2 * Copyright (c) 2021 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 static std::vector<UniformData> customUniforms =
451 UniformData("pixelArea", Property::Type::VECTOR4),
454 TestGraphicsController& graphics = application.GetGraphicsController();
455 graphics.AddCustomUniforms(customUniforms);
457 // Gif image, use AnimatedImageVisual internally
458 // Atlasing is applied to pack multiple frames, use custom wrap mode
459 ImageView gifView = ImageView::New();
460 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
461 gifView.SetProperty( ImageView::Property::IMAGE,
462 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
463 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
466 Integration::Scene stage = application.GetScene();
467 stage.Add( gifView );
470 application.SendNotification();
471 application.Render(16);
473 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
475 application.SendNotification();
476 application.Render();
477 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
479 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
480 // test that the pixel area value defined in the visual property map is registered on renderer
481 Renderer renderer = gifView.GetRendererAt(0);
482 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
483 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
485 // test that the shader has the default pixel area value registered.
486 Shader shader = renderer.GetShader();
487 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
488 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
490 // test that the uniform uses the pixelArea property on the renderer.
491 TestGlAbstraction& gl = application.GetGlAbstraction();
492 Vector4 pixelAreaUniform;
493 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
494 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
496 // set the pixelArea property on the control
497 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
498 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
499 application.SendNotification();
500 application.Render(16);
502 // check the pixelArea property on the control
503 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
504 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
505 // test that the uniform uses the pixelArea property on the control.
506 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
507 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
513 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
515 ToolkitTestApplication application;
516 TestGlAbstraction& gl = application.GetGlAbstraction();
517 const std::vector<GLuint>& textures = gl.GetBoundTextures();
518 size_t numTextures = textures.size();
520 // Async loading, no atlasing for big size image
521 ImageView imageView = ImageView::New( gImage_600_RGB );
523 // By default, Aysnc loading is used
524 application.GetScene().Add( imageView );
525 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
526 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
528 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
530 application.SendNotification();
531 application.Render(16);
532 application.SendNotification();
534 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
535 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
542 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
544 ToolkitTestApplication application;
546 //Async loading, automatic atlasing for small size image
547 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
549 callStack.Enable(true);
551 Property::Map imageMap;
553 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
554 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
555 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
556 imageMap[ ImageVisual::Property::ATLASING] = true;
558 ImageView imageView = ImageView::New();
559 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
560 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
562 // By default, Aysnc loading is used
563 // loading is not started if the actor is offScene
565 application.GetScene().Add( imageView );
566 application.SendNotification();
567 application.Render(16);
568 application.Render(16);
569 application.SendNotification();
571 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
572 application.SendNotification();
573 application.Render(16);
574 application.Render(16);
575 application.SendNotification();
577 // loading started, this waits for the loader thread for max 30 seconds
578 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
580 application.SendNotification();
581 application.Render(16);
583 callStack.Enable(false);
585 TraceCallStack::NamedParams params;
586 params["width"] << 34;
587 params["height"] << 34;
588 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
593 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
595 ToolkitTestApplication application;
597 //Async loading, automatic atlasing for small size image
598 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
600 callStack.Enable(true);
602 Property::Map asyncLoadingMap;
603 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
604 asyncLoadingMap[ "desiredHeight" ] = 34;
605 asyncLoadingMap[ "desiredWidth" ] = 34;
606 asyncLoadingMap[ "synchronousLoading" ] = false;
607 asyncLoadingMap[ "atlasing" ] = true;
609 ImageView imageView = ImageView::New();
610 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
612 application.GetScene().Add( imageView );
613 application.SendNotification();
614 application.Render(16);
615 application.Render(16);
616 application.SendNotification();
618 // loading started, this waits for the loader thread for max 30 seconds
619 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
621 application.SendNotification();
622 application.Render(16);
624 callStack.Enable(false);
626 TraceCallStack::NamedParams params;
627 params["width"] << 34;
628 params["height"] << 34;
629 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
634 int UtcDaliImageViewSyncLoading(void)
636 ToolkitTestApplication application;
638 tet_infoline("ImageView Testing sync loading and size using index key property map");
640 Property::Map syncLoadingMap;
641 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
642 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
644 // Sync loading, no atlasing for big size image
646 ImageView imageView = ImageView::New();
648 // Sync loading is used
649 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
650 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
653 // Sync loading, automatic atlasing for small size image
655 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
657 callStack.Enable(true);
659 ImageView imageView = ImageView::New( );
661 // Sync loading is used
662 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
663 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
664 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
665 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
667 application.GetScene().Add( imageView );
668 application.SendNotification();
669 application.Render(16);
671 TraceCallStack::NamedParams params;
672 params["width"] << 34;
673 params["height"] << 34;
674 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
675 true, TEST_LOCATION );
680 int UtcDaliImageViewSyncLoading02(void)
682 ToolkitTestApplication application;
684 tet_infoline("ImageView Testing sync loading and size using string key property map");
686 // Sync loading, automatic atlasing for small size image
688 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
690 callStack.Enable(true);
692 ImageView imageView = ImageView::New( );
694 // Sync loading is used
695 Property::Map syncLoadingMap;
696 syncLoadingMap[ "url" ] = gImage_34_RGBA;
697 syncLoadingMap[ "desiredHeight" ] = 34;
698 syncLoadingMap[ "desiredWidth" ] = 34;
699 syncLoadingMap[ "synchronousLoading" ] = true;
700 syncLoadingMap[ "atlasing" ] = true;
701 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
703 application.GetScene().Add( imageView );
704 application.SendNotification();
705 application.Render(16);
707 TraceCallStack::NamedParams params;
708 params["width"] << 34;
709 params["height"] << 34;
710 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
711 true, TEST_LOCATION );
716 int UtcDaliImageViewAddedTexture(void)
718 ToolkitTestApplication application;
720 tet_infoline("ImageView Testing image view with texture provided manager url");
722 ImageView imageView = ImageView::New();
724 // empty texture is ok, though pointless from app point of view
726 std::string url = TextureManager::AddTexture(empty);
727 DALI_TEST_CHECK(url.size() > 0u);
729 Property::Map propertyMap;
730 propertyMap[ImageVisual::Property::URL] = url;
731 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
733 application.GetScene().Add( imageView );
734 application.SendNotification();
735 application.Render();
740 int UtcDaliImageViewSizeWithBackground(void)
742 ToolkitTestApplication application;
746 ImageView imageView = ImageView::New();
748 imageView.SetProperty( Control::Property::BACKGROUND,
750 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
751 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
752 { ImageVisual::Property::DESIRED_WIDTH, width },
753 { ImageVisual::Property::DESIRED_HEIGHT, height },
757 application.GetScene().Add( imageView );
758 application.SendNotification();
759 application.Render();
761 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
762 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
767 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
769 ToolkitTestApplication application;
771 int widthBackground = 100;
772 int heightBackground = 200;
776 ImageView imageView = ImageView::New();
778 imageView.SetProperty( Control::Property::BACKGROUND,
780 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
781 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
782 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
783 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
787 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
789 application.GetScene().Add( imageView );
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
794 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
799 int UtcDaliImageViewHeightForWidthBackground(void)
801 ToolkitTestApplication application;
803 int widthBackground = 100;
804 int heightBackground = 200;
806 ImageView imageView = ImageView::New();
808 imageView.SetProperty( Control::Property::BACKGROUND,
810 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
811 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
812 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
813 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
817 application.GetScene().Add( imageView );
818 application.SendNotification();
819 application.Render();
821 Control control = Control::DownCast( imageView );
822 DALI_TEST_CHECK( control );
823 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
824 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
829 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
831 ToolkitTestApplication application;
833 int widthBackground = 100;
834 int heightBackground = 200;
838 ImageView imageView = ImageView::New();
840 imageView.SetProperty( Control::Property::BACKGROUND,
842 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
843 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
844 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
845 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
849 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
851 application.GetScene().Add( imageView );
852 application.SendNotification();
853 application.Render();
855 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
856 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
861 int UtcDaliImageViewSetImageUrl(void)
863 ToolkitTestApplication application;
865 ImageView imageView = ImageView::New();
866 imageView.SetImage( TEST_IMAGE_FILE_NAME );
867 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
870 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
871 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
876 bool gResourceReadySignalFired = false;
877 Vector3 gNaturalSize;
879 void ResourceReadySignal( Control control )
881 gResourceReadySignalFired = true;
884 int UtcDaliImageViewCheckResourceReady(void)
886 ToolkitTestApplication application;
888 gResourceReadySignalFired = false;
890 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
891 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
893 imageView.SetProperty( Control::Property::BACKGROUND,
895 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
896 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
897 { ImageVisual::Property::DESIRED_WIDTH, 100 },
898 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
902 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
904 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
906 application.GetScene().Add( imageView );
908 // loading started, this waits for the loader thread
909 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
911 application.SendNotification();
912 application.Render(16);
914 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
916 application.SendNotification();
917 application.Render();
919 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
921 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
926 int UtcDaliImageViewSetImageTypeChangesP(void)
928 ToolkitTestApplication application;
930 ImageView imageView = ImageView::New();
931 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
933 application.GetScene().Add( imageView );
937 Toolkit::Visual::Base visual;
939 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
940 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
942 application.SendNotification();
943 application.Render( 16 );
945 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
947 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
948 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
951 imageView.SetImage( "TEST_URL" );
953 application.SendNotification();
954 application.Render( 16 );
956 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
957 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
959 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
960 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
961 DALI_TEST_CHECK( visual ); // Visual should be valid
964 imageView.SetImage( "" );
966 application.SendNotification();
967 application.Render( 16 );
969 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
970 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
972 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
974 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
975 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
977 // Set a URL in property map
978 Property::Map propertyMap;
979 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
980 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
982 application.SendNotification();
983 application.Render( 16 );
985 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
986 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
988 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
989 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
990 DALI_TEST_CHECK( visual ); // Visual should be valid
992 // Set a URL in property map again
993 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
994 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
996 application.SendNotification();
997 application.Render( 16 );
999 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1000 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1002 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1003 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1004 DALI_TEST_CHECK( visual ); // Visual should be valid
1006 // Set an empty URL in property map
1007 propertyMap[ImageVisual::Property::URL] = std::string();
1008 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1010 application.SendNotification();
1011 application.Render( 16 );
1013 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1014 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1016 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1017 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1018 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1023 int UtcDaliImageViewResourceUrlP(void)
1025 ToolkitTestApplication application;
1027 ImageView imageView = ImageView::New();
1028 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
1030 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
1031 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
1036 int UtcDaliImageViewReplaceImage(void)
1038 ToolkitTestApplication application;
1040 gResourceReadySignalFired = false;
1042 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1043 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1045 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1047 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1049 application.GetScene().Add( imageView );
1051 application.SendNotification();
1052 application.Render(16);
1054 // loading started, this waits for the loader thread for max 30 seconds
1055 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1057 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1059 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1061 gResourceReadySignalFired = false;
1063 imageView.SetImage(TEST_IMAGE_2);
1065 application.SendNotification();
1066 application.Render(16);
1068 // loading started, this waits for the loader thread for max 30 seconds
1069 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1071 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1073 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1075 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1080 void OnRelayoutOverride( Size size )
1082 gNaturalSize = size; // Size Relayout is using
1085 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1087 ToolkitTestApplication application;
1089 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1090 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1091 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1093 DummyControl dummyControl = DummyControl::New( true );
1094 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1095 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1097 dummyControl.Add( imageView );
1098 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1099 application.GetScene().Add( dummyControl );
1101 application.SendNotification();
1102 application.Render();
1104 // loading started, this waits for the loader thread for max 30 seconds
1105 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1107 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1108 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1110 gNaturalSize = Vector3::ZERO;
1112 imageView.SetImage(gImage_600_RGB);
1114 // Waiting for resourceReady so SendNotifcation not called here.
1116 // loading started, this waits for the loader thread for max 30 seconds
1117 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1119 // Trigger a potential relayout
1120 application.SendNotification();
1121 application.Render();
1123 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1124 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1129 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1131 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1133 ToolkitTestApplication application;
1135 gResourceReadySignalFired = false;
1137 Property::Map imageMap;
1139 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1140 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1142 tet_infoline("Creating ImageView without URL so image does not start loading");
1143 ImageView imageView = ImageView::New();
1144 tet_infoline("Connect to image loaded signal before setting image");
1145 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1146 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1147 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1149 // loading started, this waits for the loader thread
1150 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1152 application.SendNotification();
1153 application.Render(16);
1155 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1160 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1162 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1164 ToolkitTestApplication application;
1166 gResourceReadySignalFired = false;
1168 Property::Map imageMap;
1170 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1171 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1173 ImageView imageView = ImageView::New();
1174 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1175 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1177 // loading started, this waits for the loader thread
1178 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1180 application.SendNotification();
1181 application.Render(16);
1183 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1184 gResourceReadySignalFired = false;
1186 ImageView imageViewWithExistingImage = ImageView::New();
1187 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1188 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1190 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1195 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1197 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1199 ToolkitTestApplication application;
1201 gResourceReadySignalFired = false;
1203 Property::Map imageImmediateLoadingMap;
1204 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1205 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1207 tet_infoline("Immediate load an image");
1208 ImageView imageView = ImageView::New();
1209 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1210 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1212 // loading started, this waits for the loader thread
1213 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1215 application.SendNotification();
1216 application.Render(16);
1218 tet_infoline("Check image loaded");
1219 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1220 gResourceReadySignalFired = false;
1222 tet_infoline("Create another ImageView with the same URL");
1223 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1224 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1225 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1227 application.GetScene().Add( imageViewWithExistingImage );
1229 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1234 int UtcDaliImageViewPaddingProperty(void)
1236 ToolkitTestApplication application;
1238 ImageView imageView = ImageView::New();
1239 Property::Map imagePropertyMap;
1240 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1241 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1242 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1243 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1244 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1245 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1246 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1247 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1248 application.GetScene().Add( imageView );
1250 application.SendNotification();
1251 application.Render();
1253 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1255 ImageView childImage = ImageView::New();
1256 childImage.SetBackgroundColor( Color::BLACK );
1257 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1258 imageView.Add( childImage );
1260 application.SendNotification();
1261 application.Render();
1263 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1264 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1266 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1267 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1268 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1269 Property::Map resultMap;
1270 imageVisual.CreatePropertyMap( resultMap );
1272 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1273 DALI_TEST_CHECK( transformValue );
1274 Property::Map* retMap = transformValue->GetMap();
1275 DALI_TEST_CHECK( retMap );
1277 // Image Visual should be positioned depending on ImageView's padding
1278 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1283 int UtcDaliImageViewPaddingProperty02(void)
1285 ToolkitTestApplication application;
1287 ImageView imageView = ImageView::New();
1288 Property::Map imagePropertyMap;
1289 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1290 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1291 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1292 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1293 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1294 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1295 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1296 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1297 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1298 application.GetScene().Add( imageView );
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1305 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1306 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1307 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1308 Property::Map resultMap;
1309 imageVisual.CreatePropertyMap( resultMap );
1311 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1312 DALI_TEST_CHECK( transformValue );
1313 Property::Map* retMap = transformValue->GetMap();
1314 DALI_TEST_CHECK( retMap );
1316 // Image Visual should be positioned depending on ImageView's padding
1317 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1322 int UtcDaliImageViewPaddingProperty03(void)
1324 tet_infoline("Test Setting Image Padding then removing it.");
1326 ToolkitTestApplication application;
1328 ImageView imageView = ImageView::New();
1329 Property::Map imagePropertyMap;
1330 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1331 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1332 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1333 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1334 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1335 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1336 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1337 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1338 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1339 application.GetScene().Add( imageView );
1341 application.SendNotification();
1342 application.Render();
1344 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1346 tet_infoline("Remove Padding and test Visual is position correctly");
1348 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1350 application.SendNotification();
1351 application.Render();
1353 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1354 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1355 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1356 Property::Map resultMap;
1357 imageVisual.CreatePropertyMap( resultMap );
1359 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1360 DALI_TEST_CHECK( transformValue );
1361 Property::Map* retMap = transformValue->GetMap();
1362 DALI_TEST_CHECK( retMap );
1364 // Image Visual should be positioned depending on ImageView's padding
1365 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1370 int UtcDaliImageViewPaddingProperty04(void)
1372 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1374 ToolkitTestApplication application;
1376 ImageView imageView = ImageView::New();
1377 Property::Map imagePropertyMap;
1378 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1379 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1380 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1381 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1382 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1383 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1384 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1385 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1386 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1387 application.GetScene().Add( imageView );
1389 application.SendNotification();
1390 application.Render();
1392 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1394 tet_infoline("Remove Padding and test Visual is position correctly");
1396 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1398 application.SendNotification();
1399 application.Render();
1401 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1402 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1403 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1404 Property::Map resultMap;
1405 imageVisual.CreatePropertyMap( resultMap );
1407 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1408 DALI_TEST_CHECK( transformValue );
1409 Property::Map* retMap = transformValue->GetMap();
1410 DALI_TEST_CHECK( retMap );
1412 // Image Visual should be positioned depending on ImageView's padding
1413 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1418 int UtcDaliImageViewTransformTest01(void)
1420 tet_infoline("Test Setting a offset transform on the ImageView");
1422 ToolkitTestApplication application;
1424 ImageView imageView = ImageView::New();
1425 Property::Map imagePropertyMap;
1426 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1427 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1428 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1429 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1430 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1431 .Add( Visual::Property::TRANSFORM,
1432 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1433 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1434 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1436 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1437 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1438 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1439 application.GetScene().Add( imageView );
1441 application.SendNotification();
1442 application.Render();
1444 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1445 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1446 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1447 Property::Map resultMap;
1448 imageVisual.CreatePropertyMap( resultMap );
1450 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1451 DALI_TEST_CHECK( transformValue );
1452 Property::Map* retMap = transformValue->GetMap();
1453 DALI_TEST_CHECK( retMap );
1455 // Image Visual should be positioned depending on ImageView's padding
1456 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1457 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 );
1462 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1464 ToolkitTestApplication application;
1466 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1467 ImageView imageView = ImageView::New();
1468 Property::Map imageMap;
1469 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1470 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1471 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1472 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1473 application.GetScene().Add( imageView );
1475 // Trigger a potential relayout
1476 application.SendNotification();
1477 application.Render();
1479 Vector3 naturalSize = imageView.GetNaturalSize();
1481 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1482 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1487 int UtcDaliImageViewFillMode(void)
1489 ToolkitTestApplication application;
1491 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1493 ImageView imageView = ImageView::New();
1494 Property::Map imageMap;
1495 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1496 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1497 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1499 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1501 application.GetScene().Add( imageView );
1503 // Trigger a potential relayout
1504 application.SendNotification();
1505 application.Render();
1507 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1508 Property::Map returnedMap;
1509 visual.CreatePropertyMap( returnedMap );
1511 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1512 DALI_TEST_CHECK( value );
1513 Property::Map* map = value->GetMap();
1514 DALI_TEST_CHECK( map );
1516 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1517 DALI_TEST_CHECK( value );
1518 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1520 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1521 DALI_TEST_CHECK( value );
1522 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1527 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1529 ToolkitTestApplication application;
1531 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1532 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1534 ImageView imageView = ImageView::New();
1535 Property::Map imageMap;
1536 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1537 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1538 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1540 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1541 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1543 application.GetScene().Add( imageView );
1545 // Trigger a potential relayout
1546 application.SendNotification();
1547 application.Render();
1549 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1550 Property::Map returnedMap;
1551 visual.CreatePropertyMap( returnedMap );
1553 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1554 DALI_TEST_CHECK( value );
1555 Property::Map* map = value->GetMap();
1556 DALI_TEST_CHECK( map );
1559 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1560 DALI_TEST_CHECK( value );
1561 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1563 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1564 DALI_TEST_CHECK( value );
1565 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1567 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1568 DALI_TEST_CHECK( value );
1569 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1574 int UtcDaliImageViewFittingModesFill(void)
1576 ToolkitTestApplication application;
1578 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1579 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1581 ImageView imageView = ImageView::New();
1582 Property::Map imageMap;
1583 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1584 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1585 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1587 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1588 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1590 application.GetScene().Add( imageView );
1592 // Trigger a potential relayout
1593 application.SendNotification();
1594 application.Render();
1596 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1597 Property::Map returnedMap;
1598 visual.CreatePropertyMap( returnedMap );
1600 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1601 DALI_TEST_CHECK( value );
1602 Property::Map* map = value->GetMap();
1603 DALI_TEST_CHECK( map );
1605 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1606 DALI_TEST_CHECK( value );
1607 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1609 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1610 DALI_TEST_CHECK( value );
1611 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1613 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1614 DALI_TEST_CHECK( value );
1615 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1620 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1622 ToolkitTestApplication application;
1624 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1625 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1627 ImageView imageView = ImageView::New();
1628 Property::Map imageMap;
1629 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1630 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1631 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1633 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1634 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1636 application.GetScene().Add( imageView );
1638 // Trigger a potential relayout
1639 application.SendNotification();
1640 application.Render();
1642 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1643 Property::Map returnedMap;
1644 visual.CreatePropertyMap( returnedMap );
1646 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1647 DALI_TEST_CHECK( value );
1648 Property::Map* map = value->GetMap();
1649 DALI_TEST_CHECK( map );
1652 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1653 DALI_TEST_CHECK( value );
1654 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1656 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1657 DALI_TEST_CHECK( value );
1658 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1660 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1661 DALI_TEST_CHECK( value );
1662 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1667 int UtcDaliImageViewFittingModesCenter01(void)
1669 ToolkitTestApplication application;
1671 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1672 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1674 ImageView imageView = ImageView::New();
1675 Property::Map imageMap;
1676 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1677 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1678 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1680 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1681 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1683 application.GetScene().Add( imageView );
1685 // Trigger a potential relayout
1686 application.SendNotification();
1687 application.Render();
1689 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1690 Property::Map returnedMap;
1691 visual.CreatePropertyMap( returnedMap );
1693 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1694 DALI_TEST_CHECK( value );
1695 Property::Map* map = value->GetMap();
1696 DALI_TEST_CHECK( map );
1698 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1699 DALI_TEST_CHECK( value );
1700 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1702 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1703 DALI_TEST_CHECK( value );
1704 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1706 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1707 DALI_TEST_CHECK( value );
1708 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1713 int UtcDaliImageViewFittingModesCenter02(void)
1715 ToolkitTestApplication application;
1717 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1718 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1720 ImageView imageView = ImageView::New();
1721 Property::Map imageMap;
1722 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1723 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1724 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1726 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1727 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1729 application.GetScene().Add( imageView );
1731 // Trigger a potential relayout
1732 application.SendNotification();
1733 application.Render();
1735 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1736 Property::Map returnedMap;
1737 visual.CreatePropertyMap( returnedMap );
1739 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1740 DALI_TEST_CHECK( value );
1741 Property::Map* map = value->GetMap();
1742 DALI_TEST_CHECK( map );
1744 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1745 DALI_TEST_CHECK( value );
1746 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1748 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1749 DALI_TEST_CHECK( value );
1750 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1752 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1753 DALI_TEST_CHECK( value );
1754 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1759 int UtcDaliImageViewFittingModesFitHeight01(void)
1761 ToolkitTestApplication application;
1763 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1765 ImageView imageView = ImageView::New();
1766 Property::Map imageMap;
1767 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1768 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1769 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1771 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1772 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1774 application.GetScene().Add( imageView );
1776 // Trigger a potential relayout
1777 application.SendNotification();
1778 application.Render();
1780 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1781 Property::Map returnedMap;
1782 visual.CreatePropertyMap( returnedMap );
1784 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1785 DALI_TEST_CHECK( value );
1786 Property::Map* map = value->GetMap();
1787 DALI_TEST_CHECK( map );
1789 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1790 DALI_TEST_CHECK( value );
1791 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1793 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1794 DALI_TEST_CHECK( value );
1795 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1797 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1798 DALI_TEST_CHECK( value );
1799 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1804 int UtcDaliImageViewFittingModesFitHeight02(void)
1806 ToolkitTestApplication application;
1808 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1810 ImageView imageView = ImageView::New();
1811 Property::Map imageMap;
1812 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1813 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1814 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1816 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1817 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1819 application.GetScene().Add( imageView );
1821 // Trigger a potential relayout
1822 application.SendNotification();
1823 application.Render();
1825 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1826 Property::Map returnedMap;
1827 visual.CreatePropertyMap( returnedMap );
1829 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1830 DALI_TEST_CHECK( value );
1831 Property::Map* map = value->GetMap();
1832 DALI_TEST_CHECK( map );
1834 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1835 DALI_TEST_CHECK( value );
1836 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1838 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1839 DALI_TEST_CHECK( value );
1840 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1842 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1843 DALI_TEST_CHECK( value );
1844 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1849 int UtcDaliImageViewFittingModesFitWidth01(void)
1851 ToolkitTestApplication application;
1853 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
1855 ImageView imageView = ImageView::New();
1856 Property::Map imageMap;
1857 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1858 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1859 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1861 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1862 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1864 application.GetScene().Add( imageView );
1866 // Trigger a potential relayout
1867 application.SendNotification();
1868 application.Render();
1870 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1871 Property::Map returnedMap;
1872 visual.CreatePropertyMap( returnedMap );
1874 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1875 DALI_TEST_CHECK( value );
1876 Property::Map* map = value->GetMap();
1877 DALI_TEST_CHECK( map );
1879 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1880 DALI_TEST_CHECK( value );
1881 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1883 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1884 DALI_TEST_CHECK( value );
1885 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1887 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1888 DALI_TEST_CHECK( value );
1889 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1894 int UtcDaliImageViewFittingModesFitWidth02(void)
1896 ToolkitTestApplication application;
1898 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
1900 ImageView imageView = ImageView::New();
1901 Property::Map imageMap;
1902 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1903 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1904 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1906 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1907 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1909 application.GetScene().Add( imageView );
1911 // Trigger a potential relayout
1912 application.SendNotification();
1913 application.Render();
1915 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1916 Property::Map returnedMap;
1917 visual.CreatePropertyMap( returnedMap );
1919 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1920 DALI_TEST_CHECK( value );
1921 Property::Map* map = value->GetMap();
1922 DALI_TEST_CHECK( map );
1924 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1925 DALI_TEST_CHECK( value );
1926 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1928 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1929 DALI_TEST_CHECK( value );
1930 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1932 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1933 DALI_TEST_CHECK( value );
1934 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1939 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
1941 ToolkitTestApplication application;
1943 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
1945 ImageView imageView = ImageView::New();
1947 // 1. Render using FittingMode::SHRINK_TO_FIT
1948 Property::Map imageMap;
1949 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1950 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1951 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1953 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1954 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1956 application.GetScene().Add( imageView );
1958 // Trigger a potential relayout
1959 application.SendNotification();
1960 application.Render();
1962 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1963 Property::Map returnedMap;
1964 visual.CreatePropertyMap( returnedMap );
1966 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1967 DALI_TEST_CHECK( value );
1968 Property::Map* map = value->GetMap();
1969 DALI_TEST_CHECK( map );
1971 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1972 DALI_TEST_CHECK( value );
1973 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1975 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1976 DALI_TEST_CHECK( value );
1977 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1979 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1980 DALI_TEST_CHECK( value );
1981 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1983 // 2. Render again using DevelVisaul::CENTER
1984 Property::Map imageMap2;
1985 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1986 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1987 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
1989 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
1990 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1992 application.GetScene().Add( imageView );
1994 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1996 // Trigger a potential relayout
1997 application.SendNotification();
1998 application.Render();
2000 returnedMap.Clear();
2001 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2003 visual.CreatePropertyMap( returnedMap );
2005 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2006 DALI_TEST_CHECK( value );
2007 map = value->GetMap();
2008 DALI_TEST_CHECK( map );
2010 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2011 DALI_TEST_CHECK( value );
2012 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2014 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2015 DALI_TEST_CHECK( value );
2016 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2018 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2019 DALI_TEST_CHECK( value );
2020 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2022 // 3. Render again using before fittingMode
2023 Property::Map imageMap3;
2024 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2025 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2026 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2028 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2029 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2031 application.GetScene().Add( imageView );
2033 // Trigger a potential relayout
2034 application.SendNotification();
2035 application.Render();
2037 returnedMap.Clear();
2038 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2039 visual.CreatePropertyMap( returnedMap );
2041 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2042 DALI_TEST_CHECK( value );
2043 map = value->GetMap();
2044 DALI_TEST_CHECK( map );
2046 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2047 DALI_TEST_CHECK( value );
2048 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2050 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2051 DALI_TEST_CHECK( value );
2052 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2054 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2055 DALI_TEST_CHECK( value );
2056 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2061 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2063 ToolkitTestApplication application;
2065 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2067 ImageView imageView = ImageView::New();
2069 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2070 Property::Map imageMap;
2071 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2072 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2073 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2075 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2076 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2078 application.GetScene().Add( imageView );
2080 // Trigger a potential relayout
2081 application.SendNotification();
2082 application.Render();
2084 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2085 Property::Map returnedMap;
2086 visual.CreatePropertyMap( returnedMap );
2088 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2089 DALI_TEST_CHECK( value );
2090 Property::Map* map = value->GetMap();
2091 DALI_TEST_CHECK( map );
2093 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2094 DALI_TEST_CHECK( value );
2095 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2097 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2098 DALI_TEST_CHECK( value );
2099 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2101 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2102 DALI_TEST_CHECK( value );
2103 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2105 // 2. Render again using DevelVisaul::CENTER
2106 Property::Map imageMap2;
2107 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2108 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2109 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2111 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2112 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2114 application.GetScene().Add( imageView );
2116 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2118 // Trigger a potential relayout
2119 application.SendNotification();
2120 application.Render();
2122 returnedMap.Clear();
2123 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2125 visual.CreatePropertyMap( returnedMap );
2127 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2128 DALI_TEST_CHECK( value );
2129 map = value->GetMap();
2130 DALI_TEST_CHECK( map );
2132 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2133 DALI_TEST_CHECK( value );
2134 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2136 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2137 DALI_TEST_CHECK( value );
2138 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2140 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2141 DALI_TEST_CHECK( value );
2142 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2144 // 3. Render again using before fittingMode
2145 Property::Map imageMap3;
2146 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2147 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2148 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2150 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2151 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2153 application.GetScene().Add( imageView );
2155 // Trigger a potential relayout
2156 application.SendNotification();
2157 application.Render();
2159 returnedMap.Clear();
2160 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2161 visual.CreatePropertyMap( returnedMap );
2163 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2164 DALI_TEST_CHECK( value );
2165 map = value->GetMap();
2166 DALI_TEST_CHECK( map );
2168 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2169 DALI_TEST_CHECK( value );
2170 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2172 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2173 DALI_TEST_CHECK( value );
2174 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2176 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2177 DALI_TEST_CHECK( value );
2178 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2183 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2185 ToolkitTestApplication application;
2187 tet_infoline( "Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )" );
2189 ImageView imageView = ImageView::New();
2190 Property::Map imageMap;
2191 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2192 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2194 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2195 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2197 application.GetScene().Add( imageView );
2199 // Trigger a potential relayout
2200 application.SendNotification();
2201 application.Render();
2203 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2204 Property::Map returnedMap;
2205 visual.CreatePropertyMap( returnedMap );
2207 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2208 DALI_TEST_CHECK( value );
2209 Property::Map* map = value->GetMap();
2210 DALI_TEST_CHECK( map );
2212 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2213 DALI_TEST_CHECK( value );
2214 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2216 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2217 DALI_TEST_CHECK( value );
2218 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2220 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2221 DALI_TEST_CHECK( value );
2222 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2228 int UtcDaliImageViewCustomShader(void)
2230 ToolkitTestApplication application;
2232 // Set a custom shader with an image url
2234 Property::Map properties;
2235 Property::Map shader;
2236 const std::string vertexShader = "Foobar";
2237 const std::string fragmentShader = "Foobar";
2238 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2239 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2241 properties[Visual::Property::TYPE] = Visual::IMAGE;
2242 properties[Visual::Property::SHADER] = shader;
2243 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2245 ImageView imageView = ImageView::New();
2246 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2248 application.GetScene().Add( imageView );
2250 application.SendNotification();
2251 application.Render();
2253 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2255 Renderer renderer = imageView.GetRendererAt( 0 );
2256 Shader shader2 = renderer.GetShader();
2257 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2258 Property::Map* map = value.GetMap();
2259 DALI_TEST_CHECK( map );
2261 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2262 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2264 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2265 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2268 // Set a custom shader after setting an image url
2270 Property::Map properties;
2271 Property::Map shader;
2272 const std::string vertexShader = "Foobar";
2273 const std::string fragmentShader = "Foobar";
2274 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2275 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2277 properties[Visual::Property::SHADER] = shader;
2279 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2280 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2282 application.GetScene().Add( imageView );
2284 application.SendNotification();
2285 application.Render();
2287 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2289 Renderer renderer = imageView.GetRendererAt( 0 );
2290 Shader shader2 = renderer.GetShader();
2291 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2292 Property::Map* map = value.GetMap();
2293 DALI_TEST_CHECK( map );
2295 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2296 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2298 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2299 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2302 // Set a custom shader before setting an image url
2304 Property::Map properties;
2305 Property::Map shader;
2306 const std::string vertexShader = "Foobar";
2307 const std::string fragmentShader = "Foobar";
2308 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2309 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2311 properties[Visual::Property::SHADER] = shader;
2313 ImageView imageView = ImageView::New();
2314 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2315 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2317 application.GetScene().Add( imageView );
2319 application.SendNotification();
2320 application.Render();
2321 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2323 Renderer renderer = imageView.GetRendererAt( 0 );
2324 Shader shader2 = renderer.GetShader();
2325 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2326 Property::Map* map = value.GetMap();
2327 DALI_TEST_CHECK( map );
2329 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2330 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2332 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2333 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2336 // Set a custom shader after setting a property map
2338 Property::Map properties;
2339 Property::Map shader;
2340 const std::string vertexShader = "Foobar";
2341 const std::string fragmentShader = "Foobar";
2342 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2343 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2345 properties[Visual::Property::SHADER] = shader;
2347 Property::Map properties1;
2348 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2349 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2351 ImageView imageView = ImageView::New();
2352 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2353 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2355 application.GetScene().Add( imageView );
2357 application.SendNotification();
2358 application.Render();
2359 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2361 Renderer renderer = imageView.GetRendererAt( 0 );
2362 Shader shader2 = renderer.GetShader();
2363 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2364 Property::Map* map = value.GetMap();
2365 DALI_TEST_CHECK( map );
2367 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2368 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2370 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2371 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2374 // Set a custom shader before setting a property map
2376 Property::Map properties;
2377 Property::Map shader;
2378 const std::string vertexShader = "Foobar";
2379 const std::string fragmentShader = "Foobar";
2380 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2381 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2383 properties[Visual::Property::SHADER] = shader;
2385 Property::Map properties1;
2386 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2387 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2389 ImageView imageView = ImageView::New();
2390 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2391 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2393 application.GetScene().Add( imageView );
2395 application.SendNotification();
2396 application.Render();
2397 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2399 Renderer renderer = imageView.GetRendererAt( 0 );
2400 Shader shader2 = renderer.GetShader();
2401 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2402 Property::Map* map = value.GetMap();
2403 DALI_TEST_CHECK( map );
2405 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2406 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2408 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2409 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2418 static int gFailCounter = 0;
2419 const int MAX_RETRIES(3);
2421 void ReloadImage(ImageView imageView)
2423 Property::Map imageImmediateLoadingMap;
2424 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2425 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2427 tet_infoline("Immediate load an image");
2428 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2431 void ResourceFailedReload( Control control )
2434 if( gFailCounter < MAX_RETRIES )
2436 ReloadImage(ImageView::DownCast(control));
2441 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2443 tet_infoline("Test reloading failed image from within signal handler.");
2445 ToolkitTestApplication application;
2449 ImageView imageView = ImageView::New();
2450 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2451 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2452 ReloadImage(imageView);
2454 // loading started, this waits for the loader thread to complete
2455 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2456 application.SendNotification();
2458 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2460 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2461 application.SendNotification();
2463 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2465 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2466 application.SendNotification();
2467 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2472 int UtcDaliImageViewLoadRemoteSVG(void)
2474 tet_infoline("Test load from a remote server.");
2476 ToolkitTestApplication application;
2477 Toolkit::ImageView imageView;
2478 imageView = Toolkit::ImageView::New();
2479 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2480 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2481 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2482 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2483 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2484 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2485 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2487 application.GetScene().Add( imageView );
2489 DALI_TEST_CHECK( imageView );
2491 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2493 application.SendNotification();
2495 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2497 application.SendNotification();
2498 application.Render();
2500 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2505 int UtcDaliImageViewSyncSVGLoading(void)
2507 ToolkitTestApplication application;
2509 tet_infoline("ImageView Testing SVG image sync loading");
2511 // Sync loading, automatic atlasing for small size image
2513 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2515 callStack.Enable(true);
2517 ImageView imageView = ImageView::New( );
2519 // Sync loading is used
2520 Property::Map syncLoadingMap;
2521 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2522 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2523 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2524 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2526 application.GetScene().Add( imageView );
2527 DALI_TEST_CHECK( imageView );
2529 application.SendNotification();
2530 application.Render(16);
2531 Vector3 naturalSize = imageView.GetNaturalSize();
2533 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2534 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2540 int UtcDaliImageViewAsyncSVGLoading(void)
2542 ToolkitTestApplication application;
2544 tet_infoline("ImageView Testing SVG image async loading");
2546 // Sync loading, automatic atlasing for small size image
2548 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2550 callStack.Enable(true);
2552 ImageView imageView = ImageView::New( );
2554 // Sync loading is used
2555 Property::Map syncLoadingMap;
2556 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2557 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2558 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2559 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2561 application.GetScene().Add( imageView );
2562 DALI_TEST_CHECK( imageView );
2564 application.SendNotification();
2565 application.Render(16);
2566 Vector3 naturalSize = imageView.GetNaturalSize();
2568 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2569 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2574 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2576 ToolkitTestApplication application;
2578 tet_infoline("ImageView Testing SVG image async loading");
2580 // Sync loading, automatic atlasing for small size image
2582 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2584 callStack.Enable(true);
2586 ImageView imageView = ImageView::New( );
2588 // Sync loading is used
2589 Property::Map syncLoadingMap;
2590 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2591 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2593 // Check to set invalid value
2594 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2595 // Check if error log is outputted when setting other value like string.
2596 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2597 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2598 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2600 application.GetScene().Add( imageView );
2601 DALI_TEST_CHECK( imageView );
2603 application.SendNotification();
2604 application.Render(16);
2605 Vector3 naturalSize = imageView.GetNaturalSize();
2606 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2607 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2609 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2610 Property::Map* map = value.GetMap();
2611 DALI_TEST_CHECK( map );
2613 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2614 DALI_TEST_CHECK( sync );
2615 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2621 int UtcDaliImageViewSvgLoadingFailure(void)
2623 ToolkitTestApplication application;
2625 // Local svg file - invalid file path
2627 gResourceReadySignalFired = false;
2629 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/foo.svg" );
2630 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2631 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2633 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2635 application.GetScene().Add( imageView );
2637 application.SendNotification();
2638 application.Render(16);
2640 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2641 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2642 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2645 // Local svg file - invalid file
2647 gResourceReadySignalFired = false;
2649 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/invalid.svg" );
2650 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2651 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2653 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2655 application.GetScene().Add( imageView );
2657 application.SendNotification();
2658 application.Render(16);
2660 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2661 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2662 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2667 gResourceReadySignalFired = false;
2669 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2670 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2671 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2673 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2675 application.GetScene().Add( imageView );
2677 application.SendNotification();
2679 // loading started, this waits for the loader thread
2680 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2682 application.SendNotification();
2683 application.Render(16);
2685 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2686 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2687 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2693 int UtcDaliImageViewSvgRasterizationFailure(void)
2695 ToolkitTestApplication application;
2697 gResourceReadySignalFired = false;
2699 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/svg1.svg" );
2700 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2701 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2703 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2705 application.GetScene().Add( imageView );
2707 application.SendNotification();
2709 // loading started, this waits for the loader thread
2710 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2712 application.SendNotification();
2713 application.Render(16);
2715 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2716 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2717 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::READY, TEST_LOCATION );
2720 gResourceReadySignalFired = false;
2723 imageView.SetProperty( Actor::Property::SIZE, Vector2( 0.f, 0.f ) );
2725 application.SendNotification();
2727 // rasterization started, this waits for the rasterize thread
2728 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2730 application.SendNotification();
2731 application.Render(16);
2733 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2734 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2735 // Fail to rasterize because the size is 0.
2736 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2744 static int gResourceReadySignalCounter = 0;
2746 void OnResourceReadySignal( Control control )
2748 gResourceReadySignalCounter++;
2750 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
2752 if( gResourceReadySignalCounter == 1 )
2755 // It makes the first new visual be deleted immediately
2756 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2757 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2760 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
2762 // Make the resource ready immediately
2763 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
2767 void OnResourceReadySignal01( Control control )
2769 if(++gResourceReadySignalCounter == 1)
2771 // It makes the first new visual be deleted immediately
2772 // The first image will not be loaded.
2773 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
2774 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2775 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
2781 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
2783 tet_infoline("Test setting image from within signal handler.");
2785 ToolkitTestApplication application;
2787 gResourceReadySignalCounter = 0;
2789 ImageView imageView = ImageView::New( gImage_34_RGBA );
2790 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal );
2792 application.GetScene().Add( imageView );
2794 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2796 application.SendNotification();
2797 application.Render();
2799 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2801 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2804 gResourceReadySignalCounter = 0;
2806 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
2808 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2810 application.SendNotification();
2811 application.Render();
2813 // Run idle callback
2814 application.RunIdles();
2816 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2818 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2823 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
2825 tet_infoline("Test setting image from within signal handler.");
2827 ToolkitTestApplication application;
2829 gResourceReadySignalCounter = 0;
2831 ImageView imageView = ImageView::New( gImage_34_RGBA );
2832 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
2834 application.GetScene().Add( imageView );
2836 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2838 application.SendNotification();
2839 application.Render();
2841 // Wait for loading an image
2842 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2844 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2846 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );