2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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>
32 #include <test-native-image.h>
37 #include "dummy-control.h"
40 using namespace Toolkit;
42 void utc_dali_toolkit_image_view_startup(void)
44 test_return_value = TET_UNDEF;
47 void utc_dali_toolkit_image_view_cleanup(void)
49 test_return_value = TET_PASS;
55 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
56 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
58 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
59 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
61 // resolution: 34*34, pixel format: RGBA8888
62 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
63 // resolution: 600*600, pixel format: RGB888
64 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
66 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
67 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
69 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
71 void TestUrl( ImageView imageView, const std::string url )
73 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
75 std::string urlActual;
76 DALI_TEST_CHECK( value.Get( urlActual ) );
77 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
82 int UtcDaliImageViewNewP(void)
84 ToolkitTestApplication application;
86 ImageView imageView = ImageView::New();
88 DALI_TEST_CHECK( imageView );
93 int UtcDaliImageViewNewUrlP(void)
95 ToolkitTestApplication application;
97 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
98 DALI_TEST_CHECK( imageView );
100 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
105 int UtcDaliImageViewConstructorP(void)
107 ToolkitTestApplication application;
111 DALI_TEST_CHECK( !imageView );
116 int UtcDaliImageViewCopyConstructorP(void)
118 ToolkitTestApplication application;
120 // Initialize an object, ref count == 1
121 ImageView imageView = ImageView::New();
123 ImageView copy( imageView );
124 DALI_TEST_CHECK( copy );
129 int UtcDaliImageViewMoveConstructor(void)
131 ToolkitTestApplication application;
133 ImageView imageView = ImageView::New();
134 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
135 imageView.SetProperty( Actor::Property::SENSITIVE, false );
136 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
138 ImageView moved = std::move( imageView );
139 DALI_TEST_CHECK( moved );
140 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
141 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
142 DALI_TEST_CHECK( !imageView );
147 int UtcDaliImageViewAssignmentOperatorP(void)
149 ToolkitTestApplication application;
151 ImageView imageView = ImageView::New();
153 ImageView copy( imageView );
154 DALI_TEST_CHECK( copy );
155 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
160 int UtcDaliImageViewMoveAssignment(void)
162 ToolkitTestApplication application;
164 ImageView imageView = ImageView::New();
165 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
166 imageView.SetProperty( Actor::Property::SENSITIVE, false );
167 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
170 moved = std::move( imageView );
171 DALI_TEST_CHECK( moved );
172 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
173 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
174 DALI_TEST_CHECK( !imageView );
179 int UtcDaliImageViewDownCastP(void)
181 ToolkitTestApplication application;
183 ImageView imageView = ImageView::New();
185 BaseHandle object(imageView);
187 ImageView imageView2 = ImageView::DownCast( object );
188 DALI_TEST_CHECK(imageView2);
190 ImageView imageView3 = DownCast< ImageView >( object );
191 DALI_TEST_CHECK(imageView3);
196 int UtcDaliImageViewDownCastN(void)
198 ToolkitTestApplication application;
200 BaseHandle unInitializedObject;
202 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
203 DALI_TEST_CHECK( !imageView1 );
205 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
206 DALI_TEST_CHECK( !imageView2 );
211 int UtcDaliImageViewTypeRegistry(void)
213 ToolkitTestApplication application;
215 TypeRegistry typeRegistry = TypeRegistry::Get();
216 DALI_TEST_CHECK( typeRegistry );
218 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
219 DALI_TEST_CHECK( typeInfo );
221 BaseHandle handle = typeInfo.CreateInstance();
222 DALI_TEST_CHECK( handle );
224 ImageView imageView = ImageView::DownCast( handle );
225 DALI_TEST_CHECK( imageView );
230 int UtcDaliImageViewSetGetProperty01(void)
232 ToolkitTestApplication application;
234 ImageView imageView = ImageView::New();
236 Property::Index idx = imageView.GetPropertyIndex( "image" );
237 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
239 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
240 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
245 int UtcDaliImageViewPreMultipliedAlphaPng(void)
247 ToolkitTestApplication application;
249 // Set up trace debug
250 TestGlAbstraction& gl = application.GetGlAbstraction();
251 TraceCallStack& textureTrace = gl.GetTextureTrace();
252 textureTrace.Enable( true );
254 Property::Map imageMap;
255 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
256 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
258 ImageView imageView1 = ImageView::New();
259 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
261 application.GetScene().Add( imageView1 );
263 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
265 DALI_TEST_CHECK( value.Get( enable ) );
266 DALI_TEST_CHECK( enable ); // Default value is true
268 // loading started, this waits for the loader thread for max 30 seconds
269 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
271 application.SendNotification();
272 application.Render();
274 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
275 DALI_TEST_CHECK( value.Get( enable ) );
276 DALI_TEST_CHECK( enable ); // Keep true
278 // conventional alpha blending
279 Renderer renderer1 = imageView1.GetRendererAt( 0 );
280 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
281 DALI_TEST_CHECK( value.Get( enable ) );
282 DALI_TEST_CHECK( enable );
284 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
285 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
286 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
287 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
288 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
289 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
290 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
291 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
293 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
294 textureTrace.Reset();
296 // Disable pre-multiplied alpha blending
297 imageView1.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
300 Property::Map attributes;
301 DevelControl::DoAction( imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes );
303 // loading started, this waits for the loader thread for max 30 seconds
304 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
306 application.SendNotification();
307 application.Render();
309 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
310 DALI_TEST_CHECK( value.Get( enable ) );
311 DALI_TEST_CHECK( !enable );
313 // conventional alpha blending
314 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
315 DALI_TEST_CHECK( value.Get( enable ) );
316 DALI_TEST_CHECK( !enable );
318 srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
319 destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
320 srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
321 destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
322 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
323 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
324 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
325 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
327 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
328 textureTrace.Reset();
330 // Make a new ImageView using the same image
331 ImageView imageView2 = ImageView::New();
332 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
334 application.GetScene().Add( imageView2 );
336 application.SendNotification();
337 application.Render();
339 Renderer renderer2 = imageView2.GetRendererAt( 0 );
340 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
341 DALI_TEST_CHECK( value.Get( enable ) );
342 DALI_TEST_CHECK( enable );
344 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
345 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
346 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
347 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
348 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
349 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
350 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
351 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
353 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
358 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
360 ToolkitTestApplication application;
362 // Set up trace debug
363 TestGlAbstraction& gl = application.GetGlAbstraction();
364 TraceCallStack& textureTrace = gl.GetTextureTrace();
365 textureTrace.Enable( true );
367 Property::Map imageMap;
368 imageMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
369 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
371 ImageView imageView1 = ImageView::New();
372 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
374 application.GetScene().Add( imageView1 );
376 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
378 DALI_TEST_CHECK( value.Get( enable ) );
379 DALI_TEST_CHECK( enable ); // Default value is true
381 // loading started, this waits for the loader thread for max 30 seconds
382 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
384 application.SendNotification();
385 application.Render();
387 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
388 DALI_TEST_CHECK( value.Get( enable ) );
389 DALI_TEST_CHECK( !enable ); // Should be false after loading
391 // conventional alpha blending
392 Renderer renderer1 = imageView1.GetRendererAt( 0 );
393 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
394 DALI_TEST_CHECK( value.Get( enable ) );
395 DALI_TEST_CHECK( !enable );
397 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
398 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
399 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
400 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
401 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
402 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
403 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
404 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
406 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
407 textureTrace.Reset();
409 ImageView imageView2 = ImageView::New();
410 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
412 // Disable pre-multiplied alpha blending
413 imageView2.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
415 application.GetScene().Add( imageView2 );
417 application.SendNotification();
418 application.Render();
420 value = imageView2.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
421 DALI_TEST_CHECK( value.Get( enable ) );
422 DALI_TEST_CHECK( !enable );
424 // conventional alpha blending
425 Renderer renderer2 = imageView2.GetRendererAt( 0 );
426 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
427 DALI_TEST_CHECK( value.Get( enable ) );
428 DALI_TEST_CHECK( !enable );
430 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
431 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
432 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
433 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
434 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
435 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
436 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
437 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
439 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
444 int UtcDaliImageViewPixelArea(void)
446 // Test pixel area property
447 ToolkitTestApplication application;
449 // Gif image, use AnimatedImageVisual internally
450 // Atlasing is applied to pack multiple frames, use custom wrap mode
451 ImageView gifView = ImageView::New();
452 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
453 gifView.SetProperty( ImageView::Property::IMAGE,
454 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
455 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
458 Integration::Scene stage = application.GetScene();
459 stage.Add( gifView );
462 application.SendNotification();
463 application.Render(16);
465 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
467 application.SendNotification();
468 application.Render();
469 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
471 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
472 // test that the pixel area value defined in the visual property map is registered on renderer
473 Renderer renderer = gifView.GetRendererAt(0);
474 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
475 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
477 // test that the shader has the default pixel area value registered.
478 Shader shader = renderer.GetShader();
479 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
480 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
482 // test that the uniform uses the pixelArea property on the renderer.
483 TestGlAbstraction& gl = application.GetGlAbstraction();
484 Vector4 pixelAreaUniform;
485 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
486 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
488 // set the pixelArea property on the control
489 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
490 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
491 application.SendNotification();
492 application.Render(16);
494 // check the pixelArea property on the control
495 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
496 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
497 // test that the uniform uses the pixelArea property on the control.
498 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
499 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
505 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
507 ToolkitTestApplication application;
508 TestGlAbstraction& gl = application.GetGlAbstraction();
509 const std::vector<GLuint>& textures = gl.GetBoundTextures();
510 size_t numTextures = textures.size();
512 // Async loading, no atlasing for big size image
513 ImageView imageView = ImageView::New( gImage_600_RGB );
515 // By default, Aysnc loading is used
516 application.GetScene().Add( imageView );
517 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
518 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
520 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
522 application.SendNotification();
523 application.Render(16);
524 application.SendNotification();
526 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
527 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
534 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
536 ToolkitTestApplication application;
538 //Async loading, automatic atlasing for small size image
539 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
541 callStack.Enable(true);
543 Property::Map imageMap;
545 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
546 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
547 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
548 imageMap[ ImageVisual::Property::ATLASING] = true;
550 ImageView imageView = ImageView::New();
551 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
552 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
554 // By default, Aysnc loading is used
555 // loading is not started if the actor is offScene
557 application.GetScene().Add( imageView );
558 application.SendNotification();
559 application.Render(16);
560 application.Render(16);
561 application.SendNotification();
563 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
564 application.SendNotification();
565 application.Render(16);
566 application.Render(16);
567 application.SendNotification();
569 // loading started, this waits for the loader thread for max 30 seconds
570 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
572 application.SendNotification();
573 application.Render(16);
575 callStack.Enable(false);
577 TraceCallStack::NamedParams params;
578 params["width"] = ToString(34);
579 params["height"] = ToString(34);
580 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
585 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
587 ToolkitTestApplication application;
589 //Async loading, automatic atlasing for small size image
590 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
592 callStack.Enable(true);
594 Property::Map asyncLoadingMap;
595 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
596 asyncLoadingMap[ "desiredHeight" ] = 34;
597 asyncLoadingMap[ "desiredWidth" ] = 34;
598 asyncLoadingMap[ "synchronousLoading" ] = false;
599 asyncLoadingMap[ "atlasing" ] = true;
601 ImageView imageView = ImageView::New();
602 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
604 application.GetScene().Add( imageView );
605 application.SendNotification();
606 application.Render(16);
607 application.Render(16);
608 application.SendNotification();
610 // loading started, this waits for the loader thread for max 30 seconds
611 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
613 application.SendNotification();
614 application.Render(16);
616 callStack.Enable(false);
618 TraceCallStack::NamedParams params;
619 params["width"] = ToString(34);
620 params["height"] = ToString(34);
621 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
626 int UtcDaliImageViewSyncLoading(void)
628 ToolkitTestApplication application;
630 tet_infoline("ImageView Testing sync loading and size using index key property map");
632 Property::Map syncLoadingMap;
633 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
634 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
636 // Sync loading, no atlasing for big size image
638 ImageView imageView = ImageView::New();
640 // Sync loading is used
641 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
642 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
645 // Sync loading, automatic atlasing for small size image
647 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
649 callStack.Enable(true);
651 ImageView imageView = ImageView::New( );
653 // Sync loading is used
654 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
655 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
656 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
657 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
659 application.GetScene().Add( imageView );
660 application.SendNotification();
661 application.Render(16);
663 TraceCallStack::NamedParams params;
664 params["width"] = ToString(34);
665 params["height"] = ToString(34);
666 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
667 true, TEST_LOCATION );
672 int UtcDaliImageViewSyncLoading02(void)
674 ToolkitTestApplication application;
676 tet_infoline("ImageView Testing sync loading and size using string key property map");
678 // Sync loading, automatic atlasing for small size image
680 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
682 callStack.Enable(true);
684 ImageView imageView = ImageView::New( );
686 // Sync loading is used
687 Property::Map syncLoadingMap;
688 syncLoadingMap[ "url" ] = gImage_34_RGBA;
689 syncLoadingMap[ "desiredHeight" ] = 34;
690 syncLoadingMap[ "desiredWidth" ] = 34;
691 syncLoadingMap[ "synchronousLoading" ] = true;
692 syncLoadingMap[ "atlasing" ] = true;
693 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
695 application.GetScene().Add( imageView );
696 application.SendNotification();
697 application.Render(16);
699 TraceCallStack::NamedParams params;
700 params["width"] = ToString(34);
701 params["height"] = ToString(34);
702 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
703 true, TEST_LOCATION );
708 int UtcDaliImageViewAddedTexture(void)
710 ToolkitTestApplication application;
712 tet_infoline("ImageView Testing image view with texture provided manager url");
714 ImageView imageView = ImageView::New();
716 // empty texture is ok, though pointless from app point of view
718 std::string url = TextureManager::AddTexture(empty);
719 DALI_TEST_CHECK(url.size() > 0u);
721 Property::Map propertyMap;
722 propertyMap[ImageVisual::Property::URL] = url;
723 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
725 application.GetScene().Add( imageView );
726 application.SendNotification();
727 application.Render();
732 int UtcDaliImageViewSizeWithBackground(void)
734 ToolkitTestApplication application;
738 ImageView imageView = ImageView::New();
740 imageView.SetProperty( Control::Property::BACKGROUND,
742 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
743 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
744 { ImageVisual::Property::DESIRED_WIDTH, width },
745 { ImageVisual::Property::DESIRED_HEIGHT, height },
749 application.GetScene().Add( imageView );
750 application.SendNotification();
751 application.Render();
753 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
754 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
759 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
761 ToolkitTestApplication application;
763 int widthBackground = 100;
764 int heightBackground = 200;
768 ImageView imageView = ImageView::New();
770 imageView.SetProperty( Control::Property::BACKGROUND,
772 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
773 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
774 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
775 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
779 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
781 application.GetScene().Add( imageView );
782 application.SendNotification();
783 application.Render();
785 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
786 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
791 int UtcDaliImageViewHeightForWidthBackground(void)
793 ToolkitTestApplication application;
795 int widthBackground = 100;
796 int heightBackground = 200;
798 ImageView imageView = ImageView::New();
800 imageView.SetProperty( Control::Property::BACKGROUND,
802 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
803 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
804 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
805 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
809 application.GetScene().Add( imageView );
810 application.SendNotification();
811 application.Render();
813 Control control = Control::DownCast( imageView );
814 DALI_TEST_CHECK( control );
815 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
816 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
821 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
823 ToolkitTestApplication application;
825 int widthBackground = 100;
826 int heightBackground = 200;
830 ImageView imageView = ImageView::New();
832 imageView.SetProperty( Control::Property::BACKGROUND,
834 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
835 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
836 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
837 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
841 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
843 application.GetScene().Add( imageView );
844 application.SendNotification();
845 application.Render();
847 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
848 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
853 int UtcDaliImageViewSetImageUrl(void)
855 ToolkitTestApplication application;
857 ImageView imageView = ImageView::New();
858 imageView.SetImage( TEST_IMAGE_FILE_NAME );
859 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
862 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
863 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
868 bool gResourceReadySignalFired = false;
869 Vector3 gNaturalSize;
871 void ResourceReadySignal( Control control )
873 gResourceReadySignalFired = true;
876 int UtcDaliImageViewCheckResourceReady(void)
878 ToolkitTestApplication application;
880 gResourceReadySignalFired = false;
882 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
883 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
885 imageView.SetProperty( Control::Property::BACKGROUND,
887 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
888 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
889 { ImageVisual::Property::DESIRED_WIDTH, 100 },
890 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
894 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
896 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
898 application.GetScene().Add( imageView );
900 // loading started, this waits for the loader thread
901 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
903 application.SendNotification();
904 application.Render(16);
906 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
908 application.SendNotification();
909 application.Render();
911 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
913 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
918 int UtcDaliImageViewSetImageTypeChangesP(void)
920 ToolkitTestApplication application;
922 ImageView imageView = ImageView::New();
923 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
925 application.GetScene().Add( imageView );
929 Toolkit::Visual::Base visual;
931 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
932 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
934 application.SendNotification();
935 application.Render( 16 );
937 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
939 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
940 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
943 imageView.SetImage( "TEST_URL" );
945 application.SendNotification();
946 application.Render( 16 );
948 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
949 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
951 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
952 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
953 DALI_TEST_CHECK( visual ); // Visual should be valid
956 imageView.SetImage( "" );
958 application.SendNotification();
959 application.Render( 16 );
961 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
962 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
964 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
966 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
967 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
969 // Set a URL in property map
970 Property::Map propertyMap;
971 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
972 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
974 application.SendNotification();
975 application.Render( 16 );
977 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
978 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
980 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
981 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
982 DALI_TEST_CHECK( visual ); // Visual should be valid
984 // Set a URL in property map again
985 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
986 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
988 application.SendNotification();
989 application.Render( 16 );
991 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
992 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
994 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
995 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
996 DALI_TEST_CHECK( visual ); // Visual should be valid
998 // Set an empty URL in property map
999 propertyMap[ImageVisual::Property::URL] = std::string();
1000 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1002 application.SendNotification();
1003 application.Render( 16 );
1005 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1006 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1008 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1009 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1010 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1015 int UtcDaliImageViewResourceUrlP(void)
1017 ToolkitTestApplication application;
1019 ImageView imageView = ImageView::New();
1020 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
1022 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
1023 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
1028 int UtcDaliImageViewReplaceImage(void)
1030 ToolkitTestApplication application;
1032 gResourceReadySignalFired = false;
1034 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1035 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1037 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1039 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1041 application.GetScene().Add( imageView );
1043 application.SendNotification();
1044 application.Render(16);
1046 // loading started, this waits for the loader thread for max 30 seconds
1047 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1049 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1051 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1053 gResourceReadySignalFired = false;
1055 imageView.SetImage(TEST_IMAGE_2);
1057 application.SendNotification();
1058 application.Render(16);
1060 // loading started, this waits for the loader thread for max 30 seconds
1061 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1063 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1065 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1067 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1072 void OnRelayoutOverride( Size size )
1074 gNaturalSize = size; // Size Relayout is using
1077 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1079 ToolkitTestApplication application;
1081 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1082 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1083 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1085 DummyControl dummyControl = DummyControl::New( true );
1086 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1087 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1089 dummyControl.Add( imageView );
1090 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1091 application.GetScene().Add( dummyControl );
1093 application.SendNotification();
1094 application.Render();
1096 // loading started, this waits for the loader thread for max 30 seconds
1097 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1099 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1102 gNaturalSize = Vector3::ZERO;
1104 imageView.SetImage(gImage_600_RGB);
1106 // Waiting for resourceReady so SendNotifcation not called here.
1108 // loading started, this waits for the loader thread for max 30 seconds
1109 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1111 // Trigger a potential relayout
1112 application.SendNotification();
1113 application.Render();
1115 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1116 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1121 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1123 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1125 ToolkitTestApplication application;
1127 gResourceReadySignalFired = false;
1129 Property::Map imageMap;
1131 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1132 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1134 tet_infoline("Creating ImageView without URL so image does not start loading");
1135 ImageView imageView = ImageView::New();
1136 tet_infoline("Connect to image loaded signal before setting image");
1137 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1138 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1139 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1141 // loading started, this waits for the loader thread
1142 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1144 application.SendNotification();
1145 application.Render(16);
1147 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1152 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1154 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1156 ToolkitTestApplication application;
1158 gResourceReadySignalFired = false;
1160 Property::Map imageMap;
1162 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1163 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1165 ImageView imageView = ImageView::New();
1166 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1167 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1169 // loading started, this waits for the loader thread
1170 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1172 application.SendNotification();
1173 application.Render(16);
1175 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1176 gResourceReadySignalFired = false;
1178 ImageView imageViewWithExistingImage = ImageView::New();
1179 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1180 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1182 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1187 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1189 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1191 ToolkitTestApplication application;
1193 gResourceReadySignalFired = false;
1195 Property::Map imageImmediateLoadingMap;
1196 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1197 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1199 tet_infoline("Immediate load an image");
1200 ImageView imageView = ImageView::New();
1201 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1202 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1204 // loading started, this waits for the loader thread
1205 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1207 application.SendNotification();
1208 application.Render(16);
1210 tet_infoline("Check image loaded");
1211 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1212 gResourceReadySignalFired = false;
1214 tet_infoline("Create another ImageView with the same URL");
1215 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1216 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1217 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1219 application.GetScene().Add( imageViewWithExistingImage );
1221 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1226 int UtcDaliImageViewPaddingProperty(void)
1228 ToolkitTestApplication application;
1230 ImageView imageView = ImageView::New();
1231 Property::Map imagePropertyMap;
1232 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1233 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1234 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1235 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1236 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1237 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1238 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1239 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1240 application.GetScene().Add( imageView );
1242 application.SendNotification();
1243 application.Render();
1245 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1247 ImageView childImage = ImageView::New();
1248 childImage.SetBackgroundColor( Color::BLACK );
1249 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1250 imageView.Add( childImage );
1252 application.SendNotification();
1253 application.Render();
1255 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1256 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1258 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1259 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1260 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1261 Property::Map resultMap;
1262 imageVisual.CreatePropertyMap( resultMap );
1264 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1265 DALI_TEST_CHECK( transformValue );
1266 Property::Map* retMap = transformValue->GetMap();
1267 DALI_TEST_CHECK( retMap );
1269 // Image Visual should be positioned depending on ImageView's padding
1270 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1275 int UtcDaliImageViewPaddingProperty02(void)
1277 ToolkitTestApplication application;
1279 ImageView imageView = ImageView::New();
1280 Property::Map imagePropertyMap;
1281 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1282 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1283 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1284 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1285 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1286 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1287 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1288 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1289 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1290 application.GetScene().Add( imageView );
1292 application.SendNotification();
1293 application.Render();
1295 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1297 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1298 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1299 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1300 Property::Map resultMap;
1301 imageVisual.CreatePropertyMap( resultMap );
1303 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1304 DALI_TEST_CHECK( transformValue );
1305 Property::Map* retMap = transformValue->GetMap();
1306 DALI_TEST_CHECK( retMap );
1308 // Image Visual should be positioned depending on ImageView's padding
1309 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1314 int UtcDaliImageViewPaddingProperty03(void)
1316 tet_infoline("Test Setting Image Padding then removing it.");
1318 ToolkitTestApplication application;
1320 ImageView imageView = ImageView::New();
1321 Property::Map imagePropertyMap;
1322 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1323 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1324 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1325 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1326 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1327 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1328 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1329 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1330 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1331 application.GetScene().Add( imageView );
1333 application.SendNotification();
1334 application.Render();
1336 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1338 tet_infoline("Remove Padding and test Visual is position correctly");
1340 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1342 application.SendNotification();
1343 application.Render();
1345 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1346 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1347 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1348 Property::Map resultMap;
1349 imageVisual.CreatePropertyMap( resultMap );
1351 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1352 DALI_TEST_CHECK( transformValue );
1353 Property::Map* retMap = transformValue->GetMap();
1354 DALI_TEST_CHECK( retMap );
1356 // Image Visual should be positioned depending on ImageView's padding
1357 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1362 int UtcDaliImageViewPaddingProperty04(void)
1364 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1366 ToolkitTestApplication application;
1368 ImageView imageView = ImageView::New();
1369 Property::Map imagePropertyMap;
1370 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1371 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1372 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1373 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1374 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1375 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1376 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1377 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1378 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1379 application.GetScene().Add( imageView );
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1386 tet_infoline("Remove Padding and test Visual is position correctly");
1388 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1390 application.SendNotification();
1391 application.Render();
1393 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1394 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1395 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1396 Property::Map resultMap;
1397 imageVisual.CreatePropertyMap( resultMap );
1399 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1400 DALI_TEST_CHECK( transformValue );
1401 Property::Map* retMap = transformValue->GetMap();
1402 DALI_TEST_CHECK( retMap );
1404 // Image Visual should be positioned depending on ImageView's padding
1405 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1410 int UtcDaliImageViewTransformTest01(void)
1412 tet_infoline("Test Setting a offset transform on the ImageView");
1414 ToolkitTestApplication application;
1416 ImageView imageView = ImageView::New();
1417 Property::Map imagePropertyMap;
1418 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1419 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1420 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1421 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1422 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1423 .Add( Visual::Property::TRANSFORM,
1424 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1425 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1426 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1428 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1429 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1430 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1431 application.GetScene().Add( imageView );
1433 application.SendNotification();
1434 application.Render();
1436 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1437 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1438 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1439 Property::Map resultMap;
1440 imageVisual.CreatePropertyMap( resultMap );
1442 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1443 DALI_TEST_CHECK( transformValue );
1444 Property::Map* retMap = transformValue->GetMap();
1445 DALI_TEST_CHECK( retMap );
1447 // Image Visual should be positioned depending on ImageView's padding
1448 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1449 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 );
1454 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1456 ToolkitTestApplication application;
1458 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1459 ImageView imageView = ImageView::New();
1460 Property::Map imageMap;
1461 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1462 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1463 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1464 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1465 application.GetScene().Add( imageView );
1467 // Trigger a potential relayout
1468 application.SendNotification();
1469 application.Render();
1471 Vector3 naturalSize = imageView.GetNaturalSize();
1473 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1474 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1479 int UtcDaliImageViewFillMode(void)
1481 ToolkitTestApplication application;
1483 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1485 ImageView imageView = ImageView::New();
1486 Property::Map imageMap;
1487 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1488 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1489 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1491 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1493 application.GetScene().Add( imageView );
1495 // Trigger a potential relayout
1496 application.SendNotification();
1497 application.Render();
1499 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1500 Property::Map returnedMap;
1501 visual.CreatePropertyMap( returnedMap );
1503 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1504 DALI_TEST_CHECK( value );
1505 Property::Map* map = value->GetMap();
1506 DALI_TEST_CHECK( map );
1508 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1509 DALI_TEST_CHECK( value );
1510 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1512 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1513 DALI_TEST_CHECK( value );
1514 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1519 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1521 ToolkitTestApplication application;
1523 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1524 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1526 ImageView imageView = ImageView::New();
1527 Property::Map imageMap;
1528 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1529 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1530 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1532 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1533 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1535 application.GetScene().Add( imageView );
1537 // Trigger a potential relayout
1538 application.SendNotification();
1539 application.Render();
1541 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1542 Property::Map returnedMap;
1543 visual.CreatePropertyMap( returnedMap );
1545 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1546 DALI_TEST_CHECK( value );
1547 Property::Map* map = value->GetMap();
1548 DALI_TEST_CHECK( map );
1551 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1552 DALI_TEST_CHECK( value );
1553 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1555 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1556 DALI_TEST_CHECK( value );
1557 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1559 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1560 DALI_TEST_CHECK( value );
1561 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1566 int UtcDaliImageViewFittingModesFill(void)
1568 ToolkitTestApplication application;
1570 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1571 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1573 ImageView imageView = ImageView::New();
1574 Property::Map imageMap;
1575 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1576 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1577 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1579 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1580 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1582 application.GetScene().Add( imageView );
1584 // Trigger a potential relayout
1585 application.SendNotification();
1586 application.Render();
1588 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1589 Property::Map returnedMap;
1590 visual.CreatePropertyMap( returnedMap );
1592 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1593 DALI_TEST_CHECK( value );
1594 Property::Map* map = value->GetMap();
1595 DALI_TEST_CHECK( map );
1597 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1598 DALI_TEST_CHECK( value );
1599 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1601 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1602 DALI_TEST_CHECK( value );
1603 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1605 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1606 DALI_TEST_CHECK( value );
1607 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1612 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1614 ToolkitTestApplication application;
1616 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1617 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1619 ImageView imageView = ImageView::New();
1620 Property::Map imageMap;
1621 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1622 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1623 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1625 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1626 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1628 application.GetScene().Add( imageView );
1630 // Trigger a potential relayout
1631 application.SendNotification();
1632 application.Render();
1634 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1635 Property::Map returnedMap;
1636 visual.CreatePropertyMap( returnedMap );
1638 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1639 DALI_TEST_CHECK( value );
1640 Property::Map* map = value->GetMap();
1641 DALI_TEST_CHECK( map );
1644 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1645 DALI_TEST_CHECK( value );
1646 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1648 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1649 DALI_TEST_CHECK( value );
1650 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1652 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1653 DALI_TEST_CHECK( value );
1654 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1659 int UtcDaliImageViewFittingModesCenter01(void)
1661 ToolkitTestApplication application;
1663 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1664 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1666 ImageView imageView = ImageView::New();
1667 Property::Map imageMap;
1668 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1669 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1670 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1672 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1673 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1675 application.GetScene().Add( imageView );
1677 // Trigger a potential relayout
1678 application.SendNotification();
1679 application.Render();
1681 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1682 Property::Map returnedMap;
1683 visual.CreatePropertyMap( returnedMap );
1685 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1686 DALI_TEST_CHECK( value );
1687 Property::Map* map = value->GetMap();
1688 DALI_TEST_CHECK( map );
1690 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1691 DALI_TEST_CHECK( value );
1692 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1694 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1695 DALI_TEST_CHECK( value );
1696 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1698 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1699 DALI_TEST_CHECK( value );
1700 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1705 int UtcDaliImageViewFittingModesCenter02(void)
1707 ToolkitTestApplication application;
1709 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1710 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1712 ImageView imageView = ImageView::New();
1713 Property::Map imageMap;
1714 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1715 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1716 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1718 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1719 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1721 application.GetScene().Add( imageView );
1723 // Trigger a potential relayout
1724 application.SendNotification();
1725 application.Render();
1727 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1728 Property::Map returnedMap;
1729 visual.CreatePropertyMap( returnedMap );
1731 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1732 DALI_TEST_CHECK( value );
1733 Property::Map* map = value->GetMap();
1734 DALI_TEST_CHECK( map );
1736 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1737 DALI_TEST_CHECK( value );
1738 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1740 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1741 DALI_TEST_CHECK( value );
1742 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1744 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1745 DALI_TEST_CHECK( value );
1746 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1751 int UtcDaliImageViewFittingModesFitHeight01(void)
1753 ToolkitTestApplication application;
1755 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1757 ImageView imageView = ImageView::New();
1758 Property::Map imageMap;
1759 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1760 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1761 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1763 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1764 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1766 application.GetScene().Add( imageView );
1768 // Trigger a potential relayout
1769 application.SendNotification();
1770 application.Render();
1772 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1773 Property::Map returnedMap;
1774 visual.CreatePropertyMap( returnedMap );
1776 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1777 DALI_TEST_CHECK( value );
1778 Property::Map* map = value->GetMap();
1779 DALI_TEST_CHECK( map );
1781 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1782 DALI_TEST_CHECK( value );
1783 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1785 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1786 DALI_TEST_CHECK( value );
1787 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1789 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1790 DALI_TEST_CHECK( value );
1791 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1796 int UtcDaliImageViewFittingModesFitHeight02(void)
1798 ToolkitTestApplication application;
1800 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1802 ImageView imageView = ImageView::New();
1803 Property::Map imageMap;
1804 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1805 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1806 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1808 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1809 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1811 application.GetScene().Add( imageView );
1813 // Trigger a potential relayout
1814 application.SendNotification();
1815 application.Render();
1817 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1818 Property::Map returnedMap;
1819 visual.CreatePropertyMap( returnedMap );
1821 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1822 DALI_TEST_CHECK( value );
1823 Property::Map* map = value->GetMap();
1824 DALI_TEST_CHECK( map );
1826 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1827 DALI_TEST_CHECK( value );
1828 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1830 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1831 DALI_TEST_CHECK( value );
1832 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1834 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1835 DALI_TEST_CHECK( value );
1836 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1841 int UtcDaliImageViewFittingModesFitWidth01(void)
1843 ToolkitTestApplication application;
1845 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
1847 ImageView imageView = ImageView::New();
1848 Property::Map imageMap;
1849 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1850 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1851 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1853 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1854 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1856 application.GetScene().Add( imageView );
1858 // Trigger a potential relayout
1859 application.SendNotification();
1860 application.Render();
1862 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1863 Property::Map returnedMap;
1864 visual.CreatePropertyMap( returnedMap );
1866 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1867 DALI_TEST_CHECK( value );
1868 Property::Map* map = value->GetMap();
1869 DALI_TEST_CHECK( map );
1871 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1872 DALI_TEST_CHECK( value );
1873 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1875 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1876 DALI_TEST_CHECK( value );
1877 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1879 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1880 DALI_TEST_CHECK( value );
1881 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1886 int UtcDaliImageViewFittingModesFitWidth02(void)
1888 ToolkitTestApplication application;
1890 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
1892 ImageView imageView = ImageView::New();
1893 Property::Map imageMap;
1894 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1895 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1896 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1898 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1899 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1901 application.GetScene().Add( imageView );
1903 // Trigger a potential relayout
1904 application.SendNotification();
1905 application.Render();
1907 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1908 Property::Map returnedMap;
1909 visual.CreatePropertyMap( returnedMap );
1911 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1912 DALI_TEST_CHECK( value );
1913 Property::Map* map = value->GetMap();
1914 DALI_TEST_CHECK( map );
1916 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1917 DALI_TEST_CHECK( value );
1918 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1920 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1921 DALI_TEST_CHECK( value );
1922 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1924 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1925 DALI_TEST_CHECK( value );
1926 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1931 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
1933 ToolkitTestApplication application;
1935 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
1937 ImageView imageView = ImageView::New();
1939 // 1. Render using FittingMode::SHRINK_TO_FIT
1940 Property::Map imageMap;
1941 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1942 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1943 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1945 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1946 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1948 application.GetScene().Add( imageView );
1950 // Trigger a potential relayout
1951 application.SendNotification();
1952 application.Render();
1954 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1955 Property::Map returnedMap;
1956 visual.CreatePropertyMap( returnedMap );
1958 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1959 DALI_TEST_CHECK( value );
1960 Property::Map* map = value->GetMap();
1961 DALI_TEST_CHECK( map );
1963 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1964 DALI_TEST_CHECK( value );
1965 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1967 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1968 DALI_TEST_CHECK( value );
1969 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1971 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1972 DALI_TEST_CHECK( value );
1973 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1975 // 2. Render again using DevelVisaul::CENTER
1976 Property::Map imageMap2;
1977 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1978 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1979 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
1981 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
1982 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1984 application.GetScene().Add( imageView );
1986 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1988 // Trigger a potential relayout
1989 application.SendNotification();
1990 application.Render();
1992 returnedMap.Clear();
1993 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1995 visual.CreatePropertyMap( returnedMap );
1997 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1998 DALI_TEST_CHECK( value );
1999 map = value->GetMap();
2000 DALI_TEST_CHECK( map );
2002 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2003 DALI_TEST_CHECK( value );
2004 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2006 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2007 DALI_TEST_CHECK( value );
2008 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2010 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2011 DALI_TEST_CHECK( value );
2012 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2014 // 3. Render again using before fittingMode
2015 Property::Map imageMap3;
2016 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2017 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2018 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2020 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2021 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2023 application.GetScene().Add( imageView );
2025 // Trigger a potential relayout
2026 application.SendNotification();
2027 application.Render();
2029 returnedMap.Clear();
2030 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2031 visual.CreatePropertyMap( returnedMap );
2033 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2034 DALI_TEST_CHECK( value );
2035 map = value->GetMap();
2036 DALI_TEST_CHECK( map );
2038 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2039 DALI_TEST_CHECK( value );
2040 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2042 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2043 DALI_TEST_CHECK( value );
2044 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2046 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2047 DALI_TEST_CHECK( value );
2048 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2053 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2055 ToolkitTestApplication application;
2057 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2059 ImageView imageView = ImageView::New();
2061 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2062 Property::Map imageMap;
2063 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2064 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2065 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2067 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2068 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2070 application.GetScene().Add( imageView );
2072 // Trigger a potential relayout
2073 application.SendNotification();
2074 application.Render();
2076 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2077 Property::Map returnedMap;
2078 visual.CreatePropertyMap( returnedMap );
2080 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2081 DALI_TEST_CHECK( value );
2082 Property::Map* map = value->GetMap();
2083 DALI_TEST_CHECK( map );
2085 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2086 DALI_TEST_CHECK( value );
2087 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2089 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2090 DALI_TEST_CHECK( value );
2091 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2093 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2094 DALI_TEST_CHECK( value );
2095 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2097 // 2. Render again using DevelVisaul::CENTER
2098 Property::Map imageMap2;
2099 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2100 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2101 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2103 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2104 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2106 application.GetScene().Add( imageView );
2108 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2110 // Trigger a potential relayout
2111 application.SendNotification();
2112 application.Render();
2114 returnedMap.Clear();
2115 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2117 visual.CreatePropertyMap( returnedMap );
2119 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2120 DALI_TEST_CHECK( value );
2121 map = value->GetMap();
2122 DALI_TEST_CHECK( map );
2124 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2125 DALI_TEST_CHECK( value );
2126 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2128 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2129 DALI_TEST_CHECK( value );
2130 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2132 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2133 DALI_TEST_CHECK( value );
2134 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2136 // 3. Render again using before fittingMode
2137 Property::Map imageMap3;
2138 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2139 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2140 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2142 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2143 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2145 application.GetScene().Add( imageView );
2147 // Trigger a potential relayout
2148 application.SendNotification();
2149 application.Render();
2151 returnedMap.Clear();
2152 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2153 visual.CreatePropertyMap( returnedMap );
2155 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2156 DALI_TEST_CHECK( value );
2157 map = value->GetMap();
2158 DALI_TEST_CHECK( map );
2160 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2161 DALI_TEST_CHECK( value );
2162 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2164 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2165 DALI_TEST_CHECK( value );
2166 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2168 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2169 DALI_TEST_CHECK( value );
2170 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2175 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2177 ToolkitTestApplication application;
2179 tet_infoline( "Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )" );
2181 ImageView imageView = ImageView::New();
2182 Property::Map imageMap;
2183 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2184 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2186 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2187 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2189 application.GetScene().Add( imageView );
2191 // Trigger a potential relayout
2192 application.SendNotification();
2193 application.Render();
2195 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2196 Property::Map returnedMap;
2197 visual.CreatePropertyMap( returnedMap );
2199 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2200 DALI_TEST_CHECK( value );
2201 Property::Map* map = value->GetMap();
2202 DALI_TEST_CHECK( map );
2204 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2205 DALI_TEST_CHECK( value );
2206 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2208 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2209 DALI_TEST_CHECK( value );
2210 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2212 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2213 DALI_TEST_CHECK( value );
2214 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2220 int UtcDaliImageViewCustomShader(void)
2222 ToolkitTestApplication application;
2224 // Set a custom shader with an image url
2226 Property::Map properties;
2227 Property::Map shader;
2228 const std::string vertexShader = "Foobar";
2229 const std::string fragmentShader = "Foobar";
2230 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2231 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2233 properties[Visual::Property::TYPE] = Visual::IMAGE;
2234 properties[Visual::Property::SHADER] = shader;
2235 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2237 ImageView imageView = ImageView::New();
2238 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2240 application.GetScene().Add( imageView );
2242 application.SendNotification();
2243 application.Render();
2245 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2247 Renderer renderer = imageView.GetRendererAt( 0 );
2248 Shader shader2 = renderer.GetShader();
2249 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2250 Property::Map* map = value.GetMap();
2251 DALI_TEST_CHECK( map );
2253 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2254 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2256 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2257 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2260 // Set a custom shader after setting an image url
2262 Property::Map properties;
2263 Property::Map shader;
2264 const std::string vertexShader = "Foobar";
2265 const std::string fragmentShader = "Foobar";
2266 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2267 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2269 properties[Visual::Property::SHADER] = shader;
2271 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2272 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2274 application.GetScene().Add( imageView );
2276 application.SendNotification();
2277 application.Render();
2279 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2281 Renderer renderer = imageView.GetRendererAt( 0 );
2282 Shader shader2 = renderer.GetShader();
2283 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2284 Property::Map* map = value.GetMap();
2285 DALI_TEST_CHECK( map );
2287 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2288 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2290 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2291 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2294 // Set a custom shader before setting an image url
2296 Property::Map properties;
2297 Property::Map shader;
2298 const std::string vertexShader = "Foobar";
2299 const std::string fragmentShader = "Foobar";
2300 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2301 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2303 properties[Visual::Property::SHADER] = shader;
2305 ImageView imageView = ImageView::New();
2306 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2307 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2309 application.GetScene().Add( imageView );
2311 application.SendNotification();
2312 application.Render();
2313 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2315 Renderer renderer = imageView.GetRendererAt( 0 );
2316 Shader shader2 = renderer.GetShader();
2317 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2318 Property::Map* map = value.GetMap();
2319 DALI_TEST_CHECK( map );
2321 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2322 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2324 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2325 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2328 // Set a custom shader after setting a property map
2330 Property::Map properties;
2331 Property::Map shader;
2332 const std::string vertexShader = "Foobar";
2333 const std::string fragmentShader = "Foobar";
2334 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2335 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2337 properties[Visual::Property::SHADER] = shader;
2339 Property::Map properties1;
2340 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2341 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2343 ImageView imageView = ImageView::New();
2344 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2345 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2347 application.GetScene().Add( imageView );
2349 application.SendNotification();
2350 application.Render();
2351 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2353 Renderer renderer = imageView.GetRendererAt( 0 );
2354 Shader shader2 = renderer.GetShader();
2355 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2356 Property::Map* map = value.GetMap();
2357 DALI_TEST_CHECK( map );
2359 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2360 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2362 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2363 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2366 // Set a custom shader before setting a property map
2368 Property::Map properties;
2369 Property::Map shader;
2370 const std::string vertexShader = "Foobar";
2371 const std::string fragmentShader = "Foobar";
2372 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2373 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2375 properties[Visual::Property::SHADER] = shader;
2377 Property::Map properties1;
2378 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2379 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2381 ImageView imageView = ImageView::New();
2382 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2383 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2385 application.GetScene().Add( imageView );
2387 application.SendNotification();
2388 application.Render();
2389 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2391 Renderer renderer = imageView.GetRendererAt( 0 );
2392 Shader shader2 = renderer.GetShader();
2393 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2394 Property::Map* map = value.GetMap();
2395 DALI_TEST_CHECK( map );
2397 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2398 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2400 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2401 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2410 static int gFailCounter = 0;
2411 const int MAX_RETRIES(3);
2413 void ReloadImage(ImageView imageView)
2415 Property::Map imageImmediateLoadingMap;
2416 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2417 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2419 tet_infoline("Immediate load an image");
2420 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2423 void ResourceFailedReload( Control control )
2426 if( gFailCounter < MAX_RETRIES )
2428 ReloadImage(ImageView::DownCast(control));
2433 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2435 tet_infoline("Test reloading failed image from within signal handler.");
2437 ToolkitTestApplication application;
2441 ImageView imageView = ImageView::New();
2442 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2443 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2444 ReloadImage(imageView);
2446 // loading started, this waits for the loader thread to complete
2447 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2448 application.SendNotification();
2450 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2452 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2453 application.SendNotification();
2455 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2457 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2458 application.SendNotification();
2459 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2464 int UtcDaliImageViewLoadRemoteSVG(void)
2466 tet_infoline("Test load from a remote server.");
2468 ToolkitTestApplication application;
2469 Toolkit::ImageView imageView;
2470 imageView = Toolkit::ImageView::New();
2471 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2472 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2473 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2474 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2475 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2476 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2477 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2479 application.GetScene().Add( imageView );
2481 DALI_TEST_CHECK( imageView );
2483 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2485 application.SendNotification();
2487 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2489 application.SendNotification();
2490 application.Render();
2492 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2497 int UtcDaliImageViewSyncSVGLoading(void)
2499 ToolkitTestApplication application;
2501 tet_infoline("ImageView Testing SVG image sync loading");
2503 // Sync loading, automatic atlasing for small size image
2505 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2507 callStack.Enable(true);
2509 ImageView imageView = ImageView::New( );
2511 // Sync loading is used
2512 Property::Map syncLoadingMap;
2513 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2514 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2515 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2516 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2518 application.GetScene().Add( imageView );
2519 DALI_TEST_CHECK( imageView );
2521 application.SendNotification();
2522 application.Render(16);
2523 Vector3 naturalSize = imageView.GetNaturalSize();
2525 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2526 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2532 int UtcDaliImageViewAsyncSVGLoading(void)
2534 ToolkitTestApplication application;
2536 tet_infoline("ImageView Testing SVG image async loading");
2538 // Sync loading, automatic atlasing for small size image
2540 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2542 callStack.Enable(true);
2544 ImageView imageView = ImageView::New( );
2546 // Sync loading is used
2547 Property::Map syncLoadingMap;
2548 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2549 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2550 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2551 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2553 application.GetScene().Add( imageView );
2554 DALI_TEST_CHECK( imageView );
2556 application.SendNotification();
2557 application.Render(16);
2558 Vector3 naturalSize = imageView.GetNaturalSize();
2560 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2561 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2566 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2568 ToolkitTestApplication application;
2570 tet_infoline("ImageView Testing SVG image async loading");
2572 // Sync loading, automatic atlasing for small size image
2574 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2576 callStack.Enable(true);
2578 ImageView imageView = ImageView::New( );
2580 // Sync loading is used
2581 Property::Map syncLoadingMap;
2582 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2583 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2585 // Check to set invalid value
2586 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2587 // Check if error log is outputted when setting other value like string.
2588 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2589 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2590 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2592 application.GetScene().Add( imageView );
2593 DALI_TEST_CHECK( imageView );
2595 application.SendNotification();
2596 application.Render(16);
2597 Vector3 naturalSize = imageView.GetNaturalSize();
2598 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2599 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2601 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2602 Property::Map* map = value.GetMap();
2603 DALI_TEST_CHECK( map );
2605 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2606 DALI_TEST_CHECK( sync );
2607 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2613 int UtcDaliImageViewSvgLoadingFailure(void)
2615 ToolkitTestApplication application;
2617 // Local svg file - invalid file path
2619 gResourceReadySignalFired = false;
2621 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/foo.svg" );
2622 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2623 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2625 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2627 application.GetScene().Add( imageView );
2629 application.SendNotification();
2631 // loading started, this waits for the loader thread
2632 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2634 application.SendNotification();
2635 application.Render(16);
2637 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2638 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2639 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2642 // Local svg file - invalid file
2644 gResourceReadySignalFired = false;
2646 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/invalid.svg" );
2647 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2648 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2650 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2652 application.GetScene().Add( imageView );
2654 application.SendNotification();
2656 // loading started, this waits for the loader thread
2657 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2659 application.SendNotification();
2660 application.Render(16);
2662 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2663 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2664 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2669 gResourceReadySignalFired = false;
2671 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2672 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2673 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2675 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2677 application.GetScene().Add( imageView );
2679 application.SendNotification();
2681 // loading started, this waits for the loader thread
2682 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2684 application.SendNotification();
2685 application.Render(16);
2687 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2688 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2689 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2695 int UtcDaliImageViewSvgRasterizationFailure(void)
2697 ToolkitTestApplication application;
2699 gResourceReadySignalFired = false;
2701 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/svg1.svg" );
2702 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2703 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2705 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2707 application.GetScene().Add( imageView );
2709 application.SendNotification();
2711 // loading started, this waits for the loader thread
2712 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2714 application.SendNotification();
2715 application.Render(16);
2717 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2718 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2719 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::READY, TEST_LOCATION );
2722 gResourceReadySignalFired = false;
2725 imageView.SetProperty( Actor::Property::SIZE, Vector2( 0.f, 0.f ) );
2727 application.SendNotification();
2729 // rasterization started, this waits for the rasterize thread
2730 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2732 application.SendNotification();
2733 application.Render(16);
2735 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2736 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2737 // Fail to rasterize because the size is 0.
2738 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2746 static int gResourceReadySignalCounter = 0;
2748 void OnResourceReadySignal( Control control )
2750 gResourceReadySignalCounter++;
2752 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
2754 if( gResourceReadySignalCounter == 1 )
2757 // It makes the first new visual be deleted immediately
2758 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2759 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2762 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
2764 // Make the resource ready immediately
2765 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
2769 void OnResourceReadySignal01( Control control )
2771 if(++gResourceReadySignalCounter == 1)
2773 // It makes the first new visual be deleted immediately
2774 // The first image will not be loaded.
2775 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
2776 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2777 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
2783 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
2785 tet_infoline("Test setting image from within signal handler.");
2787 ToolkitTestApplication application;
2789 gResourceReadySignalCounter = 0;
2791 ImageView imageView = ImageView::New( gImage_34_RGBA );
2792 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal );
2794 application.GetScene().Add( imageView );
2796 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2798 application.SendNotification();
2799 application.Render();
2801 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2803 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2806 gResourceReadySignalCounter = 0;
2808 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
2810 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2812 application.SendNotification();
2813 application.Render();
2815 // Run idle callback
2816 application.RunIdles();
2818 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2820 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2825 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
2827 tet_infoline("Test setting image from within signal handler.");
2829 ToolkitTestApplication application;
2831 gResourceReadySignalCounter = 0;
2833 ImageView imageView = ImageView::New( gImage_34_RGBA );
2834 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
2836 application.GetScene().Add( imageView );
2838 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2840 application.SendNotification();
2841 application.Render();
2843 // Wait for loading an image
2844 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2846 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2848 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );