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>
33 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
35 #include <test-native-image.h>
36 #include <test-encoded-image-buffer.h>
41 #include "dummy-control.h"
44 using namespace Toolkit;
46 void utc_dali_toolkit_image_view_startup(void)
48 test_return_value = TET_UNDEF;
51 void utc_dali_toolkit_image_view_cleanup(void)
53 test_return_value = TET_PASS;
59 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
60 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
62 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
63 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
65 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
66 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
67 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
68 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
69 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
70 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
72 // resolution: 34*34, pixel format: RGBA8888
73 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
74 // resolution: 600*600, pixel format: RGB888
75 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
77 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
78 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
80 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
82 void TestUrl( ImageView imageView, const std::string url )
84 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
86 std::string urlActual;
87 DALI_TEST_CHECK( value.Get( urlActual ) );
88 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
93 int UtcDaliImageViewNewP(void)
95 ToolkitTestApplication application;
97 ImageView imageView = ImageView::New();
99 DALI_TEST_CHECK( imageView );
104 int UtcDaliImageViewNewUrlP(void)
106 ToolkitTestApplication application;
108 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
109 DALI_TEST_CHECK( imageView );
111 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
116 int UtcDaliImageViewConstructorP(void)
118 ToolkitTestApplication application;
122 DALI_TEST_CHECK( !imageView );
127 int UtcDaliImageViewCopyConstructorP(void)
129 ToolkitTestApplication application;
131 // Initialize an object, ref count == 1
132 ImageView imageView = ImageView::New();
134 ImageView copy( imageView );
135 DALI_TEST_CHECK( copy );
140 int UtcDaliImageViewMoveConstructor(void)
142 ToolkitTestApplication application;
144 ImageView imageView = ImageView::New();
145 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
146 imageView.SetProperty( Actor::Property::SENSITIVE, false );
147 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
149 ImageView moved = std::move( imageView );
150 DALI_TEST_CHECK( moved );
151 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
152 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
153 DALI_TEST_CHECK( !imageView );
158 int UtcDaliImageViewAssignmentOperatorP(void)
160 ToolkitTestApplication application;
162 ImageView imageView = ImageView::New();
164 ImageView copy( imageView );
165 DALI_TEST_CHECK( copy );
166 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
171 int UtcDaliImageViewMoveAssignment(void)
173 ToolkitTestApplication application;
175 ImageView imageView = ImageView::New();
176 DALI_TEST_EQUALS( 1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
177 imageView.SetProperty( Actor::Property::SENSITIVE, false );
178 DALI_TEST_CHECK( false == imageView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
181 moved = std::move( imageView );
182 DALI_TEST_CHECK( moved );
183 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
184 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
185 DALI_TEST_CHECK( !imageView );
190 int UtcDaliImageViewDownCastP(void)
192 ToolkitTestApplication application;
194 ImageView imageView = ImageView::New();
196 BaseHandle object(imageView);
198 ImageView imageView2 = ImageView::DownCast( object );
199 DALI_TEST_CHECK(imageView2);
201 ImageView imageView3 = DownCast< ImageView >( object );
202 DALI_TEST_CHECK(imageView3);
207 int UtcDaliImageViewDownCastN(void)
209 ToolkitTestApplication application;
211 BaseHandle unInitializedObject;
213 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
214 DALI_TEST_CHECK( !imageView1 );
216 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
217 DALI_TEST_CHECK( !imageView2 );
222 int UtcDaliImageViewTypeRegistry(void)
224 ToolkitTestApplication application;
226 TypeRegistry typeRegistry = TypeRegistry::Get();
227 DALI_TEST_CHECK( typeRegistry );
229 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
230 DALI_TEST_CHECK( typeInfo );
232 BaseHandle handle = typeInfo.CreateInstance();
233 DALI_TEST_CHECK( handle );
235 ImageView imageView = ImageView::DownCast( handle );
236 DALI_TEST_CHECK( imageView );
241 int UtcDaliImageViewSetGetProperty01(void)
243 ToolkitTestApplication application;
245 ImageView imageView = ImageView::New();
247 Property::Index idx = imageView.GetPropertyIndex( "image" );
248 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
250 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
251 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
256 int UtcDaliImageViewPreMultipliedAlphaPng(void)
258 ToolkitTestApplication application;
260 // Set up trace debug
261 TestGlAbstraction& gl = application.GetGlAbstraction();
262 TraceCallStack& textureTrace = gl.GetTextureTrace();
263 textureTrace.Enable( true );
265 Property::Map imageMap;
266 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
267 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
269 ImageView imageView1 = ImageView::New();
270 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
272 application.GetScene().Add( imageView1 );
274 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
276 DALI_TEST_CHECK( value.Get( enable ) );
277 DALI_TEST_CHECK( enable ); // Default value is true
279 // loading started, this waits for the loader thread for max 30 seconds
280 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
282 application.SendNotification();
283 application.Render();
285 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
286 DALI_TEST_CHECK( value.Get( enable ) );
287 DALI_TEST_CHECK( enable ); // Keep true
289 // conventional alpha blending
290 Renderer renderer1 = imageView1.GetRendererAt( 0 );
291 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
292 DALI_TEST_CHECK( value.Get( enable ) );
293 DALI_TEST_CHECK( enable );
295 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
296 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
297 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
298 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
299 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
300 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
301 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
302 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
304 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
305 textureTrace.Reset();
307 // Disable pre-multiplied alpha blending
308 imageView1.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
311 Property::Map attributes;
312 DevelControl::DoAction( imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes );
314 // loading started, this waits for the loader thread for max 30 seconds
315 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
317 application.SendNotification();
318 application.Render();
320 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
321 DALI_TEST_CHECK( value.Get( enable ) );
322 DALI_TEST_CHECK( !enable );
324 // conventional alpha blending
325 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
326 DALI_TEST_CHECK( value.Get( enable ) );
327 DALI_TEST_CHECK( !enable );
329 srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
330 destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
331 srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
332 destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
333 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
334 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
335 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
336 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
338 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
339 textureTrace.Reset();
341 // Make a new ImageView using the same image
342 ImageView imageView2 = ImageView::New();
343 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
345 application.GetScene().Add( imageView2 );
347 application.SendNotification();
348 application.Render();
350 Renderer renderer2 = imageView2.GetRendererAt( 0 );
351 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
352 DALI_TEST_CHECK( value.Get( enable ) );
353 DALI_TEST_CHECK( enable );
355 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
356 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
357 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
358 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
359 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
360 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
361 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
362 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
364 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
369 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
371 ToolkitTestApplication application;
373 // Set up trace debug
374 TestGlAbstraction& gl = application.GetGlAbstraction();
375 TraceCallStack& textureTrace = gl.GetTextureTrace();
376 textureTrace.Enable( true );
378 Property::Map imageMap;
379 imageMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
380 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
382 ImageView imageView1 = ImageView::New();
383 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
385 application.GetScene().Add( imageView1 );
387 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
389 DALI_TEST_CHECK( value.Get( enable ) );
390 DALI_TEST_CHECK( enable ); // Default value is true
392 // loading started, this waits for the loader thread for max 30 seconds
393 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
395 application.SendNotification();
396 application.Render();
398 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
399 DALI_TEST_CHECK( value.Get( enable ) );
400 DALI_TEST_CHECK( !enable ); // Should be false after loading
402 // conventional alpha blending
403 Renderer renderer1 = imageView1.GetRendererAt( 0 );
404 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
405 DALI_TEST_CHECK( value.Get( enable ) );
406 DALI_TEST_CHECK( !enable );
408 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
409 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
410 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
411 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
412 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
413 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
414 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
415 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
417 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
418 textureTrace.Reset();
420 ImageView imageView2 = ImageView::New();
421 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
423 // Disable pre-multiplied alpha blending
424 imageView2.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
426 application.GetScene().Add( imageView2 );
428 application.SendNotification();
429 application.Render();
431 value = imageView2.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
432 DALI_TEST_CHECK( value.Get( enable ) );
433 DALI_TEST_CHECK( !enable );
435 // conventional alpha blending
436 Renderer renderer2 = imageView2.GetRendererAt( 0 );
437 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
438 DALI_TEST_CHECK( value.Get( enable ) );
439 DALI_TEST_CHECK( !enable );
441 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
442 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
443 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
444 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
445 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
446 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
447 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
448 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
450 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
455 int UtcDaliImageViewPixelArea(void)
457 // Test pixel area property
458 ToolkitTestApplication application;
460 static std::vector<UniformData> customUniforms =
462 UniformData("pixelArea", Property::Type::VECTOR4),
465 TestGraphicsController& graphics = application.GetGraphicsController();
466 graphics.AddCustomUniforms(customUniforms);
468 // Gif image, use AnimatedImageVisual internally
469 // Atlasing is applied to pack multiple frames, use custom wrap mode
470 ImageView gifView = ImageView::New();
471 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
472 gifView.SetProperty( ImageView::Property::IMAGE,
473 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
474 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
477 Integration::Scene stage = application.GetScene();
478 stage.Add( gifView );
481 application.SendNotification();
482 application.Render(16);
484 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
486 application.SendNotification();
487 application.Render();
488 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
490 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
491 // test that the pixel area value defined in the visual property map is registered on renderer
492 Renderer renderer = gifView.GetRendererAt(0);
493 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
494 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
496 // test that the shader has the default pixel area value registered.
497 Shader shader = renderer.GetShader();
498 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
499 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
501 // test that the uniform uses the pixelArea property on the renderer.
502 TestGlAbstraction& gl = application.GetGlAbstraction();
503 Vector4 pixelAreaUniform;
504 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
505 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
507 // set the pixelArea property on the control
508 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
509 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
510 application.SendNotification();
511 application.Render(16);
513 // check the pixelArea property on the control
514 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
515 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
516 // test that the uniform uses the pixelArea property on the control.
517 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
518 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
524 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
526 ToolkitTestApplication application;
527 TestGlAbstraction& gl = application.GetGlAbstraction();
528 const std::vector<GLuint>& textures = gl.GetBoundTextures();
529 size_t numTextures = textures.size();
531 // Async loading, no atlasing for big size image
532 ImageView imageView = ImageView::New( gImage_600_RGB );
534 // By default, Aysnc loading is used
535 application.GetScene().Add( imageView );
536 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
537 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
539 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
541 application.SendNotification();
542 application.Render(16);
543 application.SendNotification();
545 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
546 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
551 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
553 ToolkitTestApplication application;
555 //Async loading, automatic atlasing for small size image
556 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
558 callStack.Enable(true);
560 Property::Map imageMap;
562 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
563 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
564 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
565 imageMap[ ImageVisual::Property::ATLASING] = true;
567 ImageView imageView = ImageView::New();
568 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
569 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
571 // By default, Aysnc loading is used
572 // loading is not started if the actor is offScene
574 application.GetScene().Add( imageView );
575 application.SendNotification();
576 application.Render(16);
577 application.Render(16);
578 application.SendNotification();
580 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
581 application.SendNotification();
582 application.Render(16);
583 application.Render(16);
584 application.SendNotification();
586 // loading started, this waits for the loader thread for max 30 seconds
587 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
589 application.SendNotification();
590 application.Render(16);
592 callStack.Enable(false);
594 TraceCallStack::NamedParams params;
595 params["width"] << 34;
596 params["height"] << 34;
597 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
602 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
604 ToolkitTestApplication application;
606 //Async loading, automatic atlasing for small size image
607 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
609 callStack.Enable(true);
611 Property::Map asyncLoadingMap;
612 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
613 asyncLoadingMap[ "desiredHeight" ] = 34;
614 asyncLoadingMap[ "desiredWidth" ] = 34;
615 asyncLoadingMap[ "synchronousLoading" ] = false;
616 asyncLoadingMap[ "atlasing" ] = true;
618 ImageView imageView = ImageView::New();
619 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
621 application.GetScene().Add( imageView );
622 application.SendNotification();
623 application.Render(16);
624 application.Render(16);
625 application.SendNotification();
627 // loading started, this waits for the loader thread for max 30 seconds
628 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
630 application.SendNotification();
631 application.Render(16);
633 callStack.Enable(false);
635 TraceCallStack::NamedParams params;
636 params["width"] << 34;
637 params["height"] << 34;
638 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
643 int UtcDaliImageViewSyncLoading(void)
645 ToolkitTestApplication application;
647 tet_infoline("ImageView Testing sync loading and size using index key property map");
649 Property::Map syncLoadingMap;
650 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
651 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
653 // Sync loading, no atlasing for big size image
655 ImageView imageView = ImageView::New();
657 // Sync loading is used
658 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
659 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
662 // Sync loading, automatic atlasing for small size image
664 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
666 callStack.Enable(true);
668 ImageView imageView = ImageView::New( );
670 // Sync loading is used
671 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
672 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
673 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
674 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
676 application.GetScene().Add( imageView );
677 application.SendNotification();
678 application.Render(16);
680 TraceCallStack::NamedParams params;
681 params["width"] << 34;
682 params["height"] << 34;
683 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
684 true, TEST_LOCATION );
689 int UtcDaliImageViewSyncLoading02(void)
691 ToolkitTestApplication application;
693 tet_infoline("ImageView Testing sync loading and size using string key property map");
695 // Sync loading, automatic atlasing for small size image
697 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
699 callStack.Enable(true);
701 ImageView imageView = ImageView::New( );
703 // Sync loading is used
704 Property::Map syncLoadingMap;
705 syncLoadingMap[ "url" ] = gImage_34_RGBA;
706 syncLoadingMap[ "desiredHeight" ] = 34;
707 syncLoadingMap[ "desiredWidth" ] = 34;
708 syncLoadingMap[ "synchronousLoading" ] = true;
709 syncLoadingMap[ "atlasing" ] = true;
710 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
712 application.GetScene().Add( imageView );
713 application.SendNotification();
714 application.Render(16);
716 TraceCallStack::NamedParams params;
717 params["width"] << 34;
718 params["height"] << 34;
719 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
720 true, TEST_LOCATION );
725 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
727 ToolkitTestApplication application;
728 TestGlAbstraction& gl = application.GetGlAbstraction();
729 const std::vector<GLuint>& textures = gl.GetBoundTextures();
730 size_t numTextures = textures.size();
732 // Get encoded raw-buffer image and generate url
733 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
734 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
736 // Async loading, no atlasing for big size image
737 ImageView imageView = ImageView::New(url.GetUrl());
739 // By default, Aysnc loading is used
740 application.GetScene().Add(imageView);
741 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
742 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
744 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
746 application.SendNotification();
747 application.Render(16);
748 application.SendNotification();
750 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
751 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
756 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
758 ToolkitTestApplication application;
760 // Get encoded raw-buffer image and generate url
761 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
762 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
763 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
765 // Generate url is not equal to url2
766 // NOTE : This behavior may changed when ImageUrl compare operator changed.
767 DALI_TEST_CHECK(url != url2);
768 // Generate url's string is equal to url2's string
769 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
771 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
772 url2 = Toolkit::Image::GenerateUrl(buffer2);
774 // Check whethere two url are not equal
775 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
777 // Async loading, automatic atlasing for small size image
778 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
780 callStack.Enable(true);
782 Property::Map imageMap;
784 imageMap[ ImageVisual::Property::URL ] = url.GetUrl();
785 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
786 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
787 imageMap[ ImageVisual::Property::ATLASING] = true;
789 ImageView imageView = ImageView::New();
790 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
791 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
793 // By default, Aysnc loading is used
794 // loading is not started if the actor is offScene
796 application.GetScene().Add( imageView );
797 application.SendNotification();
798 application.Render(16);
799 application.Render(16);
800 application.SendNotification();
802 // Change url to url2
803 imageMap[ ImageVisual::Property::URL ] = url2.GetUrl();
804 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
806 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
807 application.SendNotification();
808 application.Render(16);
809 application.Render(16);
810 application.SendNotification();
812 // loading started, this waits for the loader thread for max 30 seconds
813 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
815 application.SendNotification();
816 application.Render(16);
818 callStack.Enable(false);
820 TraceCallStack::NamedParams params;
821 params["width"] << 34;
822 params["height"] << 34;
823 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
828 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
830 ToolkitTestApplication application;
832 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
834 // Get encoded raw-buffer image and generate url
835 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
836 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
838 // Sync loading, automatic atlasing for small size image
840 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
842 callStack.Enable(true);
844 ImageView imageView = ImageView::New( );
846 // Sync loading is used
847 Property::Map syncLoadingMap;
848 syncLoadingMap[ "url" ] = url.GetUrl();
849 syncLoadingMap[ "desiredHeight" ] = 34;
850 syncLoadingMap[ "desiredWidth" ] = 34;
851 syncLoadingMap[ "synchronousLoading" ] = true;
852 syncLoadingMap[ "atlasing" ] = true;
853 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
855 application.GetScene().Add( imageView );
856 application.SendNotification();
857 application.Render(16);
859 TraceCallStack::NamedParams params;
860 params["width"] << 34;
861 params["height"] << 34;
862 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
863 true, TEST_LOCATION );
869 int UtcDaliImageViewAddedTexture(void)
871 ToolkitTestApplication application;
873 tet_infoline("ImageView Testing image view with texture provided manager url");
875 ImageView imageView = ImageView::New();
877 // empty texture is ok, though pointless from app point of view
879 std::string url = TextureManager::AddTexture(empty);
880 DALI_TEST_CHECK(url.size() > 0u);
882 Property::Map propertyMap;
883 propertyMap[ImageVisual::Property::URL] = url;
884 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
886 application.GetScene().Add( imageView );
887 application.SendNotification();
888 application.Render();
893 int UtcDaliImageViewSizeWithBackground(void)
895 ToolkitTestApplication application;
899 ImageView imageView = ImageView::New();
901 imageView.SetProperty( Control::Property::BACKGROUND,
903 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
904 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
905 { ImageVisual::Property::DESIRED_WIDTH, width },
906 { ImageVisual::Property::DESIRED_HEIGHT, height },
910 application.GetScene().Add( imageView );
911 application.SendNotification();
912 application.Render();
914 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
915 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
920 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
922 ToolkitTestApplication application;
924 int widthBackground = 100;
925 int heightBackground = 200;
929 ImageView imageView = ImageView::New();
931 imageView.SetProperty( Control::Property::BACKGROUND,
933 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
934 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
935 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
936 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
940 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
942 application.GetScene().Add( imageView );
943 application.SendNotification();
944 application.Render();
946 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
947 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
952 int UtcDaliImageViewHeightForWidthBackground(void)
954 ToolkitTestApplication application;
956 int widthBackground = 100;
957 int heightBackground = 200;
959 ImageView imageView = ImageView::New();
961 imageView.SetProperty( Control::Property::BACKGROUND,
963 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
964 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
965 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
966 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
970 application.GetScene().Add( imageView );
971 application.SendNotification();
972 application.Render();
974 Control control = Control::DownCast( imageView );
975 DALI_TEST_CHECK( control );
976 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
977 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
982 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
984 ToolkitTestApplication application;
986 int widthBackground = 100;
987 int heightBackground = 200;
991 ImageView imageView = ImageView::New();
993 imageView.SetProperty( Control::Property::BACKGROUND,
995 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
996 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
997 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
998 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
1002 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
1004 application.GetScene().Add( imageView );
1005 application.SendNotification();
1006 application.Render();
1008 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
1009 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
1014 int UtcDaliImageViewSetImageUrl(void)
1016 ToolkitTestApplication application;
1018 ImageView imageView = ImageView::New();
1019 imageView.SetImage( TEST_IMAGE_FILE_NAME );
1020 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
1023 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
1024 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
1029 bool gResourceReadySignalFired = false;
1030 Vector3 gNaturalSize;
1032 void ResourceReadySignal( Control control )
1034 gResourceReadySignalFired = true;
1037 int UtcDaliImageViewCheckResourceReady(void)
1039 ToolkitTestApplication application;
1041 gResourceReadySignalFired = false;
1043 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1044 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
1046 imageView.SetProperty( Control::Property::BACKGROUND,
1048 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
1049 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
1050 { ImageVisual::Property::DESIRED_WIDTH, 100 },
1051 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
1055 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1057 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1059 application.GetScene().Add( imageView );
1061 // loading started, this waits for the loader thread
1062 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1064 application.SendNotification();
1065 application.Render(16);
1067 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1069 application.SendNotification();
1070 application.Render();
1072 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1074 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1079 int UtcDaliImageViewSetImageTypeChangesP(void)
1081 ToolkitTestApplication application;
1083 ImageView imageView = ImageView::New();
1084 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1086 application.GetScene().Add( imageView );
1090 Toolkit::Visual::Base visual;
1092 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1093 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1095 application.SendNotification();
1096 application.Render( 16 );
1098 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1100 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1101 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1104 imageView.SetImage( "TEST_URL" );
1106 application.SendNotification();
1107 application.Render( 16 );
1109 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1110 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1112 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
1113 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
1114 DALI_TEST_CHECK( visual ); // Visual should be valid
1117 imageView.SetImage( "" );
1119 application.SendNotification();
1120 application.Render( 16 );
1122 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1123 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1125 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1127 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
1128 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1130 // Set a URL in property map
1131 Property::Map propertyMap;
1132 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1133 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1135 application.SendNotification();
1136 application.Render( 16 );
1138 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1139 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1141 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1142 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1143 DALI_TEST_CHECK( visual ); // Visual should be valid
1145 // Set a URL in property map again
1146 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1147 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1149 application.SendNotification();
1150 application.Render( 16 );
1152 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1153 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1155 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1156 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1157 DALI_TEST_CHECK( visual ); // Visual should be valid
1159 // Set an empty URL in property map
1160 propertyMap[ImageVisual::Property::URL] = std::string();
1161 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
1163 application.SendNotification();
1164 application.Render( 16 );
1166 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1167 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1169 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
1170 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
1171 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
1176 int UtcDaliImageViewResourceUrlP(void)
1178 ToolkitTestApplication application;
1180 ImageView imageView = ImageView::New();
1181 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
1183 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
1184 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
1189 int UtcDaliImageViewReplaceImage(void)
1191 ToolkitTestApplication application;
1193 gResourceReadySignalFired = false;
1195 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1196 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1198 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1200 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1202 application.GetScene().Add( imageView );
1204 application.SendNotification();
1205 application.Render(16);
1207 // loading started, this waits for the loader thread for max 30 seconds
1208 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1210 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1212 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1214 gResourceReadySignalFired = false;
1216 imageView.SetImage(TEST_IMAGE_2);
1218 application.SendNotification();
1219 application.Render(16);
1221 // loading started, this waits for the loader thread for max 30 seconds
1222 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1224 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1226 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1228 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1233 void OnRelayoutOverride( Size size )
1235 gNaturalSize = size; // Size Relayout is using
1238 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1240 ToolkitTestApplication application;
1242 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1243 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1244 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1246 DummyControl dummyControl = DummyControl::New( true );
1247 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1248 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1250 dummyControl.Add( imageView );
1251 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1252 application.GetScene().Add( dummyControl );
1254 application.SendNotification();
1255 application.Render();
1257 // loading started, this waits for the loader thread for max 30 seconds
1258 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1260 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1261 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1263 gNaturalSize = Vector3::ZERO;
1265 imageView.SetImage(gImage_600_RGB);
1267 // Waiting for resourceReady so SendNotifcation not called here.
1269 // loading started, this waits for the loader thread for max 30 seconds
1270 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1272 // Trigger a potential relayout
1273 application.SendNotification();
1274 application.Render();
1276 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1277 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1282 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1284 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1286 ToolkitTestApplication application;
1288 gResourceReadySignalFired = false;
1290 Property::Map imageMap;
1292 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1293 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1295 tet_infoline("Creating ImageView without URL so image does not start loading");
1296 ImageView imageView = ImageView::New();
1297 tet_infoline("Connect to image loaded signal before setting image");
1298 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1299 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1300 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1302 // loading started, this waits for the loader thread
1303 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1305 application.SendNotification();
1306 application.Render(16);
1308 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1313 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1315 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1317 ToolkitTestApplication application;
1319 gResourceReadySignalFired = false;
1321 Property::Map imageMap;
1323 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1324 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1326 ImageView imageView = ImageView::New();
1327 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1328 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1330 // loading started, this waits for the loader thread
1331 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1333 application.SendNotification();
1334 application.Render(16);
1336 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1337 gResourceReadySignalFired = false;
1339 ImageView imageViewWithExistingImage = ImageView::New();
1340 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1341 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1343 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1348 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1350 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1352 ToolkitTestApplication application;
1354 gResourceReadySignalFired = false;
1356 Property::Map imageImmediateLoadingMap;
1357 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1358 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1360 tet_infoline("Immediate load an image");
1361 ImageView imageView = ImageView::New();
1362 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1363 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1365 // loading started, this waits for the loader thread
1366 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1368 application.SendNotification();
1369 application.Render(16);
1371 tet_infoline("Check image loaded");
1372 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1373 gResourceReadySignalFired = false;
1375 tet_infoline("Create another ImageView with the same URL");
1376 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1377 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1378 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1380 application.GetScene().Add( imageViewWithExistingImage );
1382 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1387 int UtcDaliImageViewPaddingProperty(void)
1389 ToolkitTestApplication application;
1391 ImageView imageView = ImageView::New();
1392 Property::Map imagePropertyMap;
1393 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1394 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1395 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1396 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1397 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1398 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1399 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1400 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1401 application.GetScene().Add( imageView );
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1408 ImageView childImage = ImageView::New();
1409 childImage.SetBackgroundColor( Color::BLACK );
1410 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1411 imageView.Add( childImage );
1413 application.SendNotification();
1414 application.Render();
1416 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1417 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1419 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1420 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1421 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1422 Property::Map resultMap;
1423 imageVisual.CreatePropertyMap( resultMap );
1425 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1426 DALI_TEST_CHECK( transformValue );
1427 Property::Map* retMap = transformValue->GetMap();
1428 DALI_TEST_CHECK( retMap );
1430 // Image Visual should be positioned depending on ImageView's padding
1431 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1436 int UtcDaliImageViewPaddingProperty02(void)
1438 ToolkitTestApplication application;
1440 ImageView imageView = ImageView::New();
1441 Property::Map imagePropertyMap;
1442 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1443 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1444 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1445 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1446 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1447 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1448 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1449 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1450 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1451 application.GetScene().Add( imageView );
1453 application.SendNotification();
1454 application.Render();
1456 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1458 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1459 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1460 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1461 Property::Map resultMap;
1462 imageVisual.CreatePropertyMap( resultMap );
1464 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1465 DALI_TEST_CHECK( transformValue );
1466 Property::Map* retMap = transformValue->GetMap();
1467 DALI_TEST_CHECK( retMap );
1469 // Image Visual should be positioned depending on ImageView's padding
1470 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1475 int UtcDaliImageViewPaddingProperty03(void)
1477 tet_infoline("Test Setting Image Padding then removing it.");
1479 ToolkitTestApplication application;
1481 ImageView imageView = ImageView::New();
1482 Property::Map imagePropertyMap;
1483 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1484 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1485 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1486 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1487 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1488 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1489 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1490 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1491 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1492 application.GetScene().Add( imageView );
1494 application.SendNotification();
1495 application.Render();
1497 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1499 tet_infoline("Remove Padding and test Visual is position correctly");
1501 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1503 application.SendNotification();
1504 application.Render();
1506 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1507 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1508 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1509 Property::Map resultMap;
1510 imageVisual.CreatePropertyMap( resultMap );
1512 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1513 DALI_TEST_CHECK( transformValue );
1514 Property::Map* retMap = transformValue->GetMap();
1515 DALI_TEST_CHECK( retMap );
1517 // Image Visual should be positioned depending on ImageView's padding
1518 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1523 int UtcDaliImageViewPaddingProperty04(void)
1525 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1527 ToolkitTestApplication application;
1529 ImageView imageView = ImageView::New();
1530 Property::Map imagePropertyMap;
1531 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1532 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1533 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1534 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1535 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1536 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1537 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1538 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1539 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1540 application.GetScene().Add( imageView );
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1547 tet_infoline("Remove Padding and test Visual is position correctly");
1549 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1551 application.SendNotification();
1552 application.Render();
1554 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1555 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1556 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1557 Property::Map resultMap;
1558 imageVisual.CreatePropertyMap( resultMap );
1560 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1561 DALI_TEST_CHECK( transformValue );
1562 Property::Map* retMap = transformValue->GetMap();
1563 DALI_TEST_CHECK( retMap );
1565 // Image Visual should be positioned depending on ImageView's padding
1566 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1571 int UtcDaliImageViewTransformTest01(void)
1573 tet_infoline("Test Setting a offset transform on the ImageView");
1575 ToolkitTestApplication application;
1577 ImageView imageView = ImageView::New();
1578 Property::Map imagePropertyMap;
1579 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1580 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1581 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1582 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1583 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1584 .Add( Visual::Property::TRANSFORM,
1585 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1586 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1587 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1589 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1590 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1591 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1592 application.GetScene().Add( imageView );
1594 application.SendNotification();
1595 application.Render();
1597 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1598 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1599 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1600 Property::Map resultMap;
1601 imageVisual.CreatePropertyMap( resultMap );
1603 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1604 DALI_TEST_CHECK( transformValue );
1605 Property::Map* retMap = transformValue->GetMap();
1606 DALI_TEST_CHECK( retMap );
1608 // Image Visual should be positioned depending on ImageView's padding
1609 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1610 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 );
1615 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1617 ToolkitTestApplication application;
1619 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1620 ImageView imageView = ImageView::New();
1621 Property::Map imageMap;
1622 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1623 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1624 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1625 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1626 application.GetScene().Add( imageView );
1628 // Trigger a potential relayout
1629 application.SendNotification();
1630 application.Render();
1632 Vector3 naturalSize = imageView.GetNaturalSize();
1634 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1635 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1640 int UtcDaliImageViewFillMode(void)
1642 ToolkitTestApplication application;
1644 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1646 ImageView imageView = ImageView::New();
1647 Property::Map imageMap;
1648 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1649 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1650 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1652 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1654 application.GetScene().Add( imageView );
1656 // Trigger a potential relayout
1657 application.SendNotification();
1658 application.Render();
1660 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1661 Property::Map returnedMap;
1662 visual.CreatePropertyMap( returnedMap );
1664 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1665 DALI_TEST_CHECK( value );
1666 Property::Map* map = value->GetMap();
1667 DALI_TEST_CHECK( map );
1669 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1670 DALI_TEST_CHECK( value );
1671 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1673 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1674 DALI_TEST_CHECK( value );
1675 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1680 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1682 ToolkitTestApplication application;
1684 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1685 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1687 ImageView imageView = ImageView::New();
1688 Property::Map imageMap;
1689 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1690 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1691 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1693 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1694 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1696 application.GetScene().Add( imageView );
1698 // Trigger a potential relayout
1699 application.SendNotification();
1700 application.Render();
1702 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1703 Property::Map returnedMap;
1704 visual.CreatePropertyMap( returnedMap );
1706 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1707 DALI_TEST_CHECK( value );
1708 Property::Map* map = value->GetMap();
1709 DALI_TEST_CHECK( map );
1712 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1713 DALI_TEST_CHECK( value );
1714 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1716 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1717 DALI_TEST_CHECK( value );
1718 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1720 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1721 DALI_TEST_CHECK( value );
1722 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1727 int UtcDaliImageViewFittingModesFill(void)
1729 ToolkitTestApplication application;
1731 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1732 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1734 ImageView imageView = ImageView::New();
1735 Property::Map imageMap;
1736 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1737 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1738 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1740 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1741 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1743 application.GetScene().Add( imageView );
1745 // Trigger a potential relayout
1746 application.SendNotification();
1747 application.Render();
1749 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1750 Property::Map returnedMap;
1751 visual.CreatePropertyMap( returnedMap );
1753 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1754 DALI_TEST_CHECK( value );
1755 Property::Map* map = value->GetMap();
1756 DALI_TEST_CHECK( map );
1758 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1759 DALI_TEST_CHECK( value );
1760 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1762 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1763 DALI_TEST_CHECK( value );
1764 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1766 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1767 DALI_TEST_CHECK( value );
1768 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1773 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1775 ToolkitTestApplication application;
1777 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1778 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1780 ImageView imageView = ImageView::New();
1781 Property::Map imageMap;
1782 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1783 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1784 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1786 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1787 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1789 application.GetScene().Add( imageView );
1791 // Trigger a potential relayout
1792 application.SendNotification();
1793 application.Render();
1795 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1796 Property::Map returnedMap;
1797 visual.CreatePropertyMap( returnedMap );
1799 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1800 DALI_TEST_CHECK( value );
1801 Property::Map* map = value->GetMap();
1802 DALI_TEST_CHECK( map );
1805 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1806 DALI_TEST_CHECK( value );
1807 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1809 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1810 DALI_TEST_CHECK( value );
1811 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1813 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1814 DALI_TEST_CHECK( value );
1815 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1820 int UtcDaliImageViewFittingModesCenter01(void)
1822 ToolkitTestApplication application;
1824 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1825 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1827 ImageView imageView = ImageView::New();
1828 Property::Map imageMap;
1829 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1830 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1831 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1833 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1834 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1836 application.GetScene().Add( imageView );
1838 // Trigger a potential relayout
1839 application.SendNotification();
1840 application.Render();
1842 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1843 Property::Map returnedMap;
1844 visual.CreatePropertyMap( returnedMap );
1846 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1847 DALI_TEST_CHECK( value );
1848 Property::Map* map = value->GetMap();
1849 DALI_TEST_CHECK( map );
1851 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1852 DALI_TEST_CHECK( value );
1853 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1855 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1856 DALI_TEST_CHECK( value );
1857 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1859 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1860 DALI_TEST_CHECK( value );
1861 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1866 int UtcDaliImageViewFittingModesCenter02(void)
1868 ToolkitTestApplication application;
1870 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1871 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1873 ImageView imageView = ImageView::New();
1874 Property::Map imageMap;
1875 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1876 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1877 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1879 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1880 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1882 application.GetScene().Add( imageView );
1884 // Trigger a potential relayout
1885 application.SendNotification();
1886 application.Render();
1888 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1889 Property::Map returnedMap;
1890 visual.CreatePropertyMap( returnedMap );
1892 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1893 DALI_TEST_CHECK( value );
1894 Property::Map* map = value->GetMap();
1895 DALI_TEST_CHECK( map );
1897 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1898 DALI_TEST_CHECK( value );
1899 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1901 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1902 DALI_TEST_CHECK( value );
1903 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1905 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1906 DALI_TEST_CHECK( value );
1907 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1912 int UtcDaliImageViewFittingModesFitHeight01(void)
1914 ToolkitTestApplication application;
1916 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1918 ImageView imageView = ImageView::New();
1919 Property::Map imageMap;
1920 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1921 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1922 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1924 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1925 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1927 application.GetScene().Add( imageView );
1929 // Trigger a potential relayout
1930 application.SendNotification();
1931 application.Render();
1933 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1934 Property::Map returnedMap;
1935 visual.CreatePropertyMap( returnedMap );
1937 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1938 DALI_TEST_CHECK( value );
1939 Property::Map* map = value->GetMap();
1940 DALI_TEST_CHECK( map );
1942 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1943 DALI_TEST_CHECK( value );
1944 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1946 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1947 DALI_TEST_CHECK( value );
1948 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1950 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1951 DALI_TEST_CHECK( value );
1952 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1957 int UtcDaliImageViewFittingModesFitHeight02(void)
1959 ToolkitTestApplication application;
1961 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1963 ImageView imageView = ImageView::New();
1964 Property::Map imageMap;
1965 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1966 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1967 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1969 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1970 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1972 application.GetScene().Add( imageView );
1974 // Trigger a potential relayout
1975 application.SendNotification();
1976 application.Render();
1978 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1979 Property::Map returnedMap;
1980 visual.CreatePropertyMap( returnedMap );
1982 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1983 DALI_TEST_CHECK( value );
1984 Property::Map* map = value->GetMap();
1985 DALI_TEST_CHECK( map );
1987 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1988 DALI_TEST_CHECK( value );
1989 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1991 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1992 DALI_TEST_CHECK( value );
1993 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1995 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1996 DALI_TEST_CHECK( value );
1997 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2002 int UtcDaliImageViewFittingModesFitWidth01(void)
2004 ToolkitTestApplication application;
2006 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
2008 ImageView imageView = ImageView::New();
2009 Property::Map imageMap;
2010 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2011 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
2012 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2014 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2015 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
2017 application.GetScene().Add( imageView );
2019 // Trigger a potential relayout
2020 application.SendNotification();
2021 application.Render();
2023 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2024 Property::Map returnedMap;
2025 visual.CreatePropertyMap( returnedMap );
2027 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2028 DALI_TEST_CHECK( value );
2029 Property::Map* map = value->GetMap();
2030 DALI_TEST_CHECK( map );
2032 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2033 DALI_TEST_CHECK( value );
2034 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2036 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2037 DALI_TEST_CHECK( value );
2038 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2040 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2041 DALI_TEST_CHECK( value );
2042 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
2047 int UtcDaliImageViewFittingModesFitWidth02(void)
2049 ToolkitTestApplication application;
2051 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
2053 ImageView imageView = ImageView::New();
2054 Property::Map imageMap;
2055 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2056 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
2057 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2059 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2060 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
2062 application.GetScene().Add( imageView );
2064 // Trigger a potential relayout
2065 application.SendNotification();
2066 application.Render();
2068 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2069 Property::Map returnedMap;
2070 visual.CreatePropertyMap( returnedMap );
2072 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2073 DALI_TEST_CHECK( value );
2074 Property::Map* map = value->GetMap();
2075 DALI_TEST_CHECK( map );
2077 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2078 DALI_TEST_CHECK( value );
2079 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2081 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2082 DALI_TEST_CHECK( value );
2083 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2085 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2086 DALI_TEST_CHECK( value );
2087 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2092 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2094 ToolkitTestApplication application;
2096 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2098 ImageView imageView = ImageView::New();
2100 // 1. Render using FittingMode::SHRINK_TO_FIT
2101 Property::Map imageMap;
2102 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2103 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2104 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2106 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2107 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2109 application.GetScene().Add( imageView );
2111 // Trigger a potential relayout
2112 application.SendNotification();
2113 application.Render();
2115 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2116 Property::Map returnedMap;
2117 visual.CreatePropertyMap( returnedMap );
2119 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2120 DALI_TEST_CHECK( value );
2121 Property::Map* map = value->GetMap();
2122 DALI_TEST_CHECK( map );
2124 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2125 DALI_TEST_CHECK( value );
2126 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2128 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2129 DALI_TEST_CHECK( value );
2130 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2132 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2133 DALI_TEST_CHECK( value );
2134 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2136 // 2. Render again using DevelVisaul::CENTER
2137 Property::Map imageMap2;
2138 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2139 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2140 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2142 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2143 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2145 application.GetScene().Add( imageView );
2147 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2149 // Trigger a potential relayout
2150 application.SendNotification();
2151 application.Render();
2153 returnedMap.Clear();
2154 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2156 visual.CreatePropertyMap( returnedMap );
2158 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2159 DALI_TEST_CHECK( value );
2160 map = value->GetMap();
2161 DALI_TEST_CHECK( map );
2163 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2164 DALI_TEST_CHECK( value );
2165 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2167 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2168 DALI_TEST_CHECK( value );
2169 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2171 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2172 DALI_TEST_CHECK( value );
2173 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2175 // 3. Render again using before fittingMode
2176 Property::Map imageMap3;
2177 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2178 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2179 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2181 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2182 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2184 application.GetScene().Add( imageView );
2186 // Trigger a potential relayout
2187 application.SendNotification();
2188 application.Render();
2190 returnedMap.Clear();
2191 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2192 visual.CreatePropertyMap( returnedMap );
2194 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2195 DALI_TEST_CHECK( value );
2196 map = value->GetMap();
2197 DALI_TEST_CHECK( map );
2199 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2200 DALI_TEST_CHECK( value );
2201 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2203 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2204 DALI_TEST_CHECK( value );
2205 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2207 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2208 DALI_TEST_CHECK( value );
2209 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2214 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2216 ToolkitTestApplication application;
2218 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2220 ImageView imageView = ImageView::New();
2222 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2223 Property::Map imageMap;
2224 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2225 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2226 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2228 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2229 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2231 application.GetScene().Add( imageView );
2233 // Trigger a potential relayout
2234 application.SendNotification();
2235 application.Render();
2237 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2238 Property::Map returnedMap;
2239 visual.CreatePropertyMap( returnedMap );
2241 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2242 DALI_TEST_CHECK( value );
2243 Property::Map* map = value->GetMap();
2244 DALI_TEST_CHECK( map );
2246 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2247 DALI_TEST_CHECK( value );
2248 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2250 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2251 DALI_TEST_CHECK( value );
2252 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2254 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2255 DALI_TEST_CHECK( value );
2256 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2258 // 2. Render again using DevelVisaul::CENTER
2259 Property::Map imageMap2;
2260 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2261 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2262 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2264 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2265 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2267 application.GetScene().Add( imageView );
2269 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2271 // Trigger a potential relayout
2272 application.SendNotification();
2273 application.Render();
2275 returnedMap.Clear();
2276 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2278 visual.CreatePropertyMap( returnedMap );
2280 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2281 DALI_TEST_CHECK( value );
2282 map = value->GetMap();
2283 DALI_TEST_CHECK( map );
2285 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2286 DALI_TEST_CHECK( value );
2287 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2289 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2290 DALI_TEST_CHECK( value );
2291 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2293 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2294 DALI_TEST_CHECK( value );
2295 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2297 // 3. Render again using before fittingMode
2298 Property::Map imageMap3;
2299 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2300 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2301 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2303 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2304 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2306 application.GetScene().Add( imageView );
2308 // Trigger a potential relayout
2309 application.SendNotification();
2310 application.Render();
2312 returnedMap.Clear();
2313 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2314 visual.CreatePropertyMap( returnedMap );
2316 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2317 DALI_TEST_CHECK( value );
2318 map = value->GetMap();
2319 DALI_TEST_CHECK( map );
2321 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2322 DALI_TEST_CHECK( value );
2323 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2325 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2326 DALI_TEST_CHECK( value );
2327 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2329 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2330 DALI_TEST_CHECK( value );
2331 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2336 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2338 ToolkitTestApplication application;
2340 tet_infoline( "Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )" );
2342 ImageView imageView = ImageView::New();
2343 Property::Map imageMap;
2344 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2345 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2347 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2348 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2350 application.GetScene().Add( imageView );
2352 // Trigger a potential relayout
2353 application.SendNotification();
2354 application.Render();
2356 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2357 Property::Map returnedMap;
2358 visual.CreatePropertyMap( returnedMap );
2360 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2361 DALI_TEST_CHECK( value );
2362 Property::Map* map = value->GetMap();
2363 DALI_TEST_CHECK( map );
2365 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2366 DALI_TEST_CHECK( value );
2367 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2369 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2370 DALI_TEST_CHECK( value );
2371 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2373 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2374 DALI_TEST_CHECK( value );
2375 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2381 int UtcDaliImageViewCustomShader(void)
2383 ToolkitTestApplication application;
2385 // Set a custom shader with an image url
2387 Property::Map properties;
2388 Property::Map shader;
2389 const std::string vertexShader = "Foobar";
2390 const std::string fragmentShader = "Foobar";
2391 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2392 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2394 properties[Visual::Property::TYPE] = Visual::IMAGE;
2395 properties[Visual::Property::SHADER] = shader;
2396 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2398 ImageView imageView = ImageView::New();
2399 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2401 application.GetScene().Add( imageView );
2403 application.SendNotification();
2404 application.Render();
2406 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2408 Renderer renderer = imageView.GetRendererAt( 0 );
2409 Shader shader2 = renderer.GetShader();
2410 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2411 Property::Map* map = value.GetMap();
2412 DALI_TEST_CHECK( map );
2414 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2415 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2417 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2418 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2421 // Set a custom shader after setting an image url
2423 Property::Map properties;
2424 Property::Map shader;
2425 const std::string vertexShader = "Foobar";
2426 const std::string fragmentShader = "Foobar";
2427 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2428 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2430 properties[Visual::Property::SHADER] = shader;
2432 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2433 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2435 application.GetScene().Add( imageView );
2437 application.SendNotification();
2438 application.Render();
2440 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2442 Renderer renderer = imageView.GetRendererAt( 0 );
2443 Shader shader2 = renderer.GetShader();
2444 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2445 Property::Map* map = value.GetMap();
2446 DALI_TEST_CHECK( map );
2448 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2449 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2451 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2452 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2455 // Set a custom shader before setting an image url
2457 Property::Map properties;
2458 Property::Map shader;
2459 const std::string vertexShader = "Foobar";
2460 const std::string fragmentShader = "Foobar";
2461 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2462 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2464 properties[Visual::Property::SHADER] = shader;
2466 ImageView imageView = ImageView::New();
2467 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2468 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2470 application.GetScene().Add( imageView );
2472 application.SendNotification();
2473 application.Render();
2474 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2476 Renderer renderer = imageView.GetRendererAt( 0 );
2477 Shader shader2 = renderer.GetShader();
2478 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2479 Property::Map* map = value.GetMap();
2480 DALI_TEST_CHECK( map );
2482 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2483 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2485 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2486 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2489 // Set a custom shader after setting a property map
2491 Property::Map properties;
2492 Property::Map shader;
2493 const std::string vertexShader = "Foobar";
2494 const std::string fragmentShader = "Foobar";
2495 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2496 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2498 properties[Visual::Property::SHADER] = shader;
2500 Property::Map properties1;
2501 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2502 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2504 ImageView imageView = ImageView::New();
2505 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2506 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2508 application.GetScene().Add( imageView );
2510 application.SendNotification();
2511 application.Render();
2512 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2514 Renderer renderer = imageView.GetRendererAt( 0 );
2515 Shader shader2 = renderer.GetShader();
2516 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2517 Property::Map* map = value.GetMap();
2518 DALI_TEST_CHECK( map );
2520 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2521 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2523 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2524 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2527 // Set a custom shader before setting a property map
2529 Property::Map properties;
2530 Property::Map shader;
2531 const std::string vertexShader = "Foobar";
2532 const std::string fragmentShader = "Foobar";
2533 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2534 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2536 properties[Visual::Property::SHADER] = shader;
2538 Property::Map properties1;
2539 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2540 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2542 ImageView imageView = ImageView::New();
2543 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2544 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2546 application.GetScene().Add( imageView );
2548 application.SendNotification();
2549 application.Render();
2550 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2552 Renderer renderer = imageView.GetRendererAt( 0 );
2553 Shader shader2 = renderer.GetShader();
2554 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2555 Property::Map* map = value.GetMap();
2556 DALI_TEST_CHECK( map );
2558 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2559 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2561 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2562 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2571 static int gFailCounter = 0;
2572 const int MAX_RETRIES(3);
2574 void ReloadImage(ImageView imageView)
2576 Property::Map imageImmediateLoadingMap;
2577 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2578 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2580 tet_infoline("Immediate load an image");
2581 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2584 void ResourceFailedReload( Control control )
2587 if( gFailCounter < MAX_RETRIES )
2589 ReloadImage(ImageView::DownCast(control));
2594 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2596 tet_infoline("Test reloading failed image from within signal handler.");
2598 ToolkitTestApplication application;
2602 ImageView imageView = ImageView::New();
2603 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2604 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2605 ReloadImage(imageView);
2607 // loading started, this waits for the loader thread to complete
2608 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2609 application.SendNotification();
2611 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2613 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2614 application.SendNotification();
2616 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2618 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2619 application.SendNotification();
2620 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2625 int UtcDaliImageViewLoadRemoteSVG(void)
2627 tet_infoline("Test load from a remote server.");
2629 ToolkitTestApplication application;
2630 Toolkit::ImageView imageView;
2631 imageView = Toolkit::ImageView::New();
2632 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2633 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2634 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2635 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2636 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2637 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2638 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2640 application.GetScene().Add( imageView );
2642 DALI_TEST_CHECK( imageView );
2644 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2646 application.SendNotification();
2648 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2650 application.SendNotification();
2651 application.Render();
2653 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2658 int UtcDaliImageViewSyncSVGLoading(void)
2660 ToolkitTestApplication application;
2662 tet_infoline("ImageView Testing SVG image sync loading");
2664 // Sync loading, automatic atlasing for small size image
2666 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2668 callStack.Enable(true);
2670 ImageView imageView = ImageView::New( );
2672 // Sync loading is used
2673 Property::Map syncLoadingMap;
2674 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2675 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2676 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2677 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2679 application.GetScene().Add( imageView );
2680 DALI_TEST_CHECK( imageView );
2682 application.SendNotification();
2683 application.Render(16);
2684 Vector3 naturalSize = imageView.GetNaturalSize();
2686 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2687 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2693 int UtcDaliImageViewAsyncSVGLoading(void)
2695 ToolkitTestApplication application;
2697 tet_infoline("ImageView Testing SVG image async loading");
2699 // Sync loading, automatic atlasing for small size image
2701 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2703 callStack.Enable(true);
2705 ImageView imageView = ImageView::New( );
2707 // Sync loading is used
2708 Property::Map syncLoadingMap;
2709 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2710 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2711 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2712 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2714 application.GetScene().Add( imageView );
2715 DALI_TEST_CHECK( imageView );
2717 application.SendNotification();
2718 application.Render(16);
2719 Vector3 naturalSize = imageView.GetNaturalSize();
2721 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2722 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2727 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2729 ToolkitTestApplication application;
2731 tet_infoline("ImageView Testing SVG image async loading");
2733 // Sync loading, automatic atlasing for small size image
2735 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2737 callStack.Enable(true);
2739 ImageView imageView = ImageView::New( );
2741 // Sync loading is used
2742 Property::Map syncLoadingMap;
2743 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2744 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2746 // Check to set invalid value
2747 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2748 // Check if error log is outputted when setting other value like string.
2749 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2750 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2751 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2753 application.GetScene().Add( imageView );
2754 DALI_TEST_CHECK( imageView );
2756 application.SendNotification();
2757 application.Render(16);
2758 Vector3 naturalSize = imageView.GetNaturalSize();
2759 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2760 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2762 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2763 Property::Map* map = value.GetMap();
2764 DALI_TEST_CHECK( map );
2766 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2767 DALI_TEST_CHECK( sync );
2768 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2774 int UtcDaliImageViewSvgLoadingFailure(void)
2776 ToolkitTestApplication application;
2778 // Local svg file - invalid file path
2780 gResourceReadySignalFired = false;
2782 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/foo.svg" );
2783 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2784 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2786 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2788 application.GetScene().Add( imageView );
2790 application.SendNotification();
2791 application.Render(16);
2793 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2794 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2795 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2798 // Local svg file - invalid file
2800 gResourceReadySignalFired = false;
2802 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/invalid.svg" );
2803 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2804 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2806 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2808 application.GetScene().Add( imageView );
2810 application.SendNotification();
2811 application.Render(16);
2813 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2814 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2815 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2820 gResourceReadySignalFired = false;
2822 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2823 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2824 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2826 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2828 application.GetScene().Add( imageView );
2830 application.SendNotification();
2832 // loading started, this waits for the loader thread
2833 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2835 application.SendNotification();
2836 application.Render(16);
2838 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2839 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2840 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2846 int UtcDaliImageViewSvgRasterizationFailure(void)
2848 ToolkitTestApplication application;
2850 gResourceReadySignalFired = false;
2852 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/svg1.svg" );
2853 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2854 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2856 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2858 application.GetScene().Add( imageView );
2860 application.SendNotification();
2862 // loading started, this waits for the loader thread
2863 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2865 application.SendNotification();
2866 application.Render(16);
2868 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2869 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2870 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::READY, TEST_LOCATION );
2873 gResourceReadySignalFired = false;
2876 imageView.SetProperty( Actor::Property::SIZE, Vector2( 0.f, 0.f ) );
2878 application.SendNotification();
2880 // rasterization started, this waits for the rasterize thread
2881 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2883 application.SendNotification();
2884 application.Render(16);
2886 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2887 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2888 // Fail to rasterize because the size is 0.
2889 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2894 int UtcDaliImageViewTVGLoading(void)
2896 ToolkitTestApplication application;
2898 tet_infoline("ImageView Testing TVG image loading");
2901 ImageView imageView = ImageView::New( );
2903 imageView.SetImage( TEST_RESOURCE_DIR "/test.tvg" );
2905 application.GetScene().Add( imageView );
2906 DALI_TEST_CHECK( imageView );
2907 Vector3 naturalSize = imageView.GetNaturalSize();
2909 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2910 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2914 int UtcDaliImageViewImageLoadFailure01(void)
2916 ToolkitTestApplication application;
2918 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2919 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
2920 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2921 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2923 std::string brokenUrl;
2924 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2925 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
2927 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2928 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2930 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2931 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2933 ImageView imageView = ImageView::New("invalidUrl.png");
2934 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2936 application.GetScene().Add( imageView );
2937 application.SendNotification();
2938 application.Render(16);
2940 // loading started, this waits for the loader thread
2941 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2946 int UtcDaliImageViewImageLoadFailure02(void)
2948 ToolkitTestApplication application;
2950 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2951 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
2952 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2953 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2955 std::string brokenUrl;
2956 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2957 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
2959 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2960 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2962 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2963 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2965 ImageView imageView = ImageView::New("invalidUrl.png");
2966 imageView.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 30.f ) );
2967 application.GetScene().Add( imageView );
2968 application.SendNotification();
2969 application.Render(16);
2971 // loading started, this waits for the loader thread
2972 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2977 int UtcDaliImageViewImageLoadFailure03(void)
2979 ToolkitTestApplication application;
2981 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2982 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
2983 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
2985 std::string brokenUrl;
2986 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2987 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
2989 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2990 DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
2992 ImageView imageView = ImageView::New("invalidUrl.png");
2993 imageView.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2994 application.GetScene().Add( imageView );
2995 application.SendNotification();
2996 application.Render(16);
2998 // loading started, this waits for the loader thread
2999 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3007 static int gResourceReadySignalCounter = 0;
3009 void OnResourceReadySignal01( Control control )
3011 gResourceReadySignalCounter++;
3013 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3015 if( gResourceReadySignalCounter == 1 )
3018 // It makes the first new visual be deleted immediately
3019 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
3020 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
3023 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3025 // Make the resource ready immediately
3026 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
3030 void OnResourceReadySignal02( Control control )
3032 if(++gResourceReadySignalCounter == 1)
3034 // It makes the first new visual be deleted immediately
3035 // The first image will not be loaded.
3036 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
3037 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3038 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3042 ImageView gImageView1;
3043 ImageView gImageView2;
3044 ImageView gImageView3;
3046 void OnResourceReadySignal03( Control control )
3048 if(gResourceReadySignalCounter == 0)
3051 // 1. Use cached image, then UploadComplete will be called right after OnResourceReadySignal03.
3052 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3054 // 2. Load a new image
3055 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3057 // 3. Use the new image again
3058 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3059 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3061 else if(gResourceReadySignalCounter == 1)
3063 // This is called from TextureManager::ProcessQueuedTextures().
3064 gImageView1.Unparent();
3065 gImageView1.Reset();
3067 gResourceReadySignalCounter++;
3072 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3074 tet_infoline("Test setting image from within signal handler.");
3076 ToolkitTestApplication application;
3078 gResourceReadySignalCounter = 0;
3080 ImageView imageView = ImageView::New( gImage_34_RGBA );
3081 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
3083 application.GetScene().Add( imageView );
3085 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3087 application.SendNotification();
3088 application.Render();
3090 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3092 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3095 gResourceReadySignalCounter = 0;
3097 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3099 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3101 application.SendNotification();
3102 application.Render();
3104 // Run idle callback
3105 application.RunIdles();
3107 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3109 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3114 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3116 tet_infoline("Test setting image from within signal handler.");
3118 ToolkitTestApplication application;
3120 gResourceReadySignalCounter = 0;
3122 ImageView imageView = ImageView::New( gImage_34_RGBA );
3123 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal02 );
3125 application.GetScene().Add( imageView );
3127 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3129 application.SendNotification();
3130 application.Render();
3132 // Wait for loading an image
3133 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3135 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
3137 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
3142 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3144 tet_infoline("Test setting image from within signal handler.");
3146 ToolkitTestApplication application;
3148 gResourceReadySignalCounter = 0;
3150 gImageView1 = ImageView::New(gImage_34_RGBA);
3151 application.GetScene().Add(gImageView1);
3154 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3156 gImageView2 = ImageView::New(gImage_600_RGB);
3157 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3158 application.GetScene().Add(gImageView2);
3160 gImageView3 = ImageView::New();
3161 application.GetScene().Add(gImageView3);
3163 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3165 application.SendNotification();
3166 application.Render();