2 * Copyright (c) 2022 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.
18 // Need to override adaptor classes for toolkit test harness, so include
19 // test harness headers before dali headers.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/devel-api/scripting/scripting.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
27 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
28 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
29 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
30 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
31 #include <dali-toolkit/public-api/image-loader/image.h>
32 #include <dali-toolkit/public-api/image-loader/image-url.h>
33 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
35 #include <test-native-image.h>
36 #include <test-encoded-image-buffer.h>
41 #include "dummy-control.h"
44 using namespace Toolkit;
46 void utc_dali_toolkit_image_view_startup(void)
48 test_return_value = TET_UNDEF;
51 void utc_dali_toolkit_image_view_cleanup(void)
53 test_return_value = TET_PASS;
59 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
60 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
62 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
63 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
65 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
66 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
67 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
68 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
69 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
70 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
72 // resolution: 34*34, pixel format: RGBA8888
73 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
74 // resolution: 600*600, pixel format: RGB888
75 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
77 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
78 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
80 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
82 void TestUrl( ImageView imageView, const std::string url )
84 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
86 std::string urlActual;
87 DALI_TEST_CHECK( value.Get( urlActual ) );
88 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
93 int UtcDaliImageViewNewP(void)
95 ToolkitTestApplication application;
97 ImageView imageView = ImageView::New();
99 DALI_TEST_CHECK( imageView );
104 int UtcDaliImageViewNewUrlP(void)
106 ToolkitTestApplication application;
108 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
109 DALI_TEST_CHECK( imageView );
111 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
116 int UtcDaliImageViewConstructorP(void)
118 ToolkitTestApplication application;
122 DALI_TEST_CHECK( !imageView );
127 int UtcDaliImageViewCopyConstructorP(void)
129 ToolkitTestApplication application;
131 // Initialize an object, ref count == 1
132 ImageView imageView = ImageView::New();
134 ImageView copy( imageView );
135 DALI_TEST_CHECK( copy );
140 int UtcDaliImageViewMoveConstructor(void)
142 ToolkitTestApplication application;
144 ImageView imageView = ImageView::New();
145 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
146 imageView.SetProperty( Actor::Property::SENSITIVE, false );
147 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
149 ImageView moved = std::move( imageView );
150 DALI_TEST_CHECK( moved );
151 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
152 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
153 DALI_TEST_CHECK( !imageView );
158 int UtcDaliImageViewAssignmentOperatorP(void)
160 ToolkitTestApplication application;
162 ImageView imageView = ImageView::New();
164 ImageView copy( imageView );
165 DALI_TEST_CHECK( copy );
166 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
171 int UtcDaliImageViewMoveAssignment(void)
173 ToolkitTestApplication application;
175 ImageView imageView = ImageView::New();
176 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
177 imageView.SetProperty( Actor::Property::SENSITIVE, false );
178 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
181 moved = std::move( imageView );
182 DALI_TEST_CHECK( moved );
183 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
184 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
185 DALI_TEST_CHECK( !imageView );
190 int UtcDaliImageViewDownCastP(void)
192 ToolkitTestApplication application;
194 ImageView imageView = ImageView::New();
196 BaseHandle object(imageView);
198 ImageView imageView2 = ImageView::DownCast( object );
199 DALI_TEST_CHECK(imageView2);
201 ImageView imageView3 = DownCast< ImageView >( object );
202 DALI_TEST_CHECK(imageView3);
207 int UtcDaliImageViewDownCastN(void)
209 ToolkitTestApplication application;
211 BaseHandle unInitializedObject;
213 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
214 DALI_TEST_CHECK( !imageView1 );
216 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
217 DALI_TEST_CHECK( !imageView2 );
222 int UtcDaliImageViewTypeRegistry(void)
224 ToolkitTestApplication application;
226 TypeRegistry typeRegistry = TypeRegistry::Get();
227 DALI_TEST_CHECK( typeRegistry );
229 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
230 DALI_TEST_CHECK( typeInfo );
232 BaseHandle handle = typeInfo.CreateInstance();
233 DALI_TEST_CHECK( handle );
235 ImageView imageView = ImageView::DownCast( handle );
236 DALI_TEST_CHECK( imageView );
241 int UtcDaliImageViewSetGetProperty01(void)
243 ToolkitTestApplication application;
245 ImageView imageView = ImageView::New();
247 Property::Index idx = imageView.GetPropertyIndex( "image" );
248 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
250 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
251 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
256 int UtcDaliImageViewPreMultipliedAlphaPng(void)
258 ToolkitTestApplication application;
260 // Set up trace debug
261 TestGlAbstraction& gl = application.GetGlAbstraction();
262 TraceCallStack& textureTrace = gl.GetTextureTrace();
263 textureTrace.Enable( true );
265 Property::Map imageMap;
266 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
267 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
269 ImageView imageView1 = ImageView::New();
270 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
272 application.GetScene().Add( imageView1 );
274 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
276 DALI_TEST_CHECK( value.Get( enable ) );
277 DALI_TEST_CHECK( enable ); // Default value is true
279 // loading started, this waits for the loader thread for max 30 seconds
280 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
282 application.SendNotification();
283 application.Render();
285 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
286 DALI_TEST_CHECK( value.Get( enable ) );
287 DALI_TEST_CHECK( enable ); // Keep true
289 // conventional alpha blending
290 Renderer renderer1 = imageView1.GetRendererAt( 0 );
291 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
292 DALI_TEST_CHECK( value.Get( enable ) );
293 DALI_TEST_CHECK( enable );
295 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
296 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
297 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
298 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
299 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
300 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
301 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
302 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
304 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
305 textureTrace.Reset();
307 // Disable pre-multiplied alpha blending
308 imageView1.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
311 Property::Map attributes;
312 DevelControl::DoAction( imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes );
314 // loading started, this waits for the loader thread for max 30 seconds
315 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
317 application.SendNotification();
318 application.Render();
320 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
321 DALI_TEST_CHECK( value.Get( enable ) );
322 DALI_TEST_CHECK( !enable );
324 // conventional alpha blending
325 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
326 DALI_TEST_CHECK( value.Get( enable ) );
327 DALI_TEST_CHECK( !enable );
329 srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
330 destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
331 srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
332 destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
333 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
334 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
335 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
336 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
338 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
339 textureTrace.Reset();
341 // Make a new ImageView using the same image
342 ImageView imageView2 = ImageView::New();
343 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
345 application.GetScene().Add( imageView2 );
347 application.SendNotification();
348 application.Render();
350 Renderer renderer2 = imageView2.GetRendererAt( 0 );
351 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
352 DALI_TEST_CHECK( value.Get( enable ) );
353 DALI_TEST_CHECK( enable );
355 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
356 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
357 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
358 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
359 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
360 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
361 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
362 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
364 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
369 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
371 ToolkitTestApplication application;
373 // Set up trace debug
374 TestGlAbstraction& gl = application.GetGlAbstraction();
375 TraceCallStack& textureTrace = gl.GetTextureTrace();
376 textureTrace.Enable( true );
378 Property::Map imageMap;
379 imageMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
380 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
382 ImageView imageView1 = ImageView::New();
383 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
385 application.GetScene().Add( imageView1 );
387 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
389 DALI_TEST_CHECK( value.Get( enable ) );
390 DALI_TEST_CHECK( enable ); // Default value is true
392 // loading started, this waits for the loader thread for max 30 seconds
393 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
395 application.SendNotification();
396 application.Render();
398 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
399 DALI_TEST_CHECK( value.Get( enable ) );
400 DALI_TEST_CHECK( !enable ); // Should be false after loading
402 // conventional alpha blending
403 Renderer renderer1 = imageView1.GetRendererAt( 0 );
404 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
405 DALI_TEST_CHECK( value.Get( enable ) );
406 DALI_TEST_CHECK( !enable );
408 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
409 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
410 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
411 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
412 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
413 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
414 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
415 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
417 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
418 textureTrace.Reset();
420 ImageView imageView2 = ImageView::New();
421 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
423 // Disable pre-multiplied alpha blending
424 imageView2.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
426 application.GetScene().Add( imageView2 );
428 application.SendNotification();
429 application.Render();
431 value = imageView2.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
432 DALI_TEST_CHECK( value.Get( enable ) );
433 DALI_TEST_CHECK( !enable );
435 // conventional alpha blending
436 Renderer renderer2 = imageView2.GetRendererAt( 0 );
437 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
438 DALI_TEST_CHECK( value.Get( enable ) );
439 DALI_TEST_CHECK( !enable );
441 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
442 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
443 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
444 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
445 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
446 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
447 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
448 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
450 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
455 int UtcDaliImageViewPixelArea(void)
457 // Test pixel area property
458 ToolkitTestApplication application;
460 static std::vector<UniformData> customUniforms =
462 UniformData("pixelArea", Property::Type::VECTOR4),
465 TestGraphicsController& graphics = application.GetGraphicsController();
466 graphics.AddCustomUniforms(customUniforms);
468 // Gif image, use AnimatedImageVisual internally
469 // Atlasing is applied to pack multiple frames, use custom wrap mode
470 ImageView gifView = ImageView::New();
471 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
472 gifView.SetProperty( ImageView::Property::IMAGE,
473 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
474 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
477 Integration::Scene stage = application.GetScene();
478 stage.Add( gifView );
481 application.SendNotification();
482 application.Render(16);
484 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
486 application.SendNotification();
487 application.Render();
488 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
490 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
491 // test that the pixel area value defined in the visual property map is registered on renderer
492 Renderer renderer = gifView.GetRendererAt(0);
493 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
494 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
496 // test that the shader has the default pixel area value registered.
497 Shader shader = renderer.GetShader();
498 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
499 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
501 // test that the uniform uses the pixelArea property on the renderer.
502 TestGlAbstraction& gl = application.GetGlAbstraction();
503 Vector4 pixelAreaUniform;
504 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
505 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
507 // set the pixelArea property on the control
508 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
509 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
510 application.SendNotification();
511 application.Render(16);
513 // check the pixelArea property on the control
514 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
515 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
516 // test that the uniform uses the pixelArea property on the control.
517 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
518 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
524 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
526 ToolkitTestApplication application;
527 TestGlAbstraction& gl = application.GetGlAbstraction();
528 const std::vector<GLuint>& textures = gl.GetBoundTextures();
529 size_t numTextures = textures.size();
531 // Async loading, no atlasing for big size image
532 ImageView imageView = ImageView::New( gImage_600_RGB );
534 // By default, Aysnc loading is used
535 application.GetScene().Add( imageView );
536 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
537 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
539 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
541 application.SendNotification();
542 application.Render(16);
543 application.SendNotification();
545 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
546 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
551 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
553 ToolkitTestApplication application;
555 //Async loading, automatic atlasing for small size image
556 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
558 callStack.Enable(true);
560 Property::Map imageMap;
562 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
563 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
564 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
565 imageMap[ ImageVisual::Property::ATLASING] = true;
567 ImageView imageView = ImageView::New();
568 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
569 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
571 // By default, Aysnc loading is used
572 // loading is not started if the actor is offScene
574 application.GetScene().Add( imageView );
575 application.SendNotification();
576 application.Render(16);
577 application.Render(16);
578 application.SendNotification();
580 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
581 application.SendNotification();
582 application.Render(16);
583 application.Render(16);
584 application.SendNotification();
586 // loading started, this waits for the loader thread for max 30 seconds
587 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
589 application.SendNotification();
590 application.Render(16);
592 callStack.Enable(false);
594 TraceCallStack::NamedParams params;
595 params["width"] << 34;
596 params["height"] << 34;
597 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
602 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
604 ToolkitTestApplication application;
606 //Async loading, automatic atlasing for small size image
607 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
609 callStack.Enable(true);
611 Property::Map asyncLoadingMap;
612 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
613 asyncLoadingMap[ "desiredHeight" ] = 34;
614 asyncLoadingMap[ "desiredWidth" ] = 34;
615 asyncLoadingMap[ "synchronousLoading" ] = false;
616 asyncLoadingMap[ "atlasing" ] = true;
618 ImageView imageView = ImageView::New();
619 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
621 application.GetScene().Add( imageView );
622 application.SendNotification();
623 application.Render(16);
624 application.Render(16);
625 application.SendNotification();
627 // loading started, this waits for the loader thread for max 30 seconds
628 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
630 application.SendNotification();
631 application.Render(16);
633 callStack.Enable(false);
635 TraceCallStack::NamedParams params;
636 params["width"] << 34;
637 params["height"] << 34;
638 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
643 int UtcDaliImageViewSyncLoading(void)
645 ToolkitTestApplication application;
647 tet_infoline("ImageView Testing sync loading and size using index key property map");
649 Property::Map syncLoadingMap;
650 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
651 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
653 // Sync loading, no atlasing for big size image
655 ImageView imageView = ImageView::New();
657 // Sync loading is used
658 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
659 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
662 // Sync loading, automatic atlasing for small size image
664 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
666 callStack.Enable(true);
668 ImageView imageView = ImageView::New( );
670 // Sync loading is used
671 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
672 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
673 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
674 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
676 application.GetScene().Add( imageView );
677 application.SendNotification();
678 application.Render(16);
680 TraceCallStack::NamedParams params;
681 params["width"] << 34;
682 params["height"] << 34;
683 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
684 true, TEST_LOCATION );
689 int UtcDaliImageViewSyncLoading02(void)
691 ToolkitTestApplication application;
693 tet_infoline("ImageView Testing sync loading and size using string key property map");
695 // Sync loading, automatic atlasing for small size image
697 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
699 callStack.Enable(true);
701 ImageView imageView = ImageView::New( );
703 // Sync loading is used
704 Property::Map syncLoadingMap;
705 syncLoadingMap[ "url" ] = gImage_34_RGBA;
706 syncLoadingMap[ "desiredHeight" ] = 34;
707 syncLoadingMap[ "desiredWidth" ] = 34;
708 syncLoadingMap[ "synchronousLoading" ] = true;
709 syncLoadingMap[ "atlasing" ] = true;
710 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
712 application.GetScene().Add( imageView );
713 application.SendNotification();
714 application.Render(16);
716 TraceCallStack::NamedParams params;
717 params["width"] << 34;
718 params["height"] << 34;
719 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
720 true, TEST_LOCATION );
725 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
727 ToolkitTestApplication application;
728 TestGlAbstraction& gl = application.GetGlAbstraction();
729 const std::vector<GLuint>& textures = gl.GetBoundTextures();
730 size_t numTextures = textures.size();
732 // Get encoded raw-buffer image and generate url
733 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
734 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
736 // Async loading, no atlasing for big size image
737 ImageView imageView = ImageView::New(url.GetUrl());
739 // By default, Aysnc loading is used
740 application.GetScene().Add(imageView);
741 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
742 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
744 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
746 application.SendNotification();
747 application.Render(16);
748 application.SendNotification();
750 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
751 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
756 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
758 ToolkitTestApplication application;
760 // Get encoded raw-buffer image and generate url
761 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
762 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
763 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
765 // Generate url is not equal to url2
766 // NOTE : This behavior may changed when ImageUrl compare operator changed.
767 DALI_TEST_CHECK(url != url2);
768 // Generate url's string is equal to url2's string
769 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
771 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
772 url2 = Toolkit::Image::GenerateUrl(buffer2);
774 // Check whethere two url are not equal
775 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
777 // Async loading, automatic atlasing for small size image
778 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
780 callStack.Enable(true);
782 Property::Map imageMap;
784 imageMap[ ImageVisual::Property::URL ] = url.GetUrl();
785 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
786 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
787 imageMap[ ImageVisual::Property::ATLASING] = true;
789 ImageView imageView = ImageView::New();
790 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
791 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
793 // By default, Aysnc loading is used
794 // loading is not started if the actor is offScene
796 application.GetScene().Add( imageView );
797 application.SendNotification();
798 application.Render(16);
799 application.Render(16);
800 application.SendNotification();
802 // Change url to url2
803 imageMap[ ImageVisual::Property::URL ] = url2.GetUrl();
804 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
806 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
807 application.SendNotification();
808 application.Render(16);
809 application.Render(16);
810 application.SendNotification();
812 // loading started, this waits for the loader thread for max 30 seconds
813 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
815 application.SendNotification();
816 application.Render(16);
818 callStack.Enable(false);
820 TraceCallStack::NamedParams params;
821 params["width"] << 34;
822 params["height"] << 34;
823 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
828 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
830 ToolkitTestApplication application;
832 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
834 // Get encoded raw-buffer image and generate url
835 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
836 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
838 // Sync loading, automatic atlasing for small size image
840 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
842 callStack.Enable(true);
844 ImageView imageView = ImageView::New( );
846 // Sync loading is used
847 Property::Map syncLoadingMap;
848 syncLoadingMap[ "url" ] = url.GetUrl();
849 syncLoadingMap[ "desiredHeight" ] = 34;
850 syncLoadingMap[ "desiredWidth" ] = 34;
851 syncLoadingMap[ "synchronousLoading" ] = true;
852 syncLoadingMap[ "atlasing" ] = true;
853 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
855 application.GetScene().Add( imageView );
856 application.SendNotification();
857 application.Render(16);
859 TraceCallStack::NamedParams params;
860 params["width"] << 34;
861 params["height"] << 34;
862 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
863 true, TEST_LOCATION );
869 int UtcDaliImageViewAddedTexture(void)
871 ToolkitTestApplication application;
873 tet_infoline("ImageView Testing image view with texture provided manager url");
875 ImageView imageView = ImageView::New();
877 // empty texture is ok, though pointless from app point of view
879 std::string url = TextureManager::AddTexture(empty);
880 DALI_TEST_CHECK(url.size() > 0u);
882 Property::Map propertyMap;
883 propertyMap[ImageVisual::Property::URL] = url;
884 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
886 application.GetScene().Add( imageView );
887 application.SendNotification();
888 application.Render();
893 int UtcDaliImageViewSizeWithBackground(void)
895 ToolkitTestApplication application;
899 ImageView imageView = ImageView::New();
901 imageView.SetProperty( Control::Property::BACKGROUND,
903 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
904 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
905 { ImageVisual::Property::DESIRED_WIDTH, width },
906 { ImageVisual::Property::DESIRED_HEIGHT, height },
910 application.GetScene().Add( imageView );
911 application.SendNotification();
912 application.Render();
914 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
915 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
920 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
922 ToolkitTestApplication application;
924 int widthBackground = 100;
925 int heightBackground = 200;
929 ImageView imageView = ImageView::New();
931 imageView.SetProperty( Control::Property::BACKGROUND,
933 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
934 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
935 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
936 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
940 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
942 application.GetScene().Add( imageView );
943 application.SendNotification();
944 application.Render();
946 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
947 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
952 int UtcDaliImageViewHeightForWidthBackground(void)
954 ToolkitTestApplication application;
956 int widthBackground = 100;
957 int heightBackground = 200;
959 ImageView imageView = ImageView::New();
961 imageView.SetProperty( Control::Property::BACKGROUND,
963 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
964 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
965 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
966 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
970 application.GetScene().Add( imageView );
971 application.SendNotification();
972 application.Render();
974 Control control = Control::DownCast( imageView );
975 DALI_TEST_CHECK( control );
976 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
977 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
982 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
984 ToolkitTestApplication application;
986 int widthBackground = 100;
987 int heightBackground = 200;
991 ImageView imageView = ImageView::New();
993 imageView.SetProperty( Control::Property::BACKGROUND,
995 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
996 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
997 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
998 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
1002 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
1004 application.GetScene().Add( imageView );
1005 application.SendNotification();
1006 application.Render();
1008 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
1009 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
1014 int UtcDaliImageViewSetImageUrl(void)
1016 ToolkitTestApplication application;
1018 ImageView imageView = ImageView::New();
1019 imageView.SetImage( TEST_IMAGE_FILE_NAME );
1020 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
1023 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
1024 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
1029 bool gResourceReadySignalFired = false;
1030 Vector3 gNaturalSize;
1032 void ResourceReadySignal( Control control )
1034 gResourceReadySignalFired = true;
1037 int UtcDaliImageViewCheckResourceReady(void)
1039 ToolkitTestApplication application;
1041 gResourceReadySignalFired = false;
1043 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1044 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
1046 imageView.SetProperty( Control::Property::BACKGROUND,
1048 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
1049 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
1050 { ImageVisual::Property::DESIRED_WIDTH, 100 },
1051 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
1055 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1057 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1059 application.GetScene().Add( imageView );
1061 // loading started, this waits for the loader thread
1062 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1064 application.SendNotification();
1065 application.Render(16);
1067 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1069 application.SendNotification();
1070 application.Render();
1072 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1074 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1079 int UtcDaliImageViewSetImageTypeChangesP(void)
1081 ToolkitTestApplication application;
1083 ImageView imageView = ImageView::New();
1084 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1086 application.GetScene().Add( imageView );
1090 Toolkit::Visual::Base visual;
1092 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1093 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1095 application.SendNotification();
1096 application.Render( 16 );
1098 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1100 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1101 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1104 imageView.SetImage( "TEST_URL" );
1106 application.SendNotification();
1107 application.Render( 16 );
1109 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1110 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1112 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
1113 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
1114 DALI_TEST_CHECK( visual ); // Visual should be valid
1117 imageView.SetImage( "" );
1119 application.SendNotification();
1120 application.Render( 16 );
1122 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1123 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1125 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1127 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1128 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1130 // Set a URL in property map
1131 Property::Map propertyMap;
1132 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1133 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1135 application.SendNotification();
1136 application.Render( 16 );
1138 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1139 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1141 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1142 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1143 DALI_TEST_CHECK( visual ); // Visual should be valid
1145 // Set a URL in property map again
1146 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1147 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1149 application.SendNotification();
1150 application.Render( 16 );
1152 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1153 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1155 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1156 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1157 DALI_TEST_CHECK( visual ); // Visual should be valid
1159 // Set an empty URL in property map
1160 propertyMap[ImageVisual::Property::URL] = std::string();
1161 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1163 application.SendNotification();
1164 application.Render( 16 );
1166 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1167 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1169 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1170 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1171 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1173 // Set a URL in property map again
1174 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1175 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1177 application.SendNotification();
1178 application.Render( 16 );
1180 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1181 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1183 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1184 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1185 DALI_TEST_CHECK( visual ); // Visual should be valid
1187 // Set an empty property map
1188 propertyMap.Clear();
1189 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1191 application.SendNotification();
1192 application.Render( 16 );
1194 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1195 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1197 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1198 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1199 DALI_TEST_CHECK( map.Empty() ); // But PropertyMap should be empty
1200 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1205 int UtcDaliImageViewResourceUrlP(void)
1207 ToolkitTestApplication application;
1209 ImageView imageView = ImageView::New();
1210 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
1212 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
1213 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
1218 int UtcDaliImageViewReplaceImage(void)
1220 ToolkitTestApplication application;
1222 gResourceReadySignalFired = false;
1224 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1225 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1227 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1229 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1231 application.GetScene().Add( imageView );
1233 application.SendNotification();
1234 application.Render(16);
1236 // loading started, this waits for the loader thread for max 30 seconds
1237 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1239 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1241 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1243 gResourceReadySignalFired = false;
1245 imageView.SetImage(TEST_IMAGE_2);
1247 application.SendNotification();
1248 application.Render(16);
1250 // loading started, this waits for the loader thread for max 30 seconds
1251 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1253 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1255 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1257 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1262 void OnRelayoutOverride( Size size )
1264 gNaturalSize = size; // Size Relayout is using
1267 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1269 ToolkitTestApplication application;
1271 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1272 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1273 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1275 DummyControl dummyControl = DummyControl::New( true );
1276 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1277 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1279 dummyControl.Add( imageView );
1280 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1281 application.GetScene().Add( dummyControl );
1283 application.SendNotification();
1284 application.Render();
1286 // loading started, this waits for the loader thread for max 30 seconds
1287 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1289 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1290 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1292 gNaturalSize = Vector3::ZERO;
1294 imageView.SetImage(gImage_600_RGB);
1296 // Waiting for resourceReady so SendNotifcation not called here.
1298 // loading started, this waits for the loader thread for max 30 seconds
1299 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1301 // Trigger a potential relayout
1302 application.SendNotification();
1303 application.Render();
1305 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1306 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1311 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1313 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1315 ToolkitTestApplication application;
1317 gResourceReadySignalFired = false;
1319 Property::Map imageMap;
1321 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1322 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1324 tet_infoline("Creating ImageView without URL so image does not start loading");
1325 ImageView imageView = ImageView::New();
1326 tet_infoline("Connect to image loaded signal before setting image");
1327 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1328 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1329 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1331 // loading started, this waits for the loader thread
1332 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1334 application.SendNotification();
1335 application.Render(16);
1337 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1342 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1344 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1346 ToolkitTestApplication application;
1348 gResourceReadySignalFired = false;
1350 Property::Map imageMap;
1352 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1353 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1355 ImageView imageView = ImageView::New();
1356 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1357 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1359 // loading started, this waits for the loader thread
1360 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1362 application.SendNotification();
1363 application.Render(16);
1365 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1366 gResourceReadySignalFired = false;
1368 ImageView imageViewWithExistingImage = ImageView::New();
1369 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1370 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1372 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1377 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1379 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1381 ToolkitTestApplication application;
1383 gResourceReadySignalFired = false;
1385 Property::Map imageImmediateLoadingMap;
1386 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1387 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1389 tet_infoline("Immediate load an image");
1390 ImageView imageView = ImageView::New();
1391 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1392 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1394 // loading started, this waits for the loader thread
1395 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1397 application.SendNotification();
1398 application.Render(16);
1400 tet_infoline("Check image loaded");
1401 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1402 gResourceReadySignalFired = false;
1404 tet_infoline("Create another ImageView with the same URL");
1405 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1406 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1407 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1409 application.GetScene().Add( imageViewWithExistingImage );
1411 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1416 int UtcDaliImageViewPaddingProperty(void)
1418 ToolkitTestApplication application;
1420 ImageView imageView = ImageView::New();
1421 Property::Map imagePropertyMap;
1422 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1423 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1424 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1425 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1426 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1427 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1428 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1429 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1430 application.GetScene().Add( imageView );
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1437 ImageView childImage = ImageView::New();
1438 childImage.SetBackgroundColor( Color::BLACK );
1439 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1440 imageView.Add( childImage );
1442 application.SendNotification();
1443 application.Render();
1445 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1446 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1448 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1449 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1450 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1451 Property::Map resultMap;
1452 imageVisual.CreatePropertyMap( resultMap );
1454 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1455 DALI_TEST_CHECK( transformValue );
1456 Property::Map* retMap = transformValue->GetMap();
1457 DALI_TEST_CHECK( retMap );
1459 // Image Visual should be positioned depending on ImageView's padding
1460 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1465 int UtcDaliImageViewPaddingProperty02(void)
1467 ToolkitTestApplication application;
1469 ImageView imageView = ImageView::New();
1470 Property::Map imagePropertyMap;
1471 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1472 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1473 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1474 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1475 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1476 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1477 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1478 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1479 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1480 application.GetScene().Add( imageView );
1482 application.SendNotification();
1483 application.Render();
1485 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1487 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1488 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1489 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1490 Property::Map resultMap;
1491 imageVisual.CreatePropertyMap( resultMap );
1493 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1494 DALI_TEST_CHECK( transformValue );
1495 Property::Map* retMap = transformValue->GetMap();
1496 DALI_TEST_CHECK( retMap );
1498 // Image Visual should be positioned depending on ImageView's padding
1499 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1504 int UtcDaliImageViewPaddingProperty03(void)
1506 tet_infoline("Test Setting Image Padding then removing it.");
1508 ToolkitTestApplication application;
1510 ImageView imageView = ImageView::New();
1511 Property::Map imagePropertyMap;
1512 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1513 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1514 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1515 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1516 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1517 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1518 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1519 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1520 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1521 application.GetScene().Add( imageView );
1523 application.SendNotification();
1524 application.Render();
1526 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1528 tet_infoline("Remove Padding and test Visual is position correctly");
1530 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1532 application.SendNotification();
1533 application.Render();
1535 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1536 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1537 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1538 Property::Map resultMap;
1539 imageVisual.CreatePropertyMap( resultMap );
1541 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1542 DALI_TEST_CHECK( transformValue );
1543 Property::Map* retMap = transformValue->GetMap();
1544 DALI_TEST_CHECK( retMap );
1546 // Image Visual should be positioned depending on ImageView's padding
1547 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1552 int UtcDaliImageViewPaddingProperty04(void)
1554 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1556 ToolkitTestApplication application;
1558 ImageView imageView = ImageView::New();
1559 Property::Map imagePropertyMap;
1560 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1561 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1562 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1563 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1564 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1565 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1566 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1567 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1568 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1569 application.GetScene().Add( imageView );
1571 application.SendNotification();
1572 application.Render();
1574 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1576 tet_infoline("Remove Padding and test Visual is position correctly");
1578 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1580 application.SendNotification();
1581 application.Render();
1583 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1584 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1585 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1586 Property::Map resultMap;
1587 imageVisual.CreatePropertyMap( resultMap );
1589 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1590 DALI_TEST_CHECK( transformValue );
1591 Property::Map* retMap = transformValue->GetMap();
1592 DALI_TEST_CHECK( retMap );
1594 // Image Visual should be positioned depending on ImageView's padding
1595 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1600 int UtcDaliImageViewTransformTest01(void)
1602 tet_infoline("Test Setting a offset transform on the ImageView");
1604 ToolkitTestApplication application;
1606 ImageView imageView = ImageView::New();
1607 Property::Map imagePropertyMap;
1608 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1609 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1610 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1611 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1612 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1613 .Add( Visual::Property::TRANSFORM,
1614 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1615 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1616 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1618 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1619 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1620 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1621 application.GetScene().Add( imageView );
1623 application.SendNotification();
1624 application.Render();
1626 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1627 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1628 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1629 Property::Map resultMap;
1630 imageVisual.CreatePropertyMap( resultMap );
1632 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1633 DALI_TEST_CHECK( transformValue );
1634 Property::Map* retMap = transformValue->GetMap();
1635 DALI_TEST_CHECK( retMap );
1637 // Image Visual should be positioned depending on ImageView's padding
1638 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1639 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET_POLICY )->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1644 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1646 ToolkitTestApplication application;
1648 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1649 ImageView imageView = ImageView::New();
1650 Property::Map imageMap;
1651 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1652 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1653 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1654 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1655 application.GetScene().Add( imageView );
1657 // Trigger a potential relayout
1658 application.SendNotification();
1659 application.Render();
1661 Vector3 naturalSize = imageView.GetNaturalSize();
1663 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1664 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1669 int UtcDaliImageViewFillMode(void)
1671 ToolkitTestApplication application;
1673 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1675 ImageView imageView = ImageView::New();
1676 Property::Map imageMap;
1677 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1678 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1679 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1681 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1683 application.GetScene().Add( imageView );
1685 // Trigger a potential relayout
1686 application.SendNotification();
1687 application.Render();
1689 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1690 Property::Map returnedMap;
1691 visual.CreatePropertyMap( returnedMap );
1693 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1694 DALI_TEST_CHECK( value );
1695 Property::Map* map = value->GetMap();
1696 DALI_TEST_CHECK( map );
1698 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1699 DALI_TEST_CHECK( value );
1700 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1702 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1703 DALI_TEST_CHECK( value );
1704 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1709 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1711 ToolkitTestApplication application;
1713 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1714 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1716 ImageView imageView = ImageView::New();
1717 Property::Map imageMap;
1718 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1719 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1720 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1722 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1723 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1725 application.GetScene().Add( imageView );
1727 // Trigger a potential relayout
1728 application.SendNotification();
1729 application.Render();
1731 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1732 Property::Map returnedMap;
1733 visual.CreatePropertyMap( returnedMap );
1735 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1736 DALI_TEST_CHECK( value );
1737 Property::Map* map = value->GetMap();
1738 DALI_TEST_CHECK( map );
1741 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1742 DALI_TEST_CHECK( value );
1743 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1745 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1746 DALI_TEST_CHECK( value );
1747 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1749 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1750 DALI_TEST_CHECK( value );
1751 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1756 int UtcDaliImageViewFittingModesFill(void)
1758 ToolkitTestApplication application;
1760 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1761 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1763 ImageView imageView = ImageView::New();
1764 Property::Map imageMap;
1765 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1766 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1767 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1769 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1770 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1772 application.GetScene().Add( imageView );
1774 // Trigger a potential relayout
1775 application.SendNotification();
1776 application.Render();
1778 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1779 Property::Map returnedMap;
1780 visual.CreatePropertyMap( returnedMap );
1782 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1783 DALI_TEST_CHECK( value );
1784 Property::Map* map = value->GetMap();
1785 DALI_TEST_CHECK( map );
1787 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1788 DALI_TEST_CHECK( value );
1789 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1791 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1792 DALI_TEST_CHECK( value );
1793 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1795 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1796 DALI_TEST_CHECK( value );
1797 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1802 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1804 ToolkitTestApplication application;
1806 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1807 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1809 ImageView imageView = ImageView::New();
1810 Property::Map imageMap;
1811 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1812 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1813 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1815 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1816 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1818 application.GetScene().Add( imageView );
1820 // Trigger a potential relayout
1821 application.SendNotification();
1822 application.Render();
1824 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1825 Property::Map returnedMap;
1826 visual.CreatePropertyMap( returnedMap );
1828 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1829 DALI_TEST_CHECK( value );
1830 Property::Map* map = value->GetMap();
1831 DALI_TEST_CHECK( map );
1834 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1835 DALI_TEST_CHECK( value );
1836 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1838 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1839 DALI_TEST_CHECK( value );
1840 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1842 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1843 DALI_TEST_CHECK( value );
1844 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1849 int UtcDaliImageViewFittingModesCenter01(void)
1851 ToolkitTestApplication application;
1853 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1854 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1856 ImageView imageView = ImageView::New();
1857 Property::Map imageMap;
1858 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1859 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1860 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1862 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1863 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1865 application.GetScene().Add( imageView );
1867 // Trigger a potential relayout
1868 application.SendNotification();
1869 application.Render();
1871 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1872 Property::Map returnedMap;
1873 visual.CreatePropertyMap( returnedMap );
1875 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1876 DALI_TEST_CHECK( value );
1877 Property::Map* map = value->GetMap();
1878 DALI_TEST_CHECK( map );
1880 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1881 DALI_TEST_CHECK( value );
1882 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1884 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1885 DALI_TEST_CHECK( value );
1886 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1888 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1889 DALI_TEST_CHECK( value );
1890 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1895 int UtcDaliImageViewFittingModesCenter02(void)
1897 ToolkitTestApplication application;
1899 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1900 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1902 ImageView imageView = ImageView::New();
1903 Property::Map imageMap;
1904 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1905 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1906 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1908 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1909 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1911 application.GetScene().Add( imageView );
1913 // Trigger a potential relayout
1914 application.SendNotification();
1915 application.Render();
1917 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1918 Property::Map returnedMap;
1919 visual.CreatePropertyMap( returnedMap );
1921 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1922 DALI_TEST_CHECK( value );
1923 Property::Map* map = value->GetMap();
1924 DALI_TEST_CHECK( map );
1926 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1927 DALI_TEST_CHECK( value );
1928 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1930 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1931 DALI_TEST_CHECK( value );
1932 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1934 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1935 DALI_TEST_CHECK( value );
1936 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1941 int UtcDaliImageViewFittingModesFitHeight01(void)
1943 ToolkitTestApplication application;
1945 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1947 ImageView imageView = ImageView::New();
1948 Property::Map imageMap;
1949 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1950 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1951 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1953 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1954 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1956 application.GetScene().Add( imageView );
1958 // Trigger a potential relayout
1959 application.SendNotification();
1960 application.Render();
1962 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1963 Property::Map returnedMap;
1964 visual.CreatePropertyMap( returnedMap );
1966 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1967 DALI_TEST_CHECK( value );
1968 Property::Map* map = value->GetMap();
1969 DALI_TEST_CHECK( map );
1971 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1972 DALI_TEST_CHECK( value );
1973 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1975 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1976 DALI_TEST_CHECK( value );
1977 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1979 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1980 DALI_TEST_CHECK( value );
1981 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1986 int UtcDaliImageViewFittingModesFitHeight02(void)
1988 ToolkitTestApplication application;
1990 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1992 ImageView imageView = ImageView::New();
1993 Property::Map imageMap;
1994 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1995 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1996 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1998 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1999 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
2001 application.GetScene().Add( imageView );
2003 // Trigger a potential relayout
2004 application.SendNotification();
2005 application.Render();
2007 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2008 Property::Map returnedMap;
2009 visual.CreatePropertyMap( returnedMap );
2011 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2012 DALI_TEST_CHECK( value );
2013 Property::Map* map = value->GetMap();
2014 DALI_TEST_CHECK( map );
2016 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2017 DALI_TEST_CHECK( value );
2018 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2020 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2021 DALI_TEST_CHECK( value );
2022 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2024 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2025 DALI_TEST_CHECK( value );
2026 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2031 int UtcDaliImageViewFittingModesFitWidth01(void)
2033 ToolkitTestApplication application;
2035 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
2037 ImageView imageView = ImageView::New();
2038 Property::Map imageMap;
2039 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2040 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
2041 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2043 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2044 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
2046 application.GetScene().Add( imageView );
2048 // Trigger a potential relayout
2049 application.SendNotification();
2050 application.Render();
2052 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2053 Property::Map returnedMap;
2054 visual.CreatePropertyMap( returnedMap );
2056 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2057 DALI_TEST_CHECK( value );
2058 Property::Map* map = value->GetMap();
2059 DALI_TEST_CHECK( map );
2061 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2062 DALI_TEST_CHECK( value );
2063 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2065 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2066 DALI_TEST_CHECK( value );
2067 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2069 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2070 DALI_TEST_CHECK( value );
2071 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
2076 int UtcDaliImageViewFittingModesFitWidth02(void)
2078 ToolkitTestApplication application;
2080 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
2082 ImageView imageView = ImageView::New();
2083 Property::Map imageMap;
2084 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2085 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
2086 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2088 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2089 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
2091 application.GetScene().Add( imageView );
2093 // Trigger a potential relayout
2094 application.SendNotification();
2095 application.Render();
2097 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2098 Property::Map returnedMap;
2099 visual.CreatePropertyMap( returnedMap );
2101 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2102 DALI_TEST_CHECK( value );
2103 Property::Map* map = value->GetMap();
2104 DALI_TEST_CHECK( map );
2106 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2107 DALI_TEST_CHECK( value );
2108 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2110 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2111 DALI_TEST_CHECK( value );
2112 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2114 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2115 DALI_TEST_CHECK( value );
2116 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2121 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2123 ToolkitTestApplication application;
2125 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2127 ImageView imageView = ImageView::New();
2129 // 1. Render using FittingMode::SHRINK_TO_FIT
2130 Property::Map imageMap;
2131 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2132 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2133 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2135 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2136 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2138 application.GetScene().Add( imageView );
2140 // Trigger a potential relayout
2141 application.SendNotification();
2142 application.Render();
2144 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2145 Property::Map returnedMap;
2146 visual.CreatePropertyMap( returnedMap );
2148 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2149 DALI_TEST_CHECK( value );
2150 Property::Map* map = value->GetMap();
2151 DALI_TEST_CHECK( map );
2153 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2154 DALI_TEST_CHECK( value );
2155 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2157 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2158 DALI_TEST_CHECK( value );
2159 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2161 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2162 DALI_TEST_CHECK( value );
2163 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2165 // 2. Render again using DevelVisaul::CENTER
2166 Property::Map imageMap2;
2167 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2168 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2169 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2171 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2172 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2174 application.GetScene().Add( imageView );
2176 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2178 // Trigger a potential relayout
2179 application.SendNotification();
2180 application.Render();
2182 returnedMap.Clear();
2183 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2185 visual.CreatePropertyMap( returnedMap );
2187 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2188 DALI_TEST_CHECK( value );
2189 map = value->GetMap();
2190 DALI_TEST_CHECK( map );
2192 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2193 DALI_TEST_CHECK( value );
2194 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2196 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2197 DALI_TEST_CHECK( value );
2198 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2200 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2201 DALI_TEST_CHECK( value );
2202 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2204 // 3. Render again using before fittingMode
2205 Property::Map imageMap3;
2206 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2207 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2208 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2210 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2211 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2213 application.GetScene().Add( imageView );
2215 // Trigger a potential relayout
2216 application.SendNotification();
2217 application.Render();
2219 returnedMap.Clear();
2220 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2221 visual.CreatePropertyMap( returnedMap );
2223 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2224 DALI_TEST_CHECK( value );
2225 map = value->GetMap();
2226 DALI_TEST_CHECK( map );
2228 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2229 DALI_TEST_CHECK( value );
2230 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2232 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2233 DALI_TEST_CHECK( value );
2234 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2236 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2237 DALI_TEST_CHECK( value );
2238 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2243 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2245 ToolkitTestApplication application;
2247 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2249 ImageView imageView = ImageView::New();
2251 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2252 Property::Map imageMap;
2253 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2254 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2255 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2257 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2258 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2260 application.GetScene().Add( imageView );
2262 // Trigger a potential relayout
2263 application.SendNotification();
2264 application.Render();
2266 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2267 Property::Map returnedMap;
2268 visual.CreatePropertyMap( returnedMap );
2270 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2271 DALI_TEST_CHECK( value );
2272 Property::Map* map = value->GetMap();
2273 DALI_TEST_CHECK( map );
2275 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2276 DALI_TEST_CHECK( value );
2277 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2279 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2280 DALI_TEST_CHECK( value );
2281 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2283 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2284 DALI_TEST_CHECK( value );
2285 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2287 // 2. Render again using DevelVisaul::CENTER
2288 Property::Map imageMap2;
2289 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2290 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2291 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2293 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2294 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2296 application.GetScene().Add( imageView );
2298 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2300 // Trigger a potential relayout
2301 application.SendNotification();
2302 application.Render();
2304 returnedMap.Clear();
2305 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2307 visual.CreatePropertyMap( returnedMap );
2309 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2310 DALI_TEST_CHECK( value );
2311 map = value->GetMap();
2312 DALI_TEST_CHECK( map );
2314 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2315 DALI_TEST_CHECK( value );
2316 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2318 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2319 DALI_TEST_CHECK( value );
2320 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2322 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2323 DALI_TEST_CHECK( value );
2324 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2326 // 3. Render again using before fittingMode
2327 Property::Map imageMap3;
2328 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2329 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2330 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2332 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2333 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2335 application.GetScene().Add( imageView );
2337 // Trigger a potential relayout
2338 application.SendNotification();
2339 application.Render();
2341 returnedMap.Clear();
2342 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2343 visual.CreatePropertyMap( returnedMap );
2345 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2346 DALI_TEST_CHECK( value );
2347 map = value->GetMap();
2348 DALI_TEST_CHECK( map );
2350 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2351 DALI_TEST_CHECK( value );
2352 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2354 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2355 DALI_TEST_CHECK( value );
2356 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2358 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2359 DALI_TEST_CHECK( value );
2360 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2365 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2367 ToolkitTestApplication application;
2369 tet_infoline( "Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )" );
2371 ImageView imageView = ImageView::New();
2372 Property::Map imageMap;
2373 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2374 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2376 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2377 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2379 application.GetScene().Add( imageView );
2381 // Trigger a potential relayout
2382 application.SendNotification();
2383 application.Render();
2385 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2386 Property::Map returnedMap;
2387 visual.CreatePropertyMap( returnedMap );
2389 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2390 DALI_TEST_CHECK( value );
2391 Property::Map* map = value->GetMap();
2392 DALI_TEST_CHECK( map );
2394 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2395 DALI_TEST_CHECK( value );
2396 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2398 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2399 DALI_TEST_CHECK( value );
2400 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2402 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2403 DALI_TEST_CHECK( value );
2404 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2410 int UtcDaliImageViewCustomShader(void)
2412 ToolkitTestApplication application;
2414 // Set a custom shader with an image url
2416 Property::Map properties;
2417 Property::Map shader;
2418 const std::string vertexShader = "Foobar";
2419 const std::string fragmentShader = "Foobar";
2420 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2421 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2423 properties[Visual::Property::TYPE] = Visual::IMAGE;
2424 properties[Visual::Property::SHADER] = shader;
2425 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2427 ImageView imageView = ImageView::New();
2428 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2430 application.GetScene().Add( imageView );
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2437 Renderer renderer = imageView.GetRendererAt( 0 );
2438 Shader shader2 = renderer.GetShader();
2439 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2440 Property::Map* map = value.GetMap();
2441 DALI_TEST_CHECK( map );
2443 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2444 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2446 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2447 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2450 // Set a custom shader after setting an image url
2452 Property::Map properties;
2453 Property::Map shader;
2454 const std::string vertexShader = "Foobar";
2455 const std::string fragmentShader = "Foobar";
2456 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2457 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2459 properties[Visual::Property::SHADER] = shader;
2461 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2462 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2464 application.GetScene().Add( imageView );
2466 application.SendNotification();
2467 application.Render();
2469 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2471 Renderer renderer = imageView.GetRendererAt( 0 );
2472 Shader shader2 = renderer.GetShader();
2473 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2474 Property::Map* map = value.GetMap();
2475 DALI_TEST_CHECK( map );
2477 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2478 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2480 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2481 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2484 // Set a custom shader before setting an image url
2486 Property::Map properties;
2487 Property::Map shader;
2488 const std::string vertexShader = "Foobar";
2489 const std::string fragmentShader = "Foobar";
2490 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2491 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2493 properties[Visual::Property::SHADER] = shader;
2495 ImageView imageView = ImageView::New();
2496 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2497 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2499 application.GetScene().Add( imageView );
2501 application.SendNotification();
2502 application.Render();
2503 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2505 Renderer renderer = imageView.GetRendererAt( 0 );
2506 Shader shader2 = renderer.GetShader();
2507 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2508 Property::Map* map = value.GetMap();
2509 DALI_TEST_CHECK( map );
2511 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2512 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2514 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2515 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2518 // Set a custom shader after setting a property map
2520 Property::Map properties;
2521 Property::Map shader;
2522 const std::string vertexShader = "Foobar";
2523 const std::string fragmentShader = "Foobar";
2524 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2525 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2527 properties[Visual::Property::SHADER] = shader;
2529 Property::Map properties1;
2530 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2531 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2533 ImageView imageView = ImageView::New();
2534 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2535 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2537 application.GetScene().Add( imageView );
2539 application.SendNotification();
2540 application.Render();
2541 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2543 Renderer renderer = imageView.GetRendererAt( 0 );
2544 Shader shader2 = renderer.GetShader();
2545 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2546 Property::Map* map = value.GetMap();
2547 DALI_TEST_CHECK( map );
2549 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2550 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2552 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2553 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2556 // Set a custom shader before setting a property map
2558 Property::Map properties;
2559 Property::Map shader;
2560 const std::string vertexShader = "Foobar";
2561 const std::string fragmentShader = "Foobar";
2562 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2563 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2565 properties[Visual::Property::SHADER] = shader;
2567 Property::Map properties1;
2568 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2569 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2571 ImageView imageView = ImageView::New();
2572 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2573 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2575 application.GetScene().Add( imageView );
2577 application.SendNotification();
2578 application.Render();
2579 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2581 Renderer renderer = imageView.GetRendererAt( 0 );
2582 Shader shader2 = renderer.GetShader();
2583 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2584 Property::Map* map = value.GetMap();
2585 DALI_TEST_CHECK( map );
2587 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2588 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2590 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2591 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2600 static int gFailCounter = 0;
2601 const int MAX_RETRIES(3);
2603 void ReloadImage(ImageView imageView)
2605 Property::Map imageImmediateLoadingMap;
2606 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2607 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2609 tet_infoline("Immediate load an image");
2610 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2613 void ResourceFailedReload( Control control )
2616 if( gFailCounter < MAX_RETRIES )
2618 ReloadImage(ImageView::DownCast(control));
2623 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2625 tet_infoline("Test reloading failed image from within signal handler.");
2627 ToolkitTestApplication application;
2631 ImageView imageView = ImageView::New();
2632 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2633 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2634 ReloadImage(imageView);
2636 // loading started, this waits for the loader thread to complete
2637 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2638 application.SendNotification();
2640 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2642 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2643 application.SendNotification();
2645 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2647 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2648 application.SendNotification();
2649 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2654 int UtcDaliImageViewLoadRemoteSVG(void)
2656 tet_infoline("Test load from a remote server.");
2658 ToolkitTestApplication application;
2659 Toolkit::ImageView imageView;
2660 imageView = Toolkit::ImageView::New();
2661 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2662 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2663 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2664 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2665 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2666 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2667 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2669 application.GetScene().Add( imageView );
2671 DALI_TEST_CHECK( imageView );
2673 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2675 application.SendNotification();
2677 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2679 application.SendNotification();
2680 application.Render();
2682 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2687 int UtcDaliImageViewSyncSVGLoading(void)
2689 ToolkitTestApplication application;
2691 tet_infoline("ImageView Testing SVG image sync loading");
2693 // Sync loading, automatic atlasing for small size image
2695 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2697 callStack.Enable(true);
2699 ImageView imageView = ImageView::New( );
2701 // Sync loading is used
2702 Property::Map syncLoadingMap;
2703 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2704 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2705 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2706 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2708 application.GetScene().Add( imageView );
2709 DALI_TEST_CHECK( imageView );
2711 application.SendNotification();
2712 application.Render(16);
2713 Vector3 naturalSize = imageView.GetNaturalSize();
2715 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2716 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2722 int UtcDaliImageViewAsyncSVGLoading(void)
2724 ToolkitTestApplication application;
2726 tet_infoline("ImageView Testing SVG image async loading");
2728 // Sync loading, automatic atlasing for small size image
2730 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2732 callStack.Enable(true);
2734 ImageView imageView = ImageView::New( );
2736 // Sync loading is used
2737 Property::Map syncLoadingMap;
2738 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2739 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2740 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2741 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2743 application.GetScene().Add( imageView );
2744 DALI_TEST_CHECK( imageView );
2746 application.SendNotification();
2747 application.Render(16);
2748 Vector3 naturalSize = imageView.GetNaturalSize();
2750 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2751 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2756 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2758 ToolkitTestApplication application;
2760 tet_infoline("ImageView Testing SVG image async loading");
2762 // Sync loading, automatic atlasing for small size image
2764 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2766 callStack.Enable(true);
2768 ImageView imageView = ImageView::New( );
2770 // Sync loading is used
2771 Property::Map syncLoadingMap;
2772 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2773 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2775 // Check to set invalid value
2776 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2777 // Check if error log is outputted when setting other value like string.
2778 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2779 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2780 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2782 application.GetScene().Add( imageView );
2783 DALI_TEST_CHECK( imageView );
2785 application.SendNotification();
2786 application.Render(16);
2787 Vector3 naturalSize = imageView.GetNaturalSize();
2788 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2789 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2791 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2792 Property::Map* map = value.GetMap();
2793 DALI_TEST_CHECK( map );
2795 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2796 DALI_TEST_CHECK( sync );
2797 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2803 int UtcDaliImageViewSvgLoadingFailure(void)
2805 ToolkitTestApplication application;
2807 // Local svg file - invalid file path
2809 gResourceReadySignalFired = false;
2811 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/foo.svg" );
2812 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2813 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2815 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2817 application.GetScene().Add( imageView );
2819 application.SendNotification();
2820 application.Render(16);
2822 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2823 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2824 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2827 // Local svg file - invalid file
2829 gResourceReadySignalFired = false;
2831 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/invalid.svg" );
2832 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2833 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2835 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2837 application.GetScene().Add( imageView );
2839 application.SendNotification();
2840 application.Render(16);
2842 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2843 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2844 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2849 gResourceReadySignalFired = false;
2851 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2852 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2853 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2855 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2857 application.GetScene().Add( imageView );
2859 application.SendNotification();
2861 // loading started, this waits for the loader thread
2862 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2864 application.SendNotification();
2865 application.Render(16);
2867 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2868 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2869 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2875 int UtcDaliImageViewSvgRasterizationFailure(void)
2877 ToolkitTestApplication application;
2879 gResourceReadySignalFired = false;
2881 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/svg1.svg" );
2882 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2883 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2885 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2887 application.GetScene().Add( imageView );
2889 application.SendNotification();
2891 // loading started, this waits for the loader thread
2892 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2894 application.SendNotification();
2895 application.Render(16);
2897 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2898 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2899 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::READY, TEST_LOCATION );
2902 gResourceReadySignalFired = false;
2905 imageView.SetProperty( Actor::Property::SIZE, Vector2( 0.f, 0.f ) );
2907 application.SendNotification();
2909 // rasterization started, this waits for the rasterize thread
2910 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2912 application.SendNotification();
2913 application.Render(16);
2915 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2916 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2917 // Fail to rasterize because the size is 0.
2918 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2923 int UtcDaliImageViewTVGLoading(void)
2925 ToolkitTestApplication application;
2927 tet_infoline("ImageView Testing TVG image loading");
2930 ImageView imageView = ImageView::New( );
2932 imageView.SetImage( TEST_RESOURCE_DIR "/test.tvg" );
2934 application.GetScene().Add( imageView );
2935 DALI_TEST_CHECK( imageView );
2936 Vector3 naturalSize = imageView.GetNaturalSize();
2938 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2939 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2943 int UtcDaliImageViewImageLoadFailure01(void)
2945 ToolkitTestApplication application;
2947 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2948 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
2949 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2950 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2952 std::string brokenUrl;
2953 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2954 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
2956 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2957 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2959 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2960 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2962 ImageView imageView = ImageView::New("invalidUrl.png");
2963 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2965 application.GetScene().Add( imageView );
2966 application.SendNotification();
2967 application.Render(16);
2969 // loading started, this waits for the loader thread
2970 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2975 int UtcDaliImageViewImageLoadFailure02(void)
2977 ToolkitTestApplication application;
2979 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2980 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
2981 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2982 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2984 std::string brokenUrl;
2985 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2986 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
2988 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2989 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2991 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2992 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2994 ImageView imageView = ImageView::New("invalidUrl.png");
2995 imageView.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 30.f ) );
2996 application.GetScene().Add( imageView );
2997 application.SendNotification();
2998 application.Render(16);
3000 // loading started, this waits for the loader thread
3001 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3006 int UtcDaliImageViewImageLoadFailure03(void)
3008 ToolkitTestApplication application;
3010 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3011 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3012 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3014 std::string brokenUrl;
3015 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3016 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3018 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3019 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3021 ImageView imageView = ImageView::New("invalidUrl.png");
3022 imageView.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3023 application.GetScene().Add( imageView );
3024 application.SendNotification();
3025 application.Render(16);
3027 // loading started, this waits for the loader thread
3028 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3033 int UtcDaliImageViewImageLoadFailure04(void)
3035 ToolkitTestApplication application;
3037 ImageView imageView = ImageView::New("invalidUrl.png");
3038 imageView.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3039 application.GetScene().Add( imageView );
3040 application.SendNotification();
3041 application.Render(16);
3043 // loading started, this waits for the loader thread
3044 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3047 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3048 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3049 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3050 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3052 ImageView imageView2 = ImageView::New("invalidUrl.png");
3053 imageView2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3054 application.GetScene().Add( imageView2 );
3056 std::string brokenUrl;
3057 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3058 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3060 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3061 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3063 application.SendNotification();
3064 application.Render(16);
3066 // loading started, this waits for the loader thread
3067 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3070 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3072 ImageView imageView3 = ImageView::New("invalidUrl.png");
3073 imageView3.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3074 application.GetScene().Add( imageView3 );
3076 application.SendNotification();
3077 application.Render(16);
3079 // loading started, this waits for the loader thread
3080 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3089 static int gResourceReadySignalCounter = 0;
3091 void OnResourceReadySignal01( Control control )
3093 gResourceReadySignalCounter++;
3095 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3097 if( gResourceReadySignalCounter == 1 )
3100 // It makes the first new visual be deleted immediately
3101 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
3102 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
3105 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3107 // Make the resource ready immediately
3108 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
3112 void OnResourceReadySignal02( Control control )
3114 if(++gResourceReadySignalCounter == 1)
3116 // It makes the first new visual be deleted immediately
3117 // The first image will not be loaded.
3118 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
3119 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3120 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3124 ImageView gImageView1;
3125 ImageView gImageView2;
3126 ImageView gImageView3;
3128 void OnResourceReadySignal03( Control control )
3130 if(gResourceReadySignalCounter == 0)
3133 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3134 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3136 // 2. Load a new image
3137 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3139 // 3. Use the new image again
3140 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3141 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3143 else if(gResourceReadySignalCounter == 1)
3145 // This is called from TextureManager::ProcessQueuedTextures().
3146 gImageView1.Unparent();
3147 gImageView1.Reset();
3149 gResourceReadySignalCounter++;
3154 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3156 tet_infoline("Test setting image from within signal handler.");
3158 ToolkitTestApplication application;
3160 gResourceReadySignalCounter = 0;
3162 ImageView imageView = ImageView::New( gImage_34_RGBA );
3163 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
3165 application.GetScene().Add( imageView );
3167 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3169 application.SendNotification();
3170 application.Render();
3172 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3174 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3177 gResourceReadySignalCounter = 0;
3179 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3181 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3183 application.SendNotification();
3184 application.Render();
3186 // Run idle callback
3187 application.RunIdles();
3189 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3191 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3196 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3198 tet_infoline("Test setting image from within signal handler.");
3200 ToolkitTestApplication application;
3202 gResourceReadySignalCounter = 0;
3204 ImageView imageView = ImageView::New( gImage_34_RGBA );
3205 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal02 );
3207 application.GetScene().Add( imageView );
3209 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3211 application.SendNotification();
3212 application.Render();
3214 // Wait for loading an image
3215 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3217 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3219 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3224 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3226 tet_infoline("Test setting image from within signal handler.");
3228 ToolkitTestApplication application;
3230 gResourceReadySignalCounter = 0;
3232 gImageView1 = ImageView::New(gImage_34_RGBA);
3233 application.GetScene().Add(gImageView1);
3236 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3238 gImageView2 = ImageView::New(gImage_600_RGB);
3239 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3240 application.GetScene().Add(gImageView2);
3242 gImageView3 = ImageView::New();
3243 application.GetScene().Add(gImageView3);
3245 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3247 application.SendNotification();
3248 application.Render();