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>
31 #include <dali-toolkit/public-api/image-loader/image.h>
32 #include <dali-toolkit/public-api/image-loader/image-url.h>
34 #include <test-native-image.h>
35 #include <test-encoded-image-buffer.h>
40 #include "dummy-control.h"
43 using namespace Toolkit;
45 void utc_dali_toolkit_image_view_startup(void)
47 test_return_value = TET_UNDEF;
50 void utc_dali_toolkit_image_view_cleanup(void)
52 test_return_value = TET_PASS;
58 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
59 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
61 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
62 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
64 // resolution: 34*34, pixel format: RGBA8888
65 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
66 // resolution: 600*600, pixel format: RGB888
67 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
69 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
70 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
72 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
74 void TestUrl( ImageView imageView, const std::string url )
76 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
78 std::string urlActual;
79 DALI_TEST_CHECK( value.Get( urlActual ) );
80 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
85 int UtcDaliImageViewNewP(void)
87 ToolkitTestApplication application;
89 ImageView imageView = ImageView::New();
91 DALI_TEST_CHECK( imageView );
96 int UtcDaliImageViewNewUrlP(void)
98 ToolkitTestApplication application;
100 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
101 DALI_TEST_CHECK( imageView );
103 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
108 int UtcDaliImageViewConstructorP(void)
110 ToolkitTestApplication application;
114 DALI_TEST_CHECK( !imageView );
119 int UtcDaliImageViewCopyConstructorP(void)
121 ToolkitTestApplication application;
123 // Initialize an object, ref count == 1
124 ImageView imageView = ImageView::New();
126 ImageView copy( imageView );
127 DALI_TEST_CHECK( copy );
132 int UtcDaliImageViewMoveConstructor(void)
134 ToolkitTestApplication application;
136 ImageView imageView = ImageView::New();
137 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
138 imageView.SetProperty( Actor::Property::SENSITIVE, false );
139 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
141 ImageView moved = std::move( imageView );
142 DALI_TEST_CHECK( moved );
143 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
144 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
145 DALI_TEST_CHECK( !imageView );
150 int UtcDaliImageViewAssignmentOperatorP(void)
152 ToolkitTestApplication application;
154 ImageView imageView = ImageView::New();
156 ImageView copy( imageView );
157 DALI_TEST_CHECK( copy );
158 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
163 int UtcDaliImageViewMoveAssignment(void)
165 ToolkitTestApplication application;
167 ImageView imageView = ImageView::New();
168 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
169 imageView.SetProperty( Actor::Property::SENSITIVE, false );
170 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
173 moved = std::move( imageView );
174 DALI_TEST_CHECK( moved );
175 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
176 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
177 DALI_TEST_CHECK( !imageView );
182 int UtcDaliImageViewDownCastP(void)
184 ToolkitTestApplication application;
186 ImageView imageView = ImageView::New();
188 BaseHandle object(imageView);
190 ImageView imageView2 = ImageView::DownCast( object );
191 DALI_TEST_CHECK(imageView2);
193 ImageView imageView3 = DownCast< ImageView >( object );
194 DALI_TEST_CHECK(imageView3);
199 int UtcDaliImageViewDownCastN(void)
201 ToolkitTestApplication application;
203 BaseHandle unInitializedObject;
205 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
206 DALI_TEST_CHECK( !imageView1 );
208 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
209 DALI_TEST_CHECK( !imageView2 );
214 int UtcDaliImageViewTypeRegistry(void)
216 ToolkitTestApplication application;
218 TypeRegistry typeRegistry = TypeRegistry::Get();
219 DALI_TEST_CHECK( typeRegistry );
221 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
222 DALI_TEST_CHECK( typeInfo );
224 BaseHandle handle = typeInfo.CreateInstance();
225 DALI_TEST_CHECK( handle );
227 ImageView imageView = ImageView::DownCast( handle );
228 DALI_TEST_CHECK( imageView );
233 int UtcDaliImageViewSetGetProperty01(void)
235 ToolkitTestApplication application;
237 ImageView imageView = ImageView::New();
239 Property::Index idx = imageView.GetPropertyIndex( "image" );
240 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
242 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
243 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
248 int UtcDaliImageViewPreMultipliedAlphaPng(void)
250 ToolkitTestApplication application;
252 // Set up trace debug
253 TestGlAbstraction& gl = application.GetGlAbstraction();
254 TraceCallStack& textureTrace = gl.GetTextureTrace();
255 textureTrace.Enable( true );
257 Property::Map imageMap;
258 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
259 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
261 ImageView imageView1 = ImageView::New();
262 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
264 application.GetScene().Add( imageView1 );
266 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
268 DALI_TEST_CHECK( value.Get( enable ) );
269 DALI_TEST_CHECK( enable ); // Default value is true
271 // loading started, this waits for the loader thread for max 30 seconds
272 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
274 application.SendNotification();
275 application.Render();
277 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
278 DALI_TEST_CHECK( value.Get( enable ) );
279 DALI_TEST_CHECK( enable ); // Keep true
281 // conventional alpha blending
282 Renderer renderer1 = imageView1.GetRendererAt( 0 );
283 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
284 DALI_TEST_CHECK( value.Get( enable ) );
285 DALI_TEST_CHECK( enable );
287 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
288 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
289 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
290 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
291 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
292 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
293 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
294 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
296 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
297 textureTrace.Reset();
299 // Disable pre-multiplied alpha blending
300 imageView1.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
303 Property::Map attributes;
304 DevelControl::DoAction( imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes );
306 // loading started, this waits for the loader thread for max 30 seconds
307 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
309 application.SendNotification();
310 application.Render();
312 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
313 DALI_TEST_CHECK( value.Get( enable ) );
314 DALI_TEST_CHECK( !enable );
316 // conventional alpha blending
317 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
318 DALI_TEST_CHECK( value.Get( enable ) );
319 DALI_TEST_CHECK( !enable );
321 srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
322 destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
323 srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
324 destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
325 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
326 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
327 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
328 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
330 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
331 textureTrace.Reset();
333 // Make a new ImageView using the same image
334 ImageView imageView2 = ImageView::New();
335 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
337 application.GetScene().Add( imageView2 );
339 application.SendNotification();
340 application.Render();
342 Renderer renderer2 = imageView2.GetRendererAt( 0 );
343 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
344 DALI_TEST_CHECK( value.Get( enable ) );
345 DALI_TEST_CHECK( enable );
347 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
348 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
349 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
350 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
351 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
352 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
353 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
354 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
356 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
361 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
363 ToolkitTestApplication application;
365 // Set up trace debug
366 TestGlAbstraction& gl = application.GetGlAbstraction();
367 TraceCallStack& textureTrace = gl.GetTextureTrace();
368 textureTrace.Enable( true );
370 Property::Map imageMap;
371 imageMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
372 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
374 ImageView imageView1 = ImageView::New();
375 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
377 application.GetScene().Add( imageView1 );
379 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
381 DALI_TEST_CHECK( value.Get( enable ) );
382 DALI_TEST_CHECK( enable ); // Default value is true
384 // loading started, this waits for the loader thread for max 30 seconds
385 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
387 application.SendNotification();
388 application.Render();
390 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
391 DALI_TEST_CHECK( value.Get( enable ) );
392 DALI_TEST_CHECK( !enable ); // Should be false after loading
394 // conventional alpha blending
395 Renderer renderer1 = imageView1.GetRendererAt( 0 );
396 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
397 DALI_TEST_CHECK( value.Get( enable ) );
398 DALI_TEST_CHECK( !enable );
400 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
401 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
402 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
403 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
404 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
405 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
406 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
407 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
409 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
410 textureTrace.Reset();
412 ImageView imageView2 = ImageView::New();
413 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
415 // Disable pre-multiplied alpha blending
416 imageView2.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
418 application.GetScene().Add( imageView2 );
420 application.SendNotification();
421 application.Render();
423 value = imageView2.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
424 DALI_TEST_CHECK( value.Get( enable ) );
425 DALI_TEST_CHECK( !enable );
427 // conventional alpha blending
428 Renderer renderer2 = imageView2.GetRendererAt( 0 );
429 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
430 DALI_TEST_CHECK( value.Get( enable ) );
431 DALI_TEST_CHECK( !enable );
433 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
434 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
435 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
436 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
437 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
438 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
439 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
440 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
442 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
447 int UtcDaliImageViewPixelArea(void)
449 // Test pixel area property
450 ToolkitTestApplication application;
452 static std::vector<UniformData> customUniforms =
454 UniformData("pixelArea", Property::Type::VECTOR4),
457 TestGraphicsController& graphics = application.GetGraphicsController();
458 graphics.AddCustomUniforms(customUniforms);
460 // Gif image, use AnimatedImageVisual internally
461 // Atlasing is applied to pack multiple frames, use custom wrap mode
462 ImageView gifView = ImageView::New();
463 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
464 gifView.SetProperty( ImageView::Property::IMAGE,
465 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
466 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
469 Integration::Scene stage = application.GetScene();
470 stage.Add( gifView );
473 application.SendNotification();
474 application.Render(16);
476 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
478 application.SendNotification();
479 application.Render();
480 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
482 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
483 // test that the pixel area value defined in the visual property map is registered on renderer
484 Renderer renderer = gifView.GetRendererAt(0);
485 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
486 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
488 // test that the shader has the default pixel area value registered.
489 Shader shader = renderer.GetShader();
490 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
491 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
493 // test that the uniform uses the pixelArea property on the renderer.
494 TestGlAbstraction& gl = application.GetGlAbstraction();
495 Vector4 pixelAreaUniform;
496 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
497 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
499 // set the pixelArea property on the control
500 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
501 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
502 application.SendNotification();
503 application.Render(16);
505 // check the pixelArea property on the control
506 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
507 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
508 // test that the uniform uses the pixelArea property on the control.
509 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
510 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
516 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
518 ToolkitTestApplication application;
519 TestGlAbstraction& gl = application.GetGlAbstraction();
520 const std::vector<GLuint>& textures = gl.GetBoundTextures();
521 size_t numTextures = textures.size();
523 // Async loading, no atlasing for big size image
524 ImageView imageView = ImageView::New( gImage_600_RGB );
526 // By default, Aysnc loading is used
527 application.GetScene().Add( imageView );
528 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
529 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
531 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
533 application.SendNotification();
534 application.Render(16);
535 application.SendNotification();
537 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
538 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
543 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
545 ToolkitTestApplication application;
547 //Async loading, automatic atlasing for small size image
548 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
550 callStack.Enable(true);
552 Property::Map imageMap;
554 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
555 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
556 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
557 imageMap[ ImageVisual::Property::ATLASING] = true;
559 ImageView imageView = ImageView::New();
560 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
561 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
563 // By default, Aysnc loading is used
564 // loading is not started if the actor is offScene
566 application.GetScene().Add( imageView );
567 application.SendNotification();
568 application.Render(16);
569 application.Render(16);
570 application.SendNotification();
572 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
573 application.SendNotification();
574 application.Render(16);
575 application.Render(16);
576 application.SendNotification();
578 // loading started, this waits for the loader thread for max 30 seconds
579 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
581 application.SendNotification();
582 application.Render(16);
584 callStack.Enable(false);
586 TraceCallStack::NamedParams params;
587 params["width"] << 34;
588 params["height"] << 34;
589 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
594 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
596 ToolkitTestApplication application;
598 //Async loading, automatic atlasing for small size image
599 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
601 callStack.Enable(true);
603 Property::Map asyncLoadingMap;
604 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
605 asyncLoadingMap[ "desiredHeight" ] = 34;
606 asyncLoadingMap[ "desiredWidth" ] = 34;
607 asyncLoadingMap[ "synchronousLoading" ] = false;
608 asyncLoadingMap[ "atlasing" ] = true;
610 ImageView imageView = ImageView::New();
611 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
613 application.GetScene().Add( imageView );
614 application.SendNotification();
615 application.Render(16);
616 application.Render(16);
617 application.SendNotification();
619 // loading started, this waits for the loader thread for max 30 seconds
620 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
622 application.SendNotification();
623 application.Render(16);
625 callStack.Enable(false);
627 TraceCallStack::NamedParams params;
628 params["width"] << 34;
629 params["height"] << 34;
630 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
635 int UtcDaliImageViewSyncLoading(void)
637 ToolkitTestApplication application;
639 tet_infoline("ImageView Testing sync loading and size using index key property map");
641 Property::Map syncLoadingMap;
642 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
643 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
645 // Sync loading, no atlasing for big size image
647 ImageView imageView = ImageView::New();
649 // Sync loading is used
650 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
651 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
654 // Sync loading, automatic atlasing for small size image
656 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
658 callStack.Enable(true);
660 ImageView imageView = ImageView::New( );
662 // Sync loading is used
663 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
664 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
665 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
666 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
668 application.GetScene().Add( imageView );
669 application.SendNotification();
670 application.Render(16);
672 TraceCallStack::NamedParams params;
673 params["width"] << 34;
674 params["height"] << 34;
675 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
676 true, TEST_LOCATION );
681 int UtcDaliImageViewSyncLoading02(void)
683 ToolkitTestApplication application;
685 tet_infoline("ImageView Testing sync loading and size using string key property map");
687 // Sync loading, automatic atlasing for small size image
689 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
691 callStack.Enable(true);
693 ImageView imageView = ImageView::New( );
695 // Sync loading is used
696 Property::Map syncLoadingMap;
697 syncLoadingMap[ "url" ] = gImage_34_RGBA;
698 syncLoadingMap[ "desiredHeight" ] = 34;
699 syncLoadingMap[ "desiredWidth" ] = 34;
700 syncLoadingMap[ "synchronousLoading" ] = true;
701 syncLoadingMap[ "atlasing" ] = true;
702 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
704 application.GetScene().Add( imageView );
705 application.SendNotification();
706 application.Render(16);
708 TraceCallStack::NamedParams params;
709 params["width"] << 34;
710 params["height"] << 34;
711 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
712 true, TEST_LOCATION );
717 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
719 ToolkitTestApplication application;
720 TestGlAbstraction& gl = application.GetGlAbstraction();
721 const std::vector<GLuint>& textures = gl.GetBoundTextures();
722 size_t numTextures = textures.size();
724 // Get encoded raw-buffer image and generate url
725 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
726 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
728 // Async loading, no atlasing for big size image
729 ImageView imageView = ImageView::New(url.GetUrl());
731 // By default, Aysnc loading is used
732 application.GetScene().Add(imageView);
733 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
734 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
736 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
738 application.SendNotification();
739 application.Render(16);
740 application.SendNotification();
742 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
743 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
748 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
750 ToolkitTestApplication application;
752 // Get encoded raw-buffer image and generate url
753 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
754 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
755 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
757 // Generate url is not equal to url2
758 // NOTE : This behavior may changed when ImageUrl compare operator changed.
759 DALI_TEST_CHECK(url != url2);
760 // Generate url's string is equal to url2's string
761 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
763 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
764 url2 = Toolkit::Image::GenerateUrl(buffer2);
766 // Check whethere two url are not equal
767 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
769 // Async loading, automatic atlasing for small size image
770 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
772 callStack.Enable(true);
774 Property::Map imageMap;
776 imageMap[ ImageVisual::Property::URL ] = url.GetUrl();
777 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
778 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
779 imageMap[ ImageVisual::Property::ATLASING] = true;
781 ImageView imageView = ImageView::New();
782 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
783 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
785 // By default, Aysnc loading is used
786 // loading is not started if the actor is offScene
788 application.GetScene().Add( imageView );
789 application.SendNotification();
790 application.Render(16);
791 application.Render(16);
792 application.SendNotification();
794 // Change url to url2
795 imageMap[ ImageVisual::Property::URL ] = url2.GetUrl();
796 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
798 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
799 application.SendNotification();
800 application.Render(16);
801 application.Render(16);
802 application.SendNotification();
804 // loading started, this waits for the loader thread for max 30 seconds
805 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
807 application.SendNotification();
808 application.Render(16);
810 callStack.Enable(false);
812 TraceCallStack::NamedParams params;
813 params["width"] << 34;
814 params["height"] << 34;
815 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
820 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
822 ToolkitTestApplication application;
824 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
826 // Get encoded raw-buffer image and generate url
827 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
828 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
830 // Sync loading, automatic atlasing for small size image
832 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
834 callStack.Enable(true);
836 ImageView imageView = ImageView::New( );
838 // Sync loading is used
839 Property::Map syncLoadingMap;
840 syncLoadingMap[ "url" ] = url.GetUrl();
841 syncLoadingMap[ "desiredHeight" ] = 34;
842 syncLoadingMap[ "desiredWidth" ] = 34;
843 syncLoadingMap[ "synchronousLoading" ] = true;
844 syncLoadingMap[ "atlasing" ] = true;
845 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
847 application.GetScene().Add( imageView );
848 application.SendNotification();
849 application.Render(16);
851 TraceCallStack::NamedParams params;
852 params["width"] << 34;
853 params["height"] << 34;
854 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
855 true, TEST_LOCATION );
861 int UtcDaliImageViewAddedTexture(void)
863 ToolkitTestApplication application;
865 tet_infoline("ImageView Testing image view with texture provided manager url");
867 ImageView imageView = ImageView::New();
869 // empty texture is ok, though pointless from app point of view
871 std::string url = TextureManager::AddTexture(empty);
872 DALI_TEST_CHECK(url.size() > 0u);
874 Property::Map propertyMap;
875 propertyMap[ImageVisual::Property::URL] = url;
876 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
878 application.GetScene().Add( imageView );
879 application.SendNotification();
880 application.Render();
885 int UtcDaliImageViewSizeWithBackground(void)
887 ToolkitTestApplication application;
891 ImageView imageView = ImageView::New();
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, width },
898 { ImageVisual::Property::DESIRED_HEIGHT, height },
902 application.GetScene().Add( imageView );
903 application.SendNotification();
904 application.Render();
906 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
907 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
912 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
914 ToolkitTestApplication application;
916 int widthBackground = 100;
917 int heightBackground = 200;
921 ImageView imageView = ImageView::New();
923 imageView.SetProperty( Control::Property::BACKGROUND,
925 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
926 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
927 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
928 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
932 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
934 application.GetScene().Add( imageView );
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
939 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
944 int UtcDaliImageViewHeightForWidthBackground(void)
946 ToolkitTestApplication application;
948 int widthBackground = 100;
949 int heightBackground = 200;
951 ImageView imageView = ImageView::New();
953 imageView.SetProperty( Control::Property::BACKGROUND,
955 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
956 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
957 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
958 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
962 application.GetScene().Add( imageView );
963 application.SendNotification();
964 application.Render();
966 Control control = Control::DownCast( imageView );
967 DALI_TEST_CHECK( control );
968 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
969 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
974 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
976 ToolkitTestApplication application;
978 int widthBackground = 100;
979 int heightBackground = 200;
983 ImageView imageView = ImageView::New();
985 imageView.SetProperty( Control::Property::BACKGROUND,
987 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
988 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
989 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
990 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
994 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
996 application.GetScene().Add( imageView );
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
1001 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
1006 int UtcDaliImageViewSetImageUrl(void)
1008 ToolkitTestApplication application;
1010 ImageView imageView = ImageView::New();
1011 imageView.SetImage( TEST_IMAGE_FILE_NAME );
1012 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
1015 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
1016 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
1021 bool gResourceReadySignalFired = false;
1022 Vector3 gNaturalSize;
1024 void ResourceReadySignal( Control control )
1026 gResourceReadySignalFired = true;
1029 int UtcDaliImageViewCheckResourceReady(void)
1031 ToolkitTestApplication application;
1033 gResourceReadySignalFired = false;
1035 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1036 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
1038 imageView.SetProperty( Control::Property::BACKGROUND,
1040 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
1041 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
1042 { ImageVisual::Property::DESIRED_WIDTH, 100 },
1043 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
1047 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1049 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1051 application.GetScene().Add( imageView );
1053 // loading started, this waits for the loader thread
1054 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1056 application.SendNotification();
1057 application.Render(16);
1059 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1061 application.SendNotification();
1062 application.Render();
1064 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1066 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1071 int UtcDaliImageViewSetImageTypeChangesP(void)
1073 ToolkitTestApplication application;
1075 ImageView imageView = ImageView::New();
1076 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1078 application.GetScene().Add( imageView );
1082 Toolkit::Visual::Base visual;
1084 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1085 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1087 application.SendNotification();
1088 application.Render( 16 );
1090 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1092 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1093 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1096 imageView.SetImage( "TEST_URL" );
1098 application.SendNotification();
1099 application.Render( 16 );
1101 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1102 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1104 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
1105 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
1106 DALI_TEST_CHECK( visual ); // Visual should be valid
1109 imageView.SetImage( "" );
1111 application.SendNotification();
1112 application.Render( 16 );
1114 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1115 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1117 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1119 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1120 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1122 // Set a URL in property map
1123 Property::Map propertyMap;
1124 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1125 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1127 application.SendNotification();
1128 application.Render( 16 );
1130 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1131 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1133 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1134 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1135 DALI_TEST_CHECK( visual ); // Visual should be valid
1137 // Set a URL in property map again
1138 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1139 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1141 application.SendNotification();
1142 application.Render( 16 );
1144 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1145 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1147 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1148 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1149 DALI_TEST_CHECK( visual ); // Visual should be valid
1151 // Set an empty URL in property map
1152 propertyMap[ImageVisual::Property::URL] = std::string();
1153 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1155 application.SendNotification();
1156 application.Render( 16 );
1158 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1159 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1161 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1162 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1163 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1168 int UtcDaliImageViewResourceUrlP(void)
1170 ToolkitTestApplication application;
1172 ImageView imageView = ImageView::New();
1173 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
1175 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
1176 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
1181 int UtcDaliImageViewReplaceImage(void)
1183 ToolkitTestApplication application;
1185 gResourceReadySignalFired = false;
1187 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1188 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1190 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1192 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1194 application.GetScene().Add( imageView );
1196 application.SendNotification();
1197 application.Render(16);
1199 // loading started, this waits for the loader thread for max 30 seconds
1200 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1202 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1204 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1206 gResourceReadySignalFired = false;
1208 imageView.SetImage(TEST_IMAGE_2);
1210 application.SendNotification();
1211 application.Render(16);
1213 // loading started, this waits for the loader thread for max 30 seconds
1214 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1216 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1218 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1220 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1225 void OnRelayoutOverride( Size size )
1227 gNaturalSize = size; // Size Relayout is using
1230 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1232 ToolkitTestApplication application;
1234 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1235 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1236 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1238 DummyControl dummyControl = DummyControl::New( true );
1239 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1240 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1242 dummyControl.Add( imageView );
1243 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1244 application.GetScene().Add( dummyControl );
1246 application.SendNotification();
1247 application.Render();
1249 // loading started, this waits for the loader thread for max 30 seconds
1250 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1252 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1253 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1255 gNaturalSize = Vector3::ZERO;
1257 imageView.SetImage(gImage_600_RGB);
1259 // Waiting for resourceReady so SendNotifcation not called here.
1261 // loading started, this waits for the loader thread for max 30 seconds
1262 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1264 // Trigger a potential relayout
1265 application.SendNotification();
1266 application.Render();
1268 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1269 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1274 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1276 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1278 ToolkitTestApplication application;
1280 gResourceReadySignalFired = false;
1282 Property::Map imageMap;
1284 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1285 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1287 tet_infoline("Creating ImageView without URL so image does not start loading");
1288 ImageView imageView = ImageView::New();
1289 tet_infoline("Connect to image loaded signal before setting image");
1290 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1291 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1292 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1294 // loading started, this waits for the loader thread
1295 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1297 application.SendNotification();
1298 application.Render(16);
1300 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1305 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1307 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1309 ToolkitTestApplication application;
1311 gResourceReadySignalFired = false;
1313 Property::Map imageMap;
1315 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1316 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1318 ImageView imageView = ImageView::New();
1319 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1320 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1322 // loading started, this waits for the loader thread
1323 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1325 application.SendNotification();
1326 application.Render(16);
1328 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1329 gResourceReadySignalFired = false;
1331 ImageView imageViewWithExistingImage = ImageView::New();
1332 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1333 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1335 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1340 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1342 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1344 ToolkitTestApplication application;
1346 gResourceReadySignalFired = false;
1348 Property::Map imageImmediateLoadingMap;
1349 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1350 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1352 tet_infoline("Immediate load an image");
1353 ImageView imageView = ImageView::New();
1354 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1355 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1357 // loading started, this waits for the loader thread
1358 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1360 application.SendNotification();
1361 application.Render(16);
1363 tet_infoline("Check image loaded");
1364 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1365 gResourceReadySignalFired = false;
1367 tet_infoline("Create another ImageView with the same URL");
1368 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1369 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1370 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1372 application.GetScene().Add( imageViewWithExistingImage );
1374 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1379 int UtcDaliImageViewPaddingProperty(void)
1381 ToolkitTestApplication application;
1383 ImageView imageView = ImageView::New();
1384 Property::Map imagePropertyMap;
1385 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1386 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1387 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1388 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1389 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1390 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1391 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1392 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1393 application.GetScene().Add( imageView );
1395 application.SendNotification();
1396 application.Render();
1398 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1400 ImageView childImage = ImageView::New();
1401 childImage.SetBackgroundColor( Color::BLACK );
1402 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1403 imageView.Add( childImage );
1405 application.SendNotification();
1406 application.Render();
1408 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1409 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1411 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1412 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1413 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1414 Property::Map resultMap;
1415 imageVisual.CreatePropertyMap( resultMap );
1417 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1418 DALI_TEST_CHECK( transformValue );
1419 Property::Map* retMap = transformValue->GetMap();
1420 DALI_TEST_CHECK( retMap );
1422 // Image Visual should be positioned depending on ImageView's padding
1423 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1428 int UtcDaliImageViewPaddingProperty02(void)
1430 ToolkitTestApplication application;
1432 ImageView imageView = ImageView::New();
1433 Property::Map imagePropertyMap;
1434 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1435 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1436 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1437 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1438 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1439 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1440 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1441 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1442 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1443 application.GetScene().Add( imageView );
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1450 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1451 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1452 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1453 Property::Map resultMap;
1454 imageVisual.CreatePropertyMap( resultMap );
1456 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1457 DALI_TEST_CHECK( transformValue );
1458 Property::Map* retMap = transformValue->GetMap();
1459 DALI_TEST_CHECK( retMap );
1461 // Image Visual should be positioned depending on ImageView's padding
1462 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1467 int UtcDaliImageViewPaddingProperty03(void)
1469 tet_infoline("Test Setting Image Padding then removing it.");
1471 ToolkitTestApplication application;
1473 ImageView imageView = ImageView::New();
1474 Property::Map imagePropertyMap;
1475 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1476 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1477 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1478 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1479 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1480 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1481 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1482 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1483 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1484 application.GetScene().Add( imageView );
1486 application.SendNotification();
1487 application.Render();
1489 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1491 tet_infoline("Remove Padding and test Visual is position correctly");
1493 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1495 application.SendNotification();
1496 application.Render();
1498 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1499 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1500 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1501 Property::Map resultMap;
1502 imageVisual.CreatePropertyMap( resultMap );
1504 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1505 DALI_TEST_CHECK( transformValue );
1506 Property::Map* retMap = transformValue->GetMap();
1507 DALI_TEST_CHECK( retMap );
1509 // Image Visual should be positioned depending on ImageView's padding
1510 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1515 int UtcDaliImageViewPaddingProperty04(void)
1517 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1519 ToolkitTestApplication application;
1521 ImageView imageView = ImageView::New();
1522 Property::Map imagePropertyMap;
1523 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1524 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1525 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1526 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1527 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1528 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1529 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1530 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1531 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1532 application.GetScene().Add( imageView );
1534 application.SendNotification();
1535 application.Render();
1537 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1539 tet_infoline("Remove Padding and test Visual is position correctly");
1541 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1543 application.SendNotification();
1544 application.Render();
1546 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1547 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1548 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1549 Property::Map resultMap;
1550 imageVisual.CreatePropertyMap( resultMap );
1552 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1553 DALI_TEST_CHECK( transformValue );
1554 Property::Map* retMap = transformValue->GetMap();
1555 DALI_TEST_CHECK( retMap );
1557 // Image Visual should be positioned depending on ImageView's padding
1558 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1563 int UtcDaliImageViewTransformTest01(void)
1565 tet_infoline("Test Setting a offset transform on the ImageView");
1567 ToolkitTestApplication application;
1569 ImageView imageView = ImageView::New();
1570 Property::Map imagePropertyMap;
1571 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1572 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1573 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1574 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1575 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1576 .Add( Visual::Property::TRANSFORM,
1577 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1578 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1579 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1581 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1582 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1583 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1584 application.GetScene().Add( imageView );
1586 application.SendNotification();
1587 application.Render();
1589 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1590 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1591 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1592 Property::Map resultMap;
1593 imageVisual.CreatePropertyMap( resultMap );
1595 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1596 DALI_TEST_CHECK( transformValue );
1597 Property::Map* retMap = transformValue->GetMap();
1598 DALI_TEST_CHECK( retMap );
1600 // Image Visual should be positioned depending on ImageView's padding
1601 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1602 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 );
1607 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1609 ToolkitTestApplication application;
1611 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1612 ImageView imageView = ImageView::New();
1613 Property::Map imageMap;
1614 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1615 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1616 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1617 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1618 application.GetScene().Add( imageView );
1620 // Trigger a potential relayout
1621 application.SendNotification();
1622 application.Render();
1624 Vector3 naturalSize = imageView.GetNaturalSize();
1626 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1627 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1632 int UtcDaliImageViewFillMode(void)
1634 ToolkitTestApplication application;
1636 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1638 ImageView imageView = ImageView::New();
1639 Property::Map imageMap;
1640 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1641 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1642 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1644 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1646 application.GetScene().Add( imageView );
1648 // Trigger a potential relayout
1649 application.SendNotification();
1650 application.Render();
1652 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1653 Property::Map returnedMap;
1654 visual.CreatePropertyMap( returnedMap );
1656 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1657 DALI_TEST_CHECK( value );
1658 Property::Map* map = value->GetMap();
1659 DALI_TEST_CHECK( map );
1661 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1662 DALI_TEST_CHECK( value );
1663 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1665 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1666 DALI_TEST_CHECK( value );
1667 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1672 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1674 ToolkitTestApplication application;
1676 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1677 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1679 ImageView imageView = ImageView::New();
1680 Property::Map imageMap;
1681 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1682 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1683 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1685 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1686 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1688 application.GetScene().Add( imageView );
1690 // Trigger a potential relayout
1691 application.SendNotification();
1692 application.Render();
1694 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1695 Property::Map returnedMap;
1696 visual.CreatePropertyMap( returnedMap );
1698 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1699 DALI_TEST_CHECK( value );
1700 Property::Map* map = value->GetMap();
1701 DALI_TEST_CHECK( map );
1704 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1705 DALI_TEST_CHECK( value );
1706 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1708 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1709 DALI_TEST_CHECK( value );
1710 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1712 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1713 DALI_TEST_CHECK( value );
1714 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1719 int UtcDaliImageViewFittingModesFill(void)
1721 ToolkitTestApplication application;
1723 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1724 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1726 ImageView imageView = ImageView::New();
1727 Property::Map imageMap;
1728 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1729 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1730 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1732 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1733 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1735 application.GetScene().Add( imageView );
1737 // Trigger a potential relayout
1738 application.SendNotification();
1739 application.Render();
1741 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1742 Property::Map returnedMap;
1743 visual.CreatePropertyMap( returnedMap );
1745 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1746 DALI_TEST_CHECK( value );
1747 Property::Map* map = value->GetMap();
1748 DALI_TEST_CHECK( map );
1750 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1751 DALI_TEST_CHECK( value );
1752 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1754 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1755 DALI_TEST_CHECK( value );
1756 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1758 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1759 DALI_TEST_CHECK( value );
1760 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1765 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1767 ToolkitTestApplication application;
1769 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1770 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1772 ImageView imageView = ImageView::New();
1773 Property::Map imageMap;
1774 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1775 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1776 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1778 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1779 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1781 application.GetScene().Add( imageView );
1783 // Trigger a potential relayout
1784 application.SendNotification();
1785 application.Render();
1787 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1788 Property::Map returnedMap;
1789 visual.CreatePropertyMap( returnedMap );
1791 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1792 DALI_TEST_CHECK( value );
1793 Property::Map* map = value->GetMap();
1794 DALI_TEST_CHECK( map );
1797 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1798 DALI_TEST_CHECK( value );
1799 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1801 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1802 DALI_TEST_CHECK( value );
1803 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1805 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1806 DALI_TEST_CHECK( value );
1807 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1812 int UtcDaliImageViewFittingModesCenter01(void)
1814 ToolkitTestApplication application;
1816 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1817 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1819 ImageView imageView = ImageView::New();
1820 Property::Map imageMap;
1821 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1822 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1823 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1825 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1826 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1828 application.GetScene().Add( imageView );
1830 // Trigger a potential relayout
1831 application.SendNotification();
1832 application.Render();
1834 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1835 Property::Map returnedMap;
1836 visual.CreatePropertyMap( returnedMap );
1838 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1839 DALI_TEST_CHECK( value );
1840 Property::Map* map = value->GetMap();
1841 DALI_TEST_CHECK( map );
1843 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1844 DALI_TEST_CHECK( value );
1845 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1847 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1848 DALI_TEST_CHECK( value );
1849 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1851 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1852 DALI_TEST_CHECK( value );
1853 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1858 int UtcDaliImageViewFittingModesCenter02(void)
1860 ToolkitTestApplication application;
1862 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1863 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1865 ImageView imageView = ImageView::New();
1866 Property::Map imageMap;
1867 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1868 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1869 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1871 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1872 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1874 application.GetScene().Add( imageView );
1876 // Trigger a potential relayout
1877 application.SendNotification();
1878 application.Render();
1880 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1881 Property::Map returnedMap;
1882 visual.CreatePropertyMap( returnedMap );
1884 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1885 DALI_TEST_CHECK( value );
1886 Property::Map* map = value->GetMap();
1887 DALI_TEST_CHECK( map );
1889 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1890 DALI_TEST_CHECK( value );
1891 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1893 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1894 DALI_TEST_CHECK( value );
1895 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1897 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1898 DALI_TEST_CHECK( value );
1899 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1904 int UtcDaliImageViewFittingModesFitHeight01(void)
1906 ToolkitTestApplication application;
1908 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1910 ImageView imageView = ImageView::New();
1911 Property::Map imageMap;
1912 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1913 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1914 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1916 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1917 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1919 application.GetScene().Add( imageView );
1921 // Trigger a potential relayout
1922 application.SendNotification();
1923 application.Render();
1925 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1926 Property::Map returnedMap;
1927 visual.CreatePropertyMap( returnedMap );
1929 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1930 DALI_TEST_CHECK( value );
1931 Property::Map* map = value->GetMap();
1932 DALI_TEST_CHECK( map );
1934 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1935 DALI_TEST_CHECK( value );
1936 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1938 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1939 DALI_TEST_CHECK( value );
1940 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1942 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1943 DALI_TEST_CHECK( value );
1944 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1949 int UtcDaliImageViewFittingModesFitHeight02(void)
1951 ToolkitTestApplication application;
1953 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1955 ImageView imageView = ImageView::New();
1956 Property::Map imageMap;
1957 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1958 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1959 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1961 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1962 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1964 application.GetScene().Add( imageView );
1966 // Trigger a potential relayout
1967 application.SendNotification();
1968 application.Render();
1970 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1971 Property::Map returnedMap;
1972 visual.CreatePropertyMap( returnedMap );
1974 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1975 DALI_TEST_CHECK( value );
1976 Property::Map* map = value->GetMap();
1977 DALI_TEST_CHECK( map );
1979 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1980 DALI_TEST_CHECK( value );
1981 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1983 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1984 DALI_TEST_CHECK( value );
1985 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1987 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1988 DALI_TEST_CHECK( value );
1989 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1994 int UtcDaliImageViewFittingModesFitWidth01(void)
1996 ToolkitTestApplication application;
1998 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
2000 ImageView imageView = ImageView::New();
2001 Property::Map imageMap;
2002 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2003 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
2004 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2006 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2007 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
2009 application.GetScene().Add( imageView );
2011 // Trigger a potential relayout
2012 application.SendNotification();
2013 application.Render();
2015 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2016 Property::Map returnedMap;
2017 visual.CreatePropertyMap( returnedMap );
2019 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2020 DALI_TEST_CHECK( value );
2021 Property::Map* map = value->GetMap();
2022 DALI_TEST_CHECK( map );
2024 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2025 DALI_TEST_CHECK( value );
2026 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2028 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2029 DALI_TEST_CHECK( value );
2030 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2032 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2033 DALI_TEST_CHECK( value );
2034 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
2039 int UtcDaliImageViewFittingModesFitWidth02(void)
2041 ToolkitTestApplication application;
2043 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
2045 ImageView imageView = ImageView::New();
2046 Property::Map imageMap;
2047 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2048 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
2049 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2051 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2052 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
2054 application.GetScene().Add( imageView );
2056 // Trigger a potential relayout
2057 application.SendNotification();
2058 application.Render();
2060 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2061 Property::Map returnedMap;
2062 visual.CreatePropertyMap( returnedMap );
2064 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2065 DALI_TEST_CHECK( value );
2066 Property::Map* map = value->GetMap();
2067 DALI_TEST_CHECK( map );
2069 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2070 DALI_TEST_CHECK( value );
2071 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2073 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2074 DALI_TEST_CHECK( value );
2075 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2077 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2078 DALI_TEST_CHECK( value );
2079 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2084 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2086 ToolkitTestApplication application;
2088 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2090 ImageView imageView = ImageView::New();
2092 // 1. Render using FittingMode::SHRINK_TO_FIT
2093 Property::Map imageMap;
2094 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2095 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2096 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2098 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2099 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2101 application.GetScene().Add( imageView );
2103 // Trigger a potential relayout
2104 application.SendNotification();
2105 application.Render();
2107 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2108 Property::Map returnedMap;
2109 visual.CreatePropertyMap( returnedMap );
2111 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2112 DALI_TEST_CHECK( value );
2113 Property::Map* map = value->GetMap();
2114 DALI_TEST_CHECK( map );
2116 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2117 DALI_TEST_CHECK( value );
2118 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2120 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2121 DALI_TEST_CHECK( value );
2122 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2124 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2125 DALI_TEST_CHECK( value );
2126 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2128 // 2. Render again using DevelVisaul::CENTER
2129 Property::Map imageMap2;
2130 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2131 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2132 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2134 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2135 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2137 application.GetScene().Add( imageView );
2139 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2141 // Trigger a potential relayout
2142 application.SendNotification();
2143 application.Render();
2145 returnedMap.Clear();
2146 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2148 visual.CreatePropertyMap( returnedMap );
2150 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2151 DALI_TEST_CHECK( value );
2152 map = value->GetMap();
2153 DALI_TEST_CHECK( map );
2155 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2156 DALI_TEST_CHECK( value );
2157 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2159 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2160 DALI_TEST_CHECK( value );
2161 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2163 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2164 DALI_TEST_CHECK( value );
2165 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2167 // 3. Render again using before fittingMode
2168 Property::Map imageMap3;
2169 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2170 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2171 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2173 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2174 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2176 application.GetScene().Add( imageView );
2178 // Trigger a potential relayout
2179 application.SendNotification();
2180 application.Render();
2182 returnedMap.Clear();
2183 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2184 visual.CreatePropertyMap( returnedMap );
2186 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2187 DALI_TEST_CHECK( value );
2188 map = value->GetMap();
2189 DALI_TEST_CHECK( map );
2191 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2192 DALI_TEST_CHECK( value );
2193 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2195 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2196 DALI_TEST_CHECK( value );
2197 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2199 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2200 DALI_TEST_CHECK( value );
2201 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2206 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2208 ToolkitTestApplication application;
2210 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2212 ImageView imageView = ImageView::New();
2214 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2215 Property::Map imageMap;
2216 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2217 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2218 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2220 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2221 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2223 application.GetScene().Add( imageView );
2225 // Trigger a potential relayout
2226 application.SendNotification();
2227 application.Render();
2229 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2230 Property::Map returnedMap;
2231 visual.CreatePropertyMap( returnedMap );
2233 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2234 DALI_TEST_CHECK( value );
2235 Property::Map* map = value->GetMap();
2236 DALI_TEST_CHECK( map );
2238 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2239 DALI_TEST_CHECK( value );
2240 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2242 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2243 DALI_TEST_CHECK( value );
2244 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2246 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2247 DALI_TEST_CHECK( value );
2248 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2250 // 2. Render again using DevelVisaul::CENTER
2251 Property::Map imageMap2;
2252 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2253 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2254 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2256 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2257 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2259 application.GetScene().Add( imageView );
2261 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2263 // Trigger a potential relayout
2264 application.SendNotification();
2265 application.Render();
2267 returnedMap.Clear();
2268 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2270 visual.CreatePropertyMap( returnedMap );
2272 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2273 DALI_TEST_CHECK( value );
2274 map = value->GetMap();
2275 DALI_TEST_CHECK( map );
2277 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2278 DALI_TEST_CHECK( value );
2279 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2281 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2282 DALI_TEST_CHECK( value );
2283 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2285 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2286 DALI_TEST_CHECK( value );
2287 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2289 // 3. Render again using before fittingMode
2290 Property::Map imageMap3;
2291 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2292 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2293 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2295 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2296 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2298 application.GetScene().Add( imageView );
2300 // Trigger a potential relayout
2301 application.SendNotification();
2302 application.Render();
2304 returnedMap.Clear();
2305 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2306 visual.CreatePropertyMap( returnedMap );
2308 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2309 DALI_TEST_CHECK( value );
2310 map = value->GetMap();
2311 DALI_TEST_CHECK( map );
2313 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2314 DALI_TEST_CHECK( value );
2315 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2317 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2318 DALI_TEST_CHECK( value );
2319 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2321 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2322 DALI_TEST_CHECK( value );
2323 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2328 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2330 ToolkitTestApplication application;
2332 tet_infoline( "Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )" );
2334 ImageView imageView = ImageView::New();
2335 Property::Map imageMap;
2336 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2337 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2339 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2340 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2342 application.GetScene().Add( imageView );
2344 // Trigger a potential relayout
2345 application.SendNotification();
2346 application.Render();
2348 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2349 Property::Map returnedMap;
2350 visual.CreatePropertyMap( returnedMap );
2352 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2353 DALI_TEST_CHECK( value );
2354 Property::Map* map = value->GetMap();
2355 DALI_TEST_CHECK( map );
2357 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2358 DALI_TEST_CHECK( value );
2359 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2361 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2362 DALI_TEST_CHECK( value );
2363 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2365 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2366 DALI_TEST_CHECK( value );
2367 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2373 int UtcDaliImageViewCustomShader(void)
2375 ToolkitTestApplication application;
2377 // Set a custom shader with an image url
2379 Property::Map properties;
2380 Property::Map shader;
2381 const std::string vertexShader = "Foobar";
2382 const std::string fragmentShader = "Foobar";
2383 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2384 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2386 properties[Visual::Property::TYPE] = Visual::IMAGE;
2387 properties[Visual::Property::SHADER] = shader;
2388 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2390 ImageView imageView = ImageView::New();
2391 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2393 application.GetScene().Add( imageView );
2395 application.SendNotification();
2396 application.Render();
2398 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2400 Renderer renderer = imageView.GetRendererAt( 0 );
2401 Shader shader2 = renderer.GetShader();
2402 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2403 Property::Map* map = value.GetMap();
2404 DALI_TEST_CHECK( map );
2406 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2407 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2409 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2410 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2413 // Set a custom shader after setting an image url
2415 Property::Map properties;
2416 Property::Map shader;
2417 const std::string vertexShader = "Foobar";
2418 const std::string fragmentShader = "Foobar";
2419 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2420 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2422 properties[Visual::Property::SHADER] = shader;
2424 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2425 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2427 application.GetScene().Add( imageView );
2429 application.SendNotification();
2430 application.Render();
2432 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2434 Renderer renderer = imageView.GetRendererAt( 0 );
2435 Shader shader2 = renderer.GetShader();
2436 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2437 Property::Map* map = value.GetMap();
2438 DALI_TEST_CHECK( map );
2440 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2441 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2443 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2444 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2447 // Set a custom shader before setting an image url
2449 Property::Map properties;
2450 Property::Map shader;
2451 const std::string vertexShader = "Foobar";
2452 const std::string fragmentShader = "Foobar";
2453 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2454 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2456 properties[Visual::Property::SHADER] = shader;
2458 ImageView imageView = ImageView::New();
2459 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2460 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2462 application.GetScene().Add( imageView );
2464 application.SendNotification();
2465 application.Render();
2466 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2468 Renderer renderer = imageView.GetRendererAt( 0 );
2469 Shader shader2 = renderer.GetShader();
2470 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2471 Property::Map* map = value.GetMap();
2472 DALI_TEST_CHECK( map );
2474 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2475 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2477 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2478 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2481 // Set a custom shader after setting a property map
2483 Property::Map properties;
2484 Property::Map shader;
2485 const std::string vertexShader = "Foobar";
2486 const std::string fragmentShader = "Foobar";
2487 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2488 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2490 properties[Visual::Property::SHADER] = shader;
2492 Property::Map properties1;
2493 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2494 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2496 ImageView imageView = ImageView::New();
2497 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2498 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2500 application.GetScene().Add( imageView );
2502 application.SendNotification();
2503 application.Render();
2504 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2506 Renderer renderer = imageView.GetRendererAt( 0 );
2507 Shader shader2 = renderer.GetShader();
2508 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2509 Property::Map* map = value.GetMap();
2510 DALI_TEST_CHECK( map );
2512 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2513 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2515 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2516 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2519 // Set a custom shader before setting a property map
2521 Property::Map properties;
2522 Property::Map shader;
2523 const std::string vertexShader = "Foobar";
2524 const std::string fragmentShader = "Foobar";
2525 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2526 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2528 properties[Visual::Property::SHADER] = shader;
2530 Property::Map properties1;
2531 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2532 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2534 ImageView imageView = ImageView::New();
2535 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2536 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2538 application.GetScene().Add( imageView );
2540 application.SendNotification();
2541 application.Render();
2542 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2544 Renderer renderer = imageView.GetRendererAt( 0 );
2545 Shader shader2 = renderer.GetShader();
2546 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2547 Property::Map* map = value.GetMap();
2548 DALI_TEST_CHECK( map );
2550 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2551 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2553 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2554 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2563 static int gFailCounter = 0;
2564 const int MAX_RETRIES(3);
2566 void ReloadImage(ImageView imageView)
2568 Property::Map imageImmediateLoadingMap;
2569 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2570 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2572 tet_infoline("Immediate load an image");
2573 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2576 void ResourceFailedReload( Control control )
2579 if( gFailCounter < MAX_RETRIES )
2581 ReloadImage(ImageView::DownCast(control));
2586 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2588 tet_infoline("Test reloading failed image from within signal handler.");
2590 ToolkitTestApplication application;
2594 ImageView imageView = ImageView::New();
2595 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2596 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2597 ReloadImage(imageView);
2599 // loading started, this waits for the loader thread to complete
2600 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2601 application.SendNotification();
2603 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2605 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2606 application.SendNotification();
2608 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2610 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2611 application.SendNotification();
2612 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2617 int UtcDaliImageViewLoadRemoteSVG(void)
2619 tet_infoline("Test load from a remote server.");
2621 ToolkitTestApplication application;
2622 Toolkit::ImageView imageView;
2623 imageView = Toolkit::ImageView::New();
2624 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2625 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2626 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2627 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2628 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2629 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2630 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2632 application.GetScene().Add( imageView );
2634 DALI_TEST_CHECK( imageView );
2636 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2638 application.SendNotification();
2640 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2642 application.SendNotification();
2643 application.Render();
2645 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2650 int UtcDaliImageViewSyncSVGLoading(void)
2652 ToolkitTestApplication application;
2654 tet_infoline("ImageView Testing SVG image sync loading");
2656 // Sync loading, automatic atlasing for small size image
2658 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2660 callStack.Enable(true);
2662 ImageView imageView = ImageView::New( );
2664 // Sync loading is used
2665 Property::Map syncLoadingMap;
2666 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2667 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2668 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2669 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2671 application.GetScene().Add( imageView );
2672 DALI_TEST_CHECK( imageView );
2674 application.SendNotification();
2675 application.Render(16);
2676 Vector3 naturalSize = imageView.GetNaturalSize();
2678 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2679 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2685 int UtcDaliImageViewAsyncSVGLoading(void)
2687 ToolkitTestApplication application;
2689 tet_infoline("ImageView Testing SVG image async loading");
2691 // Sync loading, automatic atlasing for small size image
2693 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2695 callStack.Enable(true);
2697 ImageView imageView = ImageView::New( );
2699 // Sync loading is used
2700 Property::Map syncLoadingMap;
2701 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2702 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2703 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2704 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2706 application.GetScene().Add( imageView );
2707 DALI_TEST_CHECK( imageView );
2709 application.SendNotification();
2710 application.Render(16);
2711 Vector3 naturalSize = imageView.GetNaturalSize();
2713 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2714 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2719 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2721 ToolkitTestApplication application;
2723 tet_infoline("ImageView Testing SVG image async loading");
2725 // Sync loading, automatic atlasing for small size image
2727 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2729 callStack.Enable(true);
2731 ImageView imageView = ImageView::New( );
2733 // Sync loading is used
2734 Property::Map syncLoadingMap;
2735 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2736 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2738 // Check to set invalid value
2739 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2740 // Check if error log is outputted when setting other value like string.
2741 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2742 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2743 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2745 application.GetScene().Add( imageView );
2746 DALI_TEST_CHECK( imageView );
2748 application.SendNotification();
2749 application.Render(16);
2750 Vector3 naturalSize = imageView.GetNaturalSize();
2751 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2752 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2754 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2755 Property::Map* map = value.GetMap();
2756 DALI_TEST_CHECK( map );
2758 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2759 DALI_TEST_CHECK( sync );
2760 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2766 int UtcDaliImageViewSvgLoadingFailure(void)
2768 ToolkitTestApplication application;
2770 // Local svg file - invalid file path
2772 gResourceReadySignalFired = false;
2774 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/foo.svg" );
2775 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2776 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2778 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2780 application.GetScene().Add( imageView );
2782 application.SendNotification();
2783 application.Render(16);
2785 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2786 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2787 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2790 // Local svg file - invalid file
2792 gResourceReadySignalFired = false;
2794 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/invalid.svg" );
2795 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2796 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2798 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2800 application.GetScene().Add( imageView );
2802 application.SendNotification();
2803 application.Render(16);
2805 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2806 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2807 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2812 gResourceReadySignalFired = false;
2814 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2815 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2816 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2818 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2820 application.GetScene().Add( imageView );
2822 application.SendNotification();
2824 // loading started, this waits for the loader thread
2825 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2827 application.SendNotification();
2828 application.Render(16);
2830 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2831 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2832 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2838 int UtcDaliImageViewSvgRasterizationFailure(void)
2840 ToolkitTestApplication application;
2842 gResourceReadySignalFired = false;
2844 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/svg1.svg" );
2845 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2846 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2848 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2850 application.GetScene().Add( imageView );
2852 application.SendNotification();
2854 // loading started, this waits for the loader thread
2855 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2857 application.SendNotification();
2858 application.Render(16);
2860 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2861 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2862 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::READY, TEST_LOCATION );
2865 gResourceReadySignalFired = false;
2868 imageView.SetProperty( Actor::Property::SIZE, Vector2( 0.f, 0.f ) );
2870 application.SendNotification();
2872 // rasterization started, this waits for the rasterize thread
2873 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2875 application.SendNotification();
2876 application.Render(16);
2878 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2879 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2880 // Fail to rasterize because the size is 0.
2881 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2889 static int gResourceReadySignalCounter = 0;
2891 void OnResourceReadySignal01( Control control )
2893 gResourceReadySignalCounter++;
2895 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
2897 if( gResourceReadySignalCounter == 1 )
2900 // It makes the first new visual be deleted immediately
2901 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2902 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2905 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
2907 // Make the resource ready immediately
2908 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
2912 void OnResourceReadySignal02( Control control )
2914 if(++gResourceReadySignalCounter == 1)
2916 // It makes the first new visual be deleted immediately
2917 // The first image will not be loaded.
2918 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
2919 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2920 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
2924 ImageView gImageView1;
2925 ImageView gImageView2;
2926 ImageView gImageView3;
2928 void OnResourceReadySignal03( Control control )
2930 if(gResourceReadySignalCounter == 0)
2933 // 1. Use cached image, then UploadComplete will be called right after OnResourceReadySignal03.
2934 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
2936 // 2. Load a new image
2937 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
2939 // 3. Use the new image again
2940 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
2941 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
2943 else if(gResourceReadySignalCounter == 1)
2945 // This is called from TextureManager::ProcessQueuedTextures().
2946 gImageView1.Unparent();
2947 gImageView1.Reset();
2949 gResourceReadySignalCounter++;
2954 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
2956 tet_infoline("Test setting image from within signal handler.");
2958 ToolkitTestApplication application;
2960 gResourceReadySignalCounter = 0;
2962 ImageView imageView = ImageView::New( gImage_34_RGBA );
2963 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
2965 application.GetScene().Add( imageView );
2967 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2969 application.SendNotification();
2970 application.Render();
2972 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2974 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2977 gResourceReadySignalCounter = 0;
2979 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
2981 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2983 application.SendNotification();
2984 application.Render();
2986 // Run idle callback
2987 application.RunIdles();
2989 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2991 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2996 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
2998 tet_infoline("Test setting image from within signal handler.");
3000 ToolkitTestApplication application;
3002 gResourceReadySignalCounter = 0;
3004 ImageView imageView = ImageView::New( gImage_34_RGBA );
3005 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal02 );
3007 application.GetScene().Add( imageView );
3009 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3011 application.SendNotification();
3012 application.Render();
3014 // Wait for loading an image
3015 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3017 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3019 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3024 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3026 tet_infoline("Test setting image from within signal handler.");
3028 ToolkitTestApplication application;
3030 gResourceReadySignalCounter = 0;
3032 gImageView1 = ImageView::New(gImage_34_RGBA);
3033 application.GetScene().Add(gImageView1);
3036 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3038 gImageView2 = ImageView::New(gImage_600_RGB);
3039 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3040 application.GetScene().Add(gImageView2);
3042 gImageView3 = ImageView::New();
3043 application.GetScene().Add(gImageView3);
3045 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3047 application.SendNotification();
3048 application.Render();