2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Need to override adaptor classes for toolkit test harness, so include
19 // test harness headers before dali headers.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/devel-api/scripting/scripting.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
27 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
28 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
29 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
30 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
32 #include <test-native-image.h>
37 #include "dummy-control.h"
40 using namespace Toolkit;
42 void utc_dali_toolkit_image_view_startup(void)
44 test_return_value = TET_UNDEF;
47 void utc_dali_toolkit_image_view_cleanup(void)
49 test_return_value = TET_PASS;
55 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
56 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
58 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
59 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
61 // resolution: 34*34, pixel format: RGBA8888
62 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
63 // resolution: 600*600, pixel format: RGB888
64 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
66 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
67 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
69 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
71 void TestUrl( ImageView imageView, const std::string url )
73 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
75 std::string urlActual;
76 DALI_TEST_CHECK( value.Get( urlActual ) );
77 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
82 int UtcDaliImageViewNewP(void)
84 ToolkitTestApplication application;
86 ImageView imageView = ImageView::New();
88 DALI_TEST_CHECK( imageView );
93 int UtcDaliImageViewNewUrlP(void)
95 ToolkitTestApplication application;
97 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
98 DALI_TEST_CHECK( imageView );
100 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
105 int UtcDaliImageViewConstructorP(void)
107 ToolkitTestApplication application;
111 DALI_TEST_CHECK( !imageView );
116 int UtcDaliImageViewCopyConstructorP(void)
118 ToolkitTestApplication application;
120 // Initialize an object, ref count == 1
121 ImageView imageView = ImageView::New();
123 ImageView copy( imageView );
124 DALI_TEST_CHECK( copy );
129 int UtcDaliImageViewAssignmentOperatorP(void)
131 ToolkitTestApplication application;
133 ImageView imageView = ImageView::New();
135 ImageView copy( imageView );
136 DALI_TEST_CHECK( copy );
137 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
142 int UtcDaliImageViewDownCastP(void)
144 ToolkitTestApplication application;
146 ImageView imageView = ImageView::New();
148 BaseHandle object(imageView);
150 ImageView imageView2 = ImageView::DownCast( object );
151 DALI_TEST_CHECK(imageView2);
153 ImageView imageView3 = DownCast< ImageView >( object );
154 DALI_TEST_CHECK(imageView3);
159 int UtcDaliImageViewDownCastN(void)
161 ToolkitTestApplication application;
163 BaseHandle unInitializedObject;
165 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
166 DALI_TEST_CHECK( !imageView1 );
168 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
169 DALI_TEST_CHECK( !imageView2 );
174 int UtcDaliImageViewTypeRegistry(void)
176 ToolkitTestApplication application;
178 TypeRegistry typeRegistry = TypeRegistry::Get();
179 DALI_TEST_CHECK( typeRegistry );
181 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
182 DALI_TEST_CHECK( typeInfo );
184 BaseHandle handle = typeInfo.CreateInstance();
185 DALI_TEST_CHECK( handle );
187 ImageView imageView = ImageView::DownCast( handle );
188 DALI_TEST_CHECK( imageView );
193 int UtcDaliImageViewSetGetProperty01(void)
195 ToolkitTestApplication application;
197 ImageView imageView = ImageView::New();
199 Property::Index idx = imageView.GetPropertyIndex( "image" );
200 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
202 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
203 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
208 int UtcDaliImageViewPreMultipliedAlphaPng(void)
210 ToolkitTestApplication application;
212 // Set up trace debug
213 TestGlAbstraction& gl = application.GetGlAbstraction();
214 TraceCallStack& textureTrace = gl.GetTextureTrace();
215 textureTrace.Enable( true );
217 Property::Map imageMap;
218 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
219 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
221 ImageView imageView1 = ImageView::New();
222 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
224 application.GetScene().Add( imageView1 );
226 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
228 DALI_TEST_CHECK( value.Get( enable ) );
229 DALI_TEST_CHECK( enable ); // Default value is true
231 // loading started, this waits for the loader thread for max 30 seconds
232 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
234 application.SendNotification();
235 application.Render();
237 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
238 DALI_TEST_CHECK( value.Get( enable ) );
239 DALI_TEST_CHECK( enable ); // Keep true
241 // conventional alpha blending
242 Renderer renderer1 = imageView1.GetRendererAt( 0 );
243 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
244 DALI_TEST_CHECK( value.Get( enable ) );
245 DALI_TEST_CHECK( enable );
247 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
248 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
249 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
250 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
251 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
252 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
253 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
254 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
256 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
257 textureTrace.Reset();
259 // Disable pre-multiplied alpha blending
260 imageView1.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
263 Property::Map attributes;
264 DevelControl::DoAction( imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes );
266 // loading started, this waits for the loader thread for max 30 seconds
267 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
269 application.SendNotification();
270 application.Render();
272 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
273 DALI_TEST_CHECK( value.Get( enable ) );
274 DALI_TEST_CHECK( !enable );
276 // conventional alpha blending
277 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
278 DALI_TEST_CHECK( value.Get( enable ) );
279 DALI_TEST_CHECK( !enable );
281 srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
282 destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
283 srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
284 destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
285 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
286 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
287 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
288 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
290 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
291 textureTrace.Reset();
293 // Make a new ImageView using the same image
294 ImageView imageView2 = ImageView::New();
295 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
297 application.GetScene().Add( imageView2 );
299 application.SendNotification();
300 application.Render();
302 Renderer renderer2 = imageView2.GetRendererAt( 0 );
303 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
304 DALI_TEST_CHECK( value.Get( enable ) );
305 DALI_TEST_CHECK( enable );
307 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
308 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
309 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
310 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
311 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
312 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
313 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
314 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
316 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
321 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
323 ToolkitTestApplication application;
325 // Set up trace debug
326 TestGlAbstraction& gl = application.GetGlAbstraction();
327 TraceCallStack& textureTrace = gl.GetTextureTrace();
328 textureTrace.Enable( true );
330 Property::Map imageMap;
331 imageMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
332 imageMap[ ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
334 ImageView imageView1 = ImageView::New();
335 imageView1.SetProperty( ImageView::Property::IMAGE, imageMap );
337 application.GetScene().Add( imageView1 );
339 Property::Value value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
341 DALI_TEST_CHECK( value.Get( enable ) );
342 DALI_TEST_CHECK( enable ); // Default value is true
344 // loading started, this waits for the loader thread for max 30 seconds
345 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
347 application.SendNotification();
348 application.Render();
350 value = imageView1.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
351 DALI_TEST_CHECK( value.Get( enable ) );
352 DALI_TEST_CHECK( !enable ); // Should be false after loading
354 // conventional alpha blending
355 Renderer renderer1 = imageView1.GetRendererAt( 0 );
356 value = renderer1.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
357 DALI_TEST_CHECK( value.Get( enable ) );
358 DALI_TEST_CHECK( !enable );
360 int srcFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
361 int destFactorRgb = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
362 int srcFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
363 int destFactorAlpha = renderer1.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
364 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
365 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
366 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
367 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
369 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); // A new texture should be generated.
370 textureTrace.Reset();
372 ImageView imageView2 = ImageView::New();
373 imageView2.SetProperty( ImageView::Property::IMAGE, imageMap );
375 // Disable pre-multiplied alpha blending
376 imageView2.SetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA, false );
378 application.GetScene().Add( imageView2 );
380 application.SendNotification();
381 application.Render();
383 value = imageView2.GetProperty( ImageView::Property::PRE_MULTIPLIED_ALPHA );
384 DALI_TEST_CHECK( value.Get( enable ) );
385 DALI_TEST_CHECK( !enable );
387 // conventional alpha blending
388 Renderer renderer2 = imageView2.GetRendererAt( 0 );
389 value = renderer2.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
390 DALI_TEST_CHECK( value.Get( enable ) );
391 DALI_TEST_CHECK( !enable );
393 srcFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
394 destFactorRgb = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
395 srcFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
396 destFactorAlpha = renderer2.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
397 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
398 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
399 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
400 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
402 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); // The cached texture should be used.
407 int UtcDaliImageViewPixelArea(void)
409 // Test pixel area property
410 ToolkitTestApplication application;
412 // Gif image, use AnimatedImageVisual internally
413 // Atlasing is applied to pack multiple frames, use custom wrap mode
414 ImageView gifView = ImageView::New();
415 const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
416 gifView.SetProperty( ImageView::Property::IMAGE,
417 Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
418 .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
421 Integration::Scene stage = application.GetScene();
422 stage.Add( gifView );
425 application.SendNotification();
426 application.Render(16);
428 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
430 application.SendNotification();
431 application.Render();
432 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
434 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
435 // test that the pixel area value defined in the visual property map is registered on renderer
436 Renderer renderer = gifView.GetRendererAt(0);
437 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
438 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
440 // test that the shader has the default pixel area value registered.
441 Shader shader = renderer.GetShader();
442 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
443 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
445 // test that the uniform uses the pixelArea property on the renderer.
446 TestGlAbstraction& gl = application.GetGlAbstraction();
447 Vector4 pixelAreaUniform;
448 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
449 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
451 // set the pixelArea property on the control
452 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
453 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
454 application.SendNotification();
455 application.Render(16);
457 // check the pixelArea property on the control
458 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
459 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
460 // test that the uniform uses the pixelArea property on the control.
461 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
462 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
468 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
470 ToolkitTestApplication application;
471 TestGlAbstraction& gl = application.GetGlAbstraction();
472 const std::vector<GLuint>& textures = gl.GetBoundTextures();
473 size_t numTextures = textures.size();
475 // Async loading, no atlasing for big size image
476 ImageView imageView = ImageView::New( gImage_600_RGB );
478 // By default, Aysnc loading is used
479 application.GetScene().Add( imageView );
480 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
481 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
483 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
485 application.SendNotification();
486 application.Render(16);
487 application.SendNotification();
489 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
490 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
497 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
499 ToolkitTestApplication application;
501 //Async loading, automatic atlasing for small size image
502 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
504 callStack.Enable(true);
506 Property::Map imageMap;
508 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
509 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
510 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
511 imageMap[ ImageVisual::Property::ATLASING] = true;
513 ImageView imageView = ImageView::New();
514 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
515 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
517 // By default, Aysnc loading is used
518 // loading is not started if the actor is offStage
520 application.GetScene().Add( imageView );
521 application.SendNotification();
522 application.Render(16);
523 application.Render(16);
524 application.SendNotification();
526 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
527 application.SendNotification();
528 application.Render(16);
529 application.Render(16);
530 application.SendNotification();
532 // loading started, this waits for the loader thread for max 30 seconds
533 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
535 application.SendNotification();
536 application.Render(16);
538 callStack.Enable(false);
540 TraceCallStack::NamedParams params;
541 params["width"] = ToString(34);
542 params["height"] = ToString(34);
543 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
548 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
550 ToolkitTestApplication application;
552 //Async loading, automatic atlasing for small size image
553 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
555 callStack.Enable(true);
557 Property::Map asyncLoadingMap;
558 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
559 asyncLoadingMap[ "desiredHeight" ] = 34;
560 asyncLoadingMap[ "desiredWidth" ] = 34;
561 asyncLoadingMap[ "synchronousLoading" ] = false;
562 asyncLoadingMap[ "atlasing" ] = true;
564 ImageView imageView = ImageView::New();
565 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
567 application.GetScene().Add( imageView );
568 application.SendNotification();
569 application.Render(16);
570 application.Render(16);
571 application.SendNotification();
573 // loading started, this waits for the loader thread for max 30 seconds
574 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
576 application.SendNotification();
577 application.Render(16);
579 callStack.Enable(false);
581 TraceCallStack::NamedParams params;
582 params["width"] = ToString(34);
583 params["height"] = ToString(34);
584 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
589 int UtcDaliImageViewSyncLoading(void)
591 ToolkitTestApplication application;
593 tet_infoline("ImageView Testing sync loading and size using index key property map");
595 Property::Map syncLoadingMap;
596 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
597 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
599 // Sync loading, no atlasing for big size image
601 ImageView imageView = ImageView::New();
603 // Sync loading is used
604 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
605 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
608 // Sync loading, automatic atlasing for small size image
610 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
612 callStack.Enable(true);
614 ImageView imageView = ImageView::New( );
616 // Sync loading is used
617 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
618 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
619 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
620 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
622 application.GetScene().Add( imageView );
623 application.SendNotification();
624 application.Render(16);
626 TraceCallStack::NamedParams params;
627 params["width"] = ToString(34);
628 params["height"] = ToString(34);
629 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
630 true, TEST_LOCATION );
635 int UtcDaliImageViewSyncLoading02(void)
637 ToolkitTestApplication application;
639 tet_infoline("ImageView Testing sync loading and size using string key property map");
641 // Sync loading, automatic atlasing for small size image
643 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
645 callStack.Enable(true);
647 ImageView imageView = ImageView::New( );
649 // Sync loading is used
650 Property::Map syncLoadingMap;
651 syncLoadingMap[ "url" ] = gImage_34_RGBA;
652 syncLoadingMap[ "desiredHeight" ] = 34;
653 syncLoadingMap[ "desiredWidth" ] = 34;
654 syncLoadingMap[ "synchronousLoading" ] = true;
655 syncLoadingMap[ "atlasing" ] = true;
656 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
658 application.GetScene().Add( imageView );
659 application.SendNotification();
660 application.Render(16);
662 TraceCallStack::NamedParams params;
663 params["width"] = ToString(34);
664 params["height"] = ToString(34);
665 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
666 true, TEST_LOCATION );
671 int UtcDaliImageViewAddedTexture(void)
673 ToolkitTestApplication application;
675 tet_infoline("ImageView Testing image view with texture provided manager url");
677 ImageView imageView = ImageView::New();
679 // empty texture is ok, though pointless from app point of view
681 std::string url = TextureManager::AddTexture(empty);
682 DALI_TEST_CHECK(url.size() > 0u);
684 Property::Map propertyMap;
685 propertyMap[ImageVisual::Property::URL] = url;
686 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
688 application.GetScene().Add( imageView );
689 application.SendNotification();
690 application.Render();
695 int UtcDaliImageViewSizeWithBackground(void)
697 ToolkitTestApplication application;
701 ImageView imageView = ImageView::New();
703 imageView.SetProperty( Control::Property::BACKGROUND,
705 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
706 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
707 { ImageVisual::Property::DESIRED_WIDTH, width },
708 { ImageVisual::Property::DESIRED_HEIGHT, height },
712 application.GetScene().Add( imageView );
713 application.SendNotification();
714 application.Render();
716 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
717 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
722 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
724 ToolkitTestApplication application;
726 int widthBackground = 100;
727 int heightBackground = 200;
731 ImageView imageView = ImageView::New();
733 imageView.SetProperty( Control::Property::BACKGROUND,
735 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
736 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
737 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
738 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
742 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
744 application.GetScene().Add( imageView );
745 application.SendNotification();
746 application.Render();
748 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
749 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
754 int UtcDaliImageViewHeightForWidthBackground(void)
756 ToolkitTestApplication application;
758 int widthBackground = 100;
759 int heightBackground = 200;
761 ImageView imageView = ImageView::New();
763 imageView.SetProperty( Control::Property::BACKGROUND,
765 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
766 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
767 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
768 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
772 application.GetScene().Add( imageView );
773 application.SendNotification();
774 application.Render();
776 Control control = Control::DownCast( imageView );
777 DALI_TEST_CHECK( control );
778 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
779 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
784 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
786 ToolkitTestApplication application;
788 int widthBackground = 100;
789 int heightBackground = 200;
793 ImageView imageView = ImageView::New();
795 imageView.SetProperty( Control::Property::BACKGROUND,
797 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
798 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
799 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
800 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
804 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
806 application.GetScene().Add( imageView );
807 application.SendNotification();
808 application.Render();
810 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
811 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
816 int UtcDaliImageViewSetImageUrl(void)
818 ToolkitTestApplication application;
820 ImageView imageView = ImageView::New();
821 imageView.SetImage( TEST_IMAGE_FILE_NAME );
822 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
825 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
826 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
831 bool gResourceReadySignalFired = false;
832 Vector3 gNaturalSize;
834 void ResourceReadySignal( Control control )
836 gResourceReadySignalFired = true;
839 int UtcDaliImageViewCheckResourceReady(void)
841 ToolkitTestApplication application;
843 gResourceReadySignalFired = false;
845 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
846 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
848 imageView.SetProperty( Control::Property::BACKGROUND,
850 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
851 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
852 { ImageVisual::Property::DESIRED_WIDTH, 100 },
853 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
857 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
859 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
861 application.GetScene().Add( imageView );
863 // loading started, this waits for the loader thread
864 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
866 application.SendNotification();
867 application.Render(16);
869 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
871 application.SendNotification();
872 application.Render();
874 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
876 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
881 int UtcDaliImageViewSetImageTypeChangesP(void)
883 ToolkitTestApplication application;
885 ImageView imageView = ImageView::New();
886 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
888 application.GetScene().Add( imageView );
892 Toolkit::Visual::Base visual;
894 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
895 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
897 application.SendNotification();
898 application.Render( 16 );
900 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
902 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
903 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
906 imageView.SetImage( "TEST_URL" );
908 application.SendNotification();
909 application.Render( 16 );
911 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
912 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
914 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
915 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
916 DALI_TEST_CHECK( visual ); // Visual should be valid
919 imageView.SetImage( "" );
921 application.SendNotification();
922 application.Render( 16 );
924 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
925 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
927 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
929 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
930 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
932 // Set a URL in property map
933 Property::Map propertyMap;
934 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
935 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
937 application.SendNotification();
938 application.Render( 16 );
940 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
941 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
943 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
944 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
945 DALI_TEST_CHECK( visual ); // Visual should be valid
947 // Set a URL in property map again
948 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
949 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
951 application.SendNotification();
952 application.Render( 16 );
954 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
955 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
957 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
958 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
959 DALI_TEST_CHECK( visual ); // Visual should be valid
961 // Set an empty URL in property map
962 propertyMap[ImageVisual::Property::URL] = std::string();
963 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
965 application.SendNotification();
966 application.Render( 16 );
968 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
969 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
971 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
972 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
973 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
978 int UtcDaliImageViewResourceUrlP(void)
980 ToolkitTestApplication application;
982 ImageView imageView = ImageView::New();
983 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
985 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
986 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
991 int UtcDaliImageViewReplaceImage(void)
993 ToolkitTestApplication application;
995 gResourceReadySignalFired = false;
997 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
998 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1000 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
1002 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1004 application.GetScene().Add( imageView );
1006 application.SendNotification();
1007 application.Render(16);
1009 // loading started, this waits for the loader thread for max 30 seconds
1010 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1012 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1014 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1016 gResourceReadySignalFired = false;
1018 imageView.SetImage(TEST_IMAGE_2);
1020 application.SendNotification();
1021 application.Render(16);
1023 // loading started, this waits for the loader thread for max 30 seconds
1024 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1026 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1028 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1030 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1035 void OnRelayoutOverride( Size size )
1037 gNaturalSize = size; // Size Relayout is using
1040 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1042 ToolkitTestApplication application;
1044 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1045 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1046 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1048 DummyControl dummyControl = DummyControl::New( true );
1049 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1050 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1052 dummyControl.Add( imageView );
1053 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1054 application.GetScene().Add( dummyControl );
1056 application.SendNotification();
1057 application.Render();
1059 // loading started, this waits for the loader thread for max 30 seconds
1060 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1062 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1063 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1065 gNaturalSize = Vector3::ZERO;
1067 imageView.SetImage(gImage_600_RGB);
1069 // Waiting for resourceReady so SendNotifcation not called here.
1071 // loading started, this waits for the loader thread for max 30 seconds
1072 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1074 // Trigger a potential relayout
1075 application.SendNotification();
1076 application.Render();
1078 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1079 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1084 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1086 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1088 ToolkitTestApplication application;
1090 gResourceReadySignalFired = false;
1092 Property::Map imageMap;
1094 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1095 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1097 tet_infoline("Creating ImageView without URL so image does not start loading");
1098 ImageView imageView = ImageView::New();
1099 tet_infoline("Connect to image loaded signal before setting image");
1100 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1101 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1102 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1104 // loading started, this waits for the loader thread
1105 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1107 application.SendNotification();
1108 application.Render(16);
1110 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1115 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1117 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1119 ToolkitTestApplication application;
1121 gResourceReadySignalFired = false;
1123 Property::Map imageMap;
1125 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1126 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1128 ImageView imageView = ImageView::New();
1129 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1130 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1132 // loading started, this waits for the loader thread
1133 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1135 application.SendNotification();
1136 application.Render(16);
1138 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1139 gResourceReadySignalFired = false;
1141 ImageView imageViewWithExistingImage = ImageView::New();
1142 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1143 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1145 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1150 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1152 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1154 ToolkitTestApplication application;
1156 gResourceReadySignalFired = false;
1158 Property::Map imageImmediateLoadingMap;
1159 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1160 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1162 tet_infoline("Immediate load an image");
1163 ImageView imageView = ImageView::New();
1164 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1165 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1167 // loading started, this waits for the loader thread
1168 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1170 application.SendNotification();
1171 application.Render(16);
1173 tet_infoline("Check image loaded");
1174 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1175 gResourceReadySignalFired = false;
1177 tet_infoline("Create another ImageView with the same URL");
1178 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1179 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1180 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1182 application.GetScene().Add( imageViewWithExistingImage );
1184 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1189 int UtcDaliImageViewPaddingProperty(void)
1191 ToolkitTestApplication application;
1193 ImageView imageView = ImageView::New();
1194 Property::Map imagePropertyMap;
1195 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1196 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1197 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1198 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1199 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1200 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1201 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1202 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1203 application.GetScene().Add( imageView );
1205 application.SendNotification();
1206 application.Render();
1208 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1210 ImageView childImage = ImageView::New();
1211 childImage.SetBackgroundColor( Color::BLACK );
1212 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1213 imageView.Add( childImage );
1215 application.SendNotification();
1216 application.Render();
1218 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1219 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1221 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1222 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1223 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1224 Property::Map resultMap;
1225 imageVisual.CreatePropertyMap( resultMap );
1227 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1228 DALI_TEST_CHECK( transformValue );
1229 Property::Map* retMap = transformValue->GetMap();
1230 DALI_TEST_CHECK( retMap );
1232 // Image Visual should be positioned depending on ImageView's padding
1233 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1238 int UtcDaliImageViewPaddingProperty02(void)
1240 ToolkitTestApplication application;
1242 ImageView imageView = ImageView::New();
1243 Property::Map imagePropertyMap;
1244 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1245 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1246 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1247 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1248 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1249 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1250 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1251 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1252 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1253 application.GetScene().Add( imageView );
1255 application.SendNotification();
1256 application.Render();
1258 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1260 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1261 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1262 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1263 Property::Map resultMap;
1264 imageVisual.CreatePropertyMap( resultMap );
1266 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1267 DALI_TEST_CHECK( transformValue );
1268 Property::Map* retMap = transformValue->GetMap();
1269 DALI_TEST_CHECK( retMap );
1271 // Image Visual should be positioned depending on ImageView's padding
1272 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1277 int UtcDaliImageViewPaddingProperty03(void)
1279 tet_infoline("Test Setting Image Padding then removing it.");
1281 ToolkitTestApplication application;
1283 ImageView imageView = ImageView::New();
1284 Property::Map imagePropertyMap;
1285 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1286 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1287 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1288 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1289 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1290 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1291 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1292 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1293 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1294 application.GetScene().Add( imageView );
1296 application.SendNotification();
1297 application.Render();
1299 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1301 tet_infoline("Remove Padding and test Visual is position correctly");
1303 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1305 application.SendNotification();
1306 application.Render();
1308 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1309 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1310 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1311 Property::Map resultMap;
1312 imageVisual.CreatePropertyMap( resultMap );
1314 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1315 DALI_TEST_CHECK( transformValue );
1316 Property::Map* retMap = transformValue->GetMap();
1317 DALI_TEST_CHECK( retMap );
1319 // Image Visual should be positioned depending on ImageView's padding
1320 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1325 int UtcDaliImageViewPaddingProperty04(void)
1327 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1329 ToolkitTestApplication application;
1331 ImageView imageView = ImageView::New();
1332 Property::Map imagePropertyMap;
1333 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1334 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1335 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1336 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1337 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1338 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1339 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1340 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1341 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1342 application.GetScene().Add( imageView );
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1349 tet_infoline("Remove Padding and test Visual is position correctly");
1351 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1353 application.SendNotification();
1354 application.Render();
1356 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1357 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1358 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1359 Property::Map resultMap;
1360 imageVisual.CreatePropertyMap( resultMap );
1362 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1363 DALI_TEST_CHECK( transformValue );
1364 Property::Map* retMap = transformValue->GetMap();
1365 DALI_TEST_CHECK( retMap );
1367 // Image Visual should be positioned depending on ImageView's padding
1368 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1373 int UtcDaliImageViewTransformTest01(void)
1375 tet_infoline("Test Setting a offset transform on the ImageView");
1377 ToolkitTestApplication application;
1379 ImageView imageView = ImageView::New();
1380 Property::Map imagePropertyMap;
1381 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1382 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1383 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1384 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1385 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1386 .Add( Visual::Property::TRANSFORM,
1387 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1388 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1389 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1391 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1392 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1393 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1394 application.GetScene().Add( imageView );
1396 application.SendNotification();
1397 application.Render();
1399 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1400 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1401 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1402 Property::Map resultMap;
1403 imageVisual.CreatePropertyMap( resultMap );
1405 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1406 DALI_TEST_CHECK( transformValue );
1407 Property::Map* retMap = transformValue->GetMap();
1408 DALI_TEST_CHECK( retMap );
1410 // Image Visual should be positioned depending on ImageView's padding
1411 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1412 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 );
1417 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1419 ToolkitTestApplication application;
1421 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1422 ImageView imageView = ImageView::New();
1423 Property::Map imageMap;
1424 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1425 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1426 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1427 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1428 application.GetScene().Add( imageView );
1430 // Trigger a potential relayout
1431 application.SendNotification();
1432 application.Render();
1434 Vector3 naturalSize = imageView.GetNaturalSize();
1436 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1437 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1442 int UtcDaliImageViewFillMode(void)
1444 ToolkitTestApplication application;
1446 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1448 ImageView imageView = ImageView::New();
1449 Property::Map imageMap;
1450 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1451 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1452 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1454 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1456 application.GetScene().Add( imageView );
1458 // Trigger a potential relayout
1459 application.SendNotification();
1460 application.Render();
1462 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1463 Property::Map returnedMap;
1464 visual.CreatePropertyMap( returnedMap );
1466 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1467 DALI_TEST_CHECK( value );
1468 Property::Map* map = value->GetMap();
1469 DALI_TEST_CHECK( map );
1471 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1472 DALI_TEST_CHECK( value );
1473 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1475 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1476 DALI_TEST_CHECK( value );
1477 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1482 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1484 ToolkitTestApplication application;
1486 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1487 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1489 ImageView imageView = ImageView::New();
1490 Property::Map imageMap;
1491 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1492 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1493 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1495 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1496 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1498 application.GetScene().Add( imageView );
1500 // Trigger a potential relayout
1501 application.SendNotification();
1502 application.Render();
1504 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1505 Property::Map returnedMap;
1506 visual.CreatePropertyMap( returnedMap );
1508 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1509 DALI_TEST_CHECK( value );
1510 Property::Map* map = value->GetMap();
1511 DALI_TEST_CHECK( map );
1514 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1515 DALI_TEST_CHECK( value );
1516 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1518 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1519 DALI_TEST_CHECK( value );
1520 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1522 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1523 DALI_TEST_CHECK( value );
1524 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1529 int UtcDaliImageViewFittingModesFill(void)
1531 ToolkitTestApplication application;
1533 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1534 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1536 ImageView imageView = ImageView::New();
1537 Property::Map imageMap;
1538 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1539 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1540 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1542 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1543 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1545 application.GetScene().Add( imageView );
1547 // Trigger a potential relayout
1548 application.SendNotification();
1549 application.Render();
1551 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1552 Property::Map returnedMap;
1553 visual.CreatePropertyMap( returnedMap );
1555 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1556 DALI_TEST_CHECK( value );
1557 Property::Map* map = value->GetMap();
1558 DALI_TEST_CHECK( map );
1560 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1561 DALI_TEST_CHECK( value );
1562 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1564 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1565 DALI_TEST_CHECK( value );
1566 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1568 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1569 DALI_TEST_CHECK( value );
1570 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1575 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1577 ToolkitTestApplication application;
1579 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1580 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1582 ImageView imageView = ImageView::New();
1583 Property::Map imageMap;
1584 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1585 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1586 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1588 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1589 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1591 application.GetScene().Add( imageView );
1593 // Trigger a potential relayout
1594 application.SendNotification();
1595 application.Render();
1597 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1598 Property::Map returnedMap;
1599 visual.CreatePropertyMap( returnedMap );
1601 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1602 DALI_TEST_CHECK( value );
1603 Property::Map* map = value->GetMap();
1604 DALI_TEST_CHECK( map );
1607 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1608 DALI_TEST_CHECK( value );
1609 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1611 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1612 DALI_TEST_CHECK( value );
1613 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1615 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1616 DALI_TEST_CHECK( value );
1617 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1622 int UtcDaliImageViewFittingModesCenter01(void)
1624 ToolkitTestApplication application;
1626 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1627 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1629 ImageView imageView = ImageView::New();
1630 Property::Map imageMap;
1631 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1632 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1633 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1635 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1636 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1638 application.GetScene().Add( imageView );
1640 // Trigger a potential relayout
1641 application.SendNotification();
1642 application.Render();
1644 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1645 Property::Map returnedMap;
1646 visual.CreatePropertyMap( returnedMap );
1648 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1649 DALI_TEST_CHECK( value );
1650 Property::Map* map = value->GetMap();
1651 DALI_TEST_CHECK( map );
1653 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1654 DALI_TEST_CHECK( value );
1655 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1657 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1658 DALI_TEST_CHECK( value );
1659 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1661 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1662 DALI_TEST_CHECK( value );
1663 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1668 int UtcDaliImageViewFittingModesCenter02(void)
1670 ToolkitTestApplication application;
1672 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1673 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1675 ImageView imageView = ImageView::New();
1676 Property::Map imageMap;
1677 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1678 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1679 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1681 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1682 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1684 application.GetScene().Add( imageView );
1686 // Trigger a potential relayout
1687 application.SendNotification();
1688 application.Render();
1690 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1691 Property::Map returnedMap;
1692 visual.CreatePropertyMap( returnedMap );
1694 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1695 DALI_TEST_CHECK( value );
1696 Property::Map* map = value->GetMap();
1697 DALI_TEST_CHECK( map );
1699 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1700 DALI_TEST_CHECK( value );
1701 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1703 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1704 DALI_TEST_CHECK( value );
1705 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1707 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1708 DALI_TEST_CHECK( value );
1709 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1714 int UtcDaliImageViewFittingModesFitHeight01(void)
1716 ToolkitTestApplication application;
1718 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1720 ImageView imageView = ImageView::New();
1721 Property::Map imageMap;
1722 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1723 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1724 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1726 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1727 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1729 application.GetScene().Add( imageView );
1731 // Trigger a potential relayout
1732 application.SendNotification();
1733 application.Render();
1735 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1736 Property::Map returnedMap;
1737 visual.CreatePropertyMap( returnedMap );
1739 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1740 DALI_TEST_CHECK( value );
1741 Property::Map* map = value->GetMap();
1742 DALI_TEST_CHECK( map );
1744 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1745 DALI_TEST_CHECK( value );
1746 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1748 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1749 DALI_TEST_CHECK( value );
1750 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1752 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1753 DALI_TEST_CHECK( value );
1754 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1759 int UtcDaliImageViewFittingModesFitHeight02(void)
1761 ToolkitTestApplication application;
1763 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1765 ImageView imageView = ImageView::New();
1766 Property::Map imageMap;
1767 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1768 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1769 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1771 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1772 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1774 application.GetScene().Add( imageView );
1776 // Trigger a potential relayout
1777 application.SendNotification();
1778 application.Render();
1780 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1781 Property::Map returnedMap;
1782 visual.CreatePropertyMap( returnedMap );
1784 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1785 DALI_TEST_CHECK( value );
1786 Property::Map* map = value->GetMap();
1787 DALI_TEST_CHECK( map );
1789 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1790 DALI_TEST_CHECK( value );
1791 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1793 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1794 DALI_TEST_CHECK( value );
1795 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1797 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1798 DALI_TEST_CHECK( value );
1799 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1804 int UtcDaliImageViewFittingModesFitWidth01(void)
1806 ToolkitTestApplication application;
1808 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
1810 ImageView imageView = ImageView::New();
1811 Property::Map imageMap;
1812 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1813 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1814 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1816 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1817 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1819 application.GetScene().Add( imageView );
1821 // Trigger a potential relayout
1822 application.SendNotification();
1823 application.Render();
1825 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1826 Property::Map returnedMap;
1827 visual.CreatePropertyMap( returnedMap );
1829 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1830 DALI_TEST_CHECK( value );
1831 Property::Map* map = value->GetMap();
1832 DALI_TEST_CHECK( map );
1834 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1835 DALI_TEST_CHECK( value );
1836 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1838 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1839 DALI_TEST_CHECK( value );
1840 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1842 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1843 DALI_TEST_CHECK( value );
1844 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1849 int UtcDaliImageViewFittingModesFitWidth02(void)
1851 ToolkitTestApplication application;
1853 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
1855 ImageView imageView = ImageView::New();
1856 Property::Map imageMap;
1857 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1858 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1859 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1861 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1862 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1864 application.GetScene().Add( imageView );
1866 // Trigger a potential relayout
1867 application.SendNotification();
1868 application.Render();
1870 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1871 Property::Map returnedMap;
1872 visual.CreatePropertyMap( returnedMap );
1874 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1875 DALI_TEST_CHECK( value );
1876 Property::Map* map = value->GetMap();
1877 DALI_TEST_CHECK( map );
1879 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1880 DALI_TEST_CHECK( value );
1881 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1883 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1884 DALI_TEST_CHECK( value );
1885 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1887 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1888 DALI_TEST_CHECK( value );
1889 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1894 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
1896 ToolkitTestApplication application;
1898 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
1900 ImageView imageView = ImageView::New();
1902 // 1. Render using FittingMode::SHRINK_TO_FIT
1903 Property::Map imageMap;
1904 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1905 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1906 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1908 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1909 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1911 application.GetScene().Add( imageView );
1913 // Trigger a potential relayout
1914 application.SendNotification();
1915 application.Render();
1917 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1918 Property::Map returnedMap;
1919 visual.CreatePropertyMap( returnedMap );
1921 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1922 DALI_TEST_CHECK( value );
1923 Property::Map* map = value->GetMap();
1924 DALI_TEST_CHECK( map );
1926 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1927 DALI_TEST_CHECK( value );
1928 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1930 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1931 DALI_TEST_CHECK( value );
1932 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1934 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1935 DALI_TEST_CHECK( value );
1936 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1938 // 2. Render again using DevelVisaul::CENTER
1939 Property::Map imageMap2;
1940 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1941 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1942 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
1944 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
1945 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1947 application.GetScene().Add( imageView );
1949 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1951 // Trigger a potential relayout
1952 application.SendNotification();
1953 application.Render();
1955 returnedMap.Clear();
1956 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1958 visual.CreatePropertyMap( returnedMap );
1960 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1961 DALI_TEST_CHECK( value );
1962 map = value->GetMap();
1963 DALI_TEST_CHECK( map );
1965 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1966 DALI_TEST_CHECK( value );
1967 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1969 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1970 DALI_TEST_CHECK( value );
1971 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1973 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1974 DALI_TEST_CHECK( value );
1975 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
1977 // 3. Render again using before fittingMode
1978 Property::Map imageMap3;
1979 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1980 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1981 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1983 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
1984 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1986 application.GetScene().Add( imageView );
1988 // Trigger a potential relayout
1989 application.SendNotification();
1990 application.Render();
1992 returnedMap.Clear();
1993 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1994 visual.CreatePropertyMap( returnedMap );
1996 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1997 DALI_TEST_CHECK( value );
1998 map = value->GetMap();
1999 DALI_TEST_CHECK( map );
2001 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2002 DALI_TEST_CHECK( value );
2003 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2005 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2006 DALI_TEST_CHECK( value );
2007 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2009 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2010 DALI_TEST_CHECK( value );
2011 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2016 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2018 ToolkitTestApplication application;
2020 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2022 ImageView imageView = ImageView::New();
2024 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2025 Property::Map imageMap;
2026 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2027 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2028 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2030 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2031 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2033 application.GetScene().Add( imageView );
2035 // Trigger a potential relayout
2036 application.SendNotification();
2037 application.Render();
2039 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2040 Property::Map returnedMap;
2041 visual.CreatePropertyMap( returnedMap );
2043 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2044 DALI_TEST_CHECK( value );
2045 Property::Map* map = value->GetMap();
2046 DALI_TEST_CHECK( map );
2048 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2049 DALI_TEST_CHECK( value );
2050 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2052 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2053 DALI_TEST_CHECK( value );
2054 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2056 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2057 DALI_TEST_CHECK( value );
2058 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2060 // 2. Render again using DevelVisaul::CENTER
2061 Property::Map imageMap2;
2062 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2063 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2064 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2066 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2067 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2069 application.GetScene().Add( imageView );
2071 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2073 // Trigger a potential relayout
2074 application.SendNotification();
2075 application.Render();
2077 returnedMap.Clear();
2078 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2080 visual.CreatePropertyMap( returnedMap );
2082 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2083 DALI_TEST_CHECK( value );
2084 map = value->GetMap();
2085 DALI_TEST_CHECK( map );
2087 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2088 DALI_TEST_CHECK( value );
2089 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2091 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2092 DALI_TEST_CHECK( value );
2093 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2095 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2096 DALI_TEST_CHECK( value );
2097 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2099 // 3. Render again using before fittingMode
2100 Property::Map imageMap3;
2101 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2102 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2103 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2105 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2106 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2108 application.GetScene().Add( imageView );
2110 // Trigger a potential relayout
2111 application.SendNotification();
2112 application.Render();
2114 returnedMap.Clear();
2115 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2116 visual.CreatePropertyMap( returnedMap );
2118 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2119 DALI_TEST_CHECK( value );
2120 map = value->GetMap();
2121 DALI_TEST_CHECK( map );
2123 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2124 DALI_TEST_CHECK( value );
2125 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2127 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2128 DALI_TEST_CHECK( value );
2129 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2131 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2132 DALI_TEST_CHECK( value );
2133 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2138 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2140 ToolkitTestApplication application;
2142 tet_infoline( "Create an ImageVisual using ScaleToFill and animated vector image ( image: [600,600], view:[600,600] )" );
2144 ImageView imageView = ImageView::New();
2145 Property::Map imageMap;
2146 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2147 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2149 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2150 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2152 application.GetScene().Add( imageView );
2154 // Trigger a potential relayout
2155 application.SendNotification();
2156 application.Render();
2158 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2159 Property::Map returnedMap;
2160 visual.CreatePropertyMap( returnedMap );
2162 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2163 DALI_TEST_CHECK( value );
2164 Property::Map* map = value->GetMap();
2165 DALI_TEST_CHECK( map );
2167 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2168 DALI_TEST_CHECK( value );
2169 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2171 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2172 DALI_TEST_CHECK( value );
2173 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2175 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2176 DALI_TEST_CHECK( value );
2177 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2183 int UtcDaliImageViewCustomShader(void)
2185 ToolkitTestApplication application;
2187 // Set a custom shader with an image url
2189 Property::Map properties;
2190 Property::Map shader;
2191 const std::string vertexShader = "Foobar";
2192 const std::string fragmentShader = "Foobar";
2193 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2194 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2196 properties[Visual::Property::TYPE] = Visual::IMAGE;
2197 properties[Visual::Property::SHADER] = shader;
2198 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2200 ImageView imageView = ImageView::New();
2201 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2203 application.GetScene().Add( imageView );
2205 application.SendNotification();
2206 application.Render();
2208 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2210 Renderer renderer = imageView.GetRendererAt( 0 );
2211 Shader shader2 = renderer.GetShader();
2212 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2213 Property::Map* map = value.GetMap();
2214 DALI_TEST_CHECK( map );
2216 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2217 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2219 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2220 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2223 // Set a custom shader after setting an image url
2225 Property::Map properties;
2226 Property::Map shader;
2227 const std::string vertexShader = "Foobar";
2228 const std::string fragmentShader = "Foobar";
2229 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2230 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2232 properties[Visual::Property::SHADER] = shader;
2234 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2235 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2237 application.GetScene().Add( imageView );
2239 application.SendNotification();
2240 application.Render();
2242 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2244 Renderer renderer = imageView.GetRendererAt( 0 );
2245 Shader shader2 = renderer.GetShader();
2246 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2247 Property::Map* map = value.GetMap();
2248 DALI_TEST_CHECK( map );
2250 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2251 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2253 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2254 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2257 // Set a custom shader before setting an image url
2259 Property::Map properties;
2260 Property::Map shader;
2261 const std::string vertexShader = "Foobar";
2262 const std::string fragmentShader = "Foobar";
2263 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2264 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2266 properties[Visual::Property::SHADER] = shader;
2268 ImageView imageView = ImageView::New();
2269 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2270 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2272 application.GetScene().Add( imageView );
2274 application.SendNotification();
2275 application.Render();
2276 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2278 Renderer renderer = imageView.GetRendererAt( 0 );
2279 Shader shader2 = renderer.GetShader();
2280 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2281 Property::Map* map = value.GetMap();
2282 DALI_TEST_CHECK( map );
2284 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2285 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2287 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2288 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2291 // Set a custom shader after setting a property map
2293 Property::Map properties;
2294 Property::Map shader;
2295 const std::string vertexShader = "Foobar";
2296 const std::string fragmentShader = "Foobar";
2297 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2298 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2300 properties[Visual::Property::SHADER] = shader;
2302 Property::Map properties1;
2303 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2304 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2306 ImageView imageView = ImageView::New();
2307 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2308 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2310 application.GetScene().Add( imageView );
2312 application.SendNotification();
2313 application.Render();
2314 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2316 Renderer renderer = imageView.GetRendererAt( 0 );
2317 Shader shader2 = renderer.GetShader();
2318 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2319 Property::Map* map = value.GetMap();
2320 DALI_TEST_CHECK( map );
2322 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2323 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2325 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2326 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2329 // Set a custom shader before setting a property map
2331 Property::Map properties;
2332 Property::Map shader;
2333 const std::string vertexShader = "Foobar";
2334 const std::string fragmentShader = "Foobar";
2335 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2336 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2338 properties[Visual::Property::SHADER] = shader;
2340 Property::Map properties1;
2341 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2342 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2344 ImageView imageView = ImageView::New();
2345 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2346 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2348 application.GetScene().Add( imageView );
2350 application.SendNotification();
2351 application.Render();
2352 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2354 Renderer renderer = imageView.GetRendererAt( 0 );
2355 Shader shader2 = renderer.GetShader();
2356 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2357 Property::Map* map = value.GetMap();
2358 DALI_TEST_CHECK( map );
2360 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2361 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2363 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2364 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2373 static int gFailCounter = 0;
2374 const int MAX_RETRIES(3);
2376 void ReloadImage(ImageView imageView)
2378 Property::Map imageImmediateLoadingMap;
2379 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2380 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2382 tet_infoline("Immediate load an image");
2383 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2386 void ResourceFailedReload( Control control )
2389 if( gFailCounter < MAX_RETRIES )
2391 ReloadImage(ImageView::DownCast(control));
2396 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2398 tet_infoline("Test reloading failed image from within signal handler.");
2400 ToolkitTestApplication application;
2404 ImageView imageView = ImageView::New();
2405 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2406 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2407 ReloadImage(imageView);
2409 // loading started, this waits for the loader thread to complete
2410 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2411 application.SendNotification();
2413 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2415 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2416 application.SendNotification();
2418 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2420 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2421 application.SendNotification();
2422 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2427 int UtcDaliImageViewLoadRemoteSVG(void)
2429 tet_infoline("Test load from a remote server.");
2431 ToolkitTestApplication application;
2432 Toolkit::ImageView imageView;
2433 imageView = Toolkit::ImageView::New( );
2434 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2435 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2436 imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2437 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2438 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2439 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2440 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2442 application.GetScene().Add( imageView );
2444 DALI_TEST_CHECK( imageView );
2446 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2448 application.SendNotification();
2450 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2452 application.SendNotification();
2453 application.Render();
2455 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2460 int UtcDaliImageViewSyncSVGLoading(void)
2462 ToolkitTestApplication application;
2464 tet_infoline("ImageView Testing SVG image sync loading");
2466 // Sync loading, automatic atlasing for small size image
2468 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2470 callStack.Enable(true);
2472 ImageView imageView = ImageView::New( );
2474 // Sync loading is used
2475 Property::Map syncLoadingMap;
2476 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2477 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2478 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2479 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2481 application.GetScene().Add( imageView );
2482 DALI_TEST_CHECK( imageView );
2484 application.SendNotification();
2485 application.Render(16);
2486 Vector3 naturalSize = imageView.GetNaturalSize();
2488 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2489 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2495 int UtcDaliImageViewAsyncSVGLoading(void)
2497 ToolkitTestApplication application;
2499 tet_infoline("ImageView Testing SVG image async loading");
2501 // Sync loading, automatic atlasing for small size image
2503 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2505 callStack.Enable(true);
2507 ImageView imageView = ImageView::New( );
2509 // Sync loading is used
2510 Property::Map syncLoadingMap;
2511 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2512 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2513 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2514 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2516 application.GetScene().Add( imageView );
2517 DALI_TEST_CHECK( imageView );
2519 application.SendNotification();
2520 application.Render(16);
2521 Vector3 naturalSize = imageView.GetNaturalSize();
2523 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2524 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2529 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2531 ToolkitTestApplication application;
2533 tet_infoline("ImageView Testing SVG image async loading");
2535 // Sync loading, automatic atlasing for small size image
2537 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2539 callStack.Enable(true);
2541 ImageView imageView = ImageView::New( );
2543 // Sync loading is used
2544 Property::Map syncLoadingMap;
2545 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2546 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2548 // Check to set invalid value
2549 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2550 // Check if error log is outputted when setting other value like string.
2551 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2552 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2553 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2555 application.GetScene().Add( imageView );
2556 DALI_TEST_CHECK( imageView );
2558 application.SendNotification();
2559 application.Render(16);
2560 Vector3 naturalSize = imageView.GetNaturalSize();
2561 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2562 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2564 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2565 Property::Map* map = value.GetMap();
2566 DALI_TEST_CHECK( map );
2568 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2569 DALI_TEST_CHECK( sync );
2570 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2576 int UtcDaliImageViewSvgLoadingFailure(void)
2578 ToolkitTestApplication application;
2582 gResourceReadySignalFired = false;
2584 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/Kid1.svg" );
2585 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2586 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2588 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2590 application.GetScene().Add( imageView );
2592 application.SendNotification();
2594 // loading started, this waits for the loader thread
2595 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2597 application.SendNotification();
2598 application.Render(16);
2600 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2601 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2602 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2607 gResourceReadySignalFired = false;
2609 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2610 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2611 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2613 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2615 application.GetScene().Add( imageView );
2617 application.SendNotification();
2619 // loading started, this waits for the loader thread
2620 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2622 application.SendNotification();
2623 application.Render(16);
2625 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2626 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2627 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2636 static int gResourceReadySignalCounter = 0;
2638 void OnResourceReadySignal( Control control )
2640 gResourceReadySignalCounter++;
2642 if( gResourceReadySignalCounter == 1 )
2645 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2646 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2652 int UtcDaliImageViewSetImageOnResourceReadySignal(void)
2654 tet_infoline("Test setting image from within signal handler.");
2656 ToolkitTestApplication application;
2658 gResourceReadySignalCounter = 0;
2660 ImageView imageView = ImageView::New( gImage_34_RGBA );
2661 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal );
2663 application.GetScene().Add( imageView );
2665 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2667 application.SendNotification();
2668 application.Render();
2670 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2672 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );