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 Stage::GetCurrent().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 Stage::GetCurrent().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 Stage::GetCurrent().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 Stage::GetCurrent().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 Stage stage = Stage::GetCurrent();
422 stage.Add( gifView );
425 application.SendNotification();
426 application.Render(16);
427 DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
429 const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
430 // test that the pixel area value defined in the visual property map is registered on renderer
431 Renderer renderer = gifView.GetRendererAt(0);
432 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
433 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
435 // test that the shader has the default pixel area value registered.
436 Shader shader = renderer.GetShader();
437 pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
438 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
440 // test that the uniform uses the pixelArea property on the renderer.
441 TestGlAbstraction& gl = application.GetGlAbstraction();
442 Vector4 pixelAreaUniform;
443 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
444 DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
446 // set the pixelArea property on the control
447 const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
448 gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
449 application.SendNotification();
450 application.Render(16);
452 // check the pixelArea property on the control
453 pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
454 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
455 // test that the uniform uses the pixelArea property on the control.
456 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
457 DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
463 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
465 ToolkitTestApplication application;
466 TestGlAbstraction& gl = application.GetGlAbstraction();
467 const std::vector<GLuint>& textures = gl.GetBoundTextures();
468 size_t numTextures = textures.size();
470 // Async loading, no atlasing for big size image
471 ImageView imageView = ImageView::New( gImage_600_RGB );
473 // By default, Aysnc loading is used
474 Stage::GetCurrent().Add( imageView );
475 imageView.SetProperty( Actor::Property::SIZE, Vector2(100, 100) );
476 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
478 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
480 application.SendNotification();
481 application.Render(16);
482 application.SendNotification();
484 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
485 DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
492 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
494 ToolkitTestApplication application;
496 //Async loading, automatic atlasing for small size image
497 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
499 callStack.Enable(true);
501 Property::Map imageMap;
503 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
504 imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
505 imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
506 imageMap[ ImageVisual::Property::ATLASING] = true;
508 ImageView imageView = ImageView::New();
509 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
510 imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
512 // By default, Aysnc loading is used
513 // loading is not started if the actor is offStage
515 Stage::GetCurrent().Add( imageView );
516 application.SendNotification();
517 application.Render(16);
518 application.Render(16);
519 application.SendNotification();
521 imageView.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
522 application.SendNotification();
523 application.Render(16);
524 application.Render(16);
525 application.SendNotification();
527 // loading started, this waits for the loader thread for max 30 seconds
528 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
530 application.SendNotification();
531 application.Render(16);
533 callStack.Enable(false);
535 TraceCallStack::NamedParams params;
536 params["width"] = ToString(34);
537 params["height"] = ToString(34);
538 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
543 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
545 ToolkitTestApplication application;
547 //Async loading, automatic atlasing for small size image
548 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
550 callStack.Enable(true);
552 Property::Map asyncLoadingMap;
553 asyncLoadingMap[ "url" ] = gImage_34_RGBA;
554 asyncLoadingMap[ "desiredHeight" ] = 34;
555 asyncLoadingMap[ "desiredWidth" ] = 34;
556 asyncLoadingMap[ "synchronousLoading" ] = false;
557 asyncLoadingMap[ "atlasing" ] = true;
559 ImageView imageView = ImageView::New();
560 imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
562 Stage::GetCurrent().Add( imageView );
563 application.SendNotification();
564 application.Render(16);
565 application.Render(16);
566 application.SendNotification();
568 // loading started, this waits for the loader thread for max 30 seconds
569 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
571 application.SendNotification();
572 application.Render(16);
574 callStack.Enable(false);
576 TraceCallStack::NamedParams params;
577 params["width"] = ToString(34);
578 params["height"] = ToString(34);
579 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
584 int UtcDaliImageViewSyncLoading(void)
586 ToolkitTestApplication application;
588 tet_infoline("ImageView Testing sync loading and size using index key property map");
590 Property::Map syncLoadingMap;
591 syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
592 syncLoadingMap[ ImageVisual::Property::ATLASING ] = true;
594 // Sync loading, no atlasing for big size image
596 ImageView imageView = ImageView::New();
598 // Sync loading is used
599 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
600 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
603 // Sync loading, automatic atlasing for small size image
605 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
607 callStack.Enable(true);
609 ImageView imageView = ImageView::New( );
611 // Sync loading is used
612 syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
613 syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
614 syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
615 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
617 Stage::GetCurrent().Add( imageView );
618 application.SendNotification();
619 application.Render(16);
621 TraceCallStack::NamedParams params;
622 params["width"] = ToString(34);
623 params["height"] = ToString(34);
624 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
625 true, TEST_LOCATION );
630 int UtcDaliImageViewSyncLoading02(void)
632 ToolkitTestApplication application;
634 tet_infoline("ImageView Testing sync loading and size using string key property map");
636 // Sync loading, automatic atlasing for small size image
638 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
640 callStack.Enable(true);
642 ImageView imageView = ImageView::New( );
644 // Sync loading is used
645 Property::Map syncLoadingMap;
646 syncLoadingMap[ "url" ] = gImage_34_RGBA;
647 syncLoadingMap[ "desiredHeight" ] = 34;
648 syncLoadingMap[ "desiredWidth" ] = 34;
649 syncLoadingMap[ "synchronousLoading" ] = true;
650 syncLoadingMap[ "atlasing" ] = true;
651 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
653 Stage::GetCurrent().Add( imageView );
654 application.SendNotification();
655 application.Render(16);
657 TraceCallStack::NamedParams params;
658 params["width"] = ToString(34);
659 params["height"] = ToString(34);
660 DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
661 true, TEST_LOCATION );
666 int UtcDaliImageViewAddedTexture(void)
668 ToolkitTestApplication application;
670 tet_infoline("ImageView Testing image view with texture provided manager url");
672 ImageView imageView = ImageView::New();
674 // empty texture is ok, though pointless from app point of view
676 std::string url = TextureManager::AddTexture(empty);
677 DALI_TEST_CHECK(url.size() > 0u);
679 Property::Map propertyMap;
680 propertyMap[ImageVisual::Property::URL] = url;
681 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
683 Stage::GetCurrent().Add( imageView );
684 application.SendNotification();
685 application.Render();
690 int UtcDaliImageViewSizeWithBackground(void)
692 ToolkitTestApplication application;
696 ImageView imageView = ImageView::New();
698 imageView.SetProperty( Control::Property::BACKGROUND,
700 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
701 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
702 { ImageVisual::Property::DESIRED_WIDTH, width },
703 { ImageVisual::Property::DESIRED_HEIGHT, height },
707 Stage::GetCurrent().Add( imageView );
708 application.SendNotification();
709 application.Render();
711 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
712 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
717 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
719 ToolkitTestApplication application;
721 int widthBackground = 100;
722 int heightBackground = 200;
726 ImageView imageView = ImageView::New();
728 imageView.SetProperty( Control::Property::BACKGROUND,
730 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
731 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
732 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
733 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground },
737 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio, 600x600 pixels
739 Stage::GetCurrent().Add( imageView );
740 application.SendNotification();
741 application.Render();
743 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, (float)width, TEST_LOCATION );
744 DALI_TEST_EQUALS( imageView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, (float)height, TEST_LOCATION );
749 int UtcDaliImageViewHeightForWidthBackground(void)
751 ToolkitTestApplication application;
753 int widthBackground = 100;
754 int heightBackground = 200;
756 ImageView imageView = ImageView::New();
758 imageView.SetProperty( Control::Property::BACKGROUND,
760 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
761 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
762 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
763 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
767 Stage::GetCurrent().Add( imageView );
768 application.SendNotification();
769 application.Render();
771 Control control = Control::DownCast( imageView );
772 DALI_TEST_CHECK( control );
773 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
774 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
779 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
781 ToolkitTestApplication application;
783 int widthBackground = 100;
784 int heightBackground = 200;
788 ImageView imageView = ImageView::New();
790 imageView.SetProperty( Control::Property::BACKGROUND,
792 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
793 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
794 { ImageVisual::Property::DESIRED_WIDTH, widthBackground },
795 { ImageVisual::Property::DESIRED_HEIGHT, heightBackground }
799 imageView.SetImage( gImage_600_RGB ); // 1 to 1 ratio
801 Stage::GetCurrent().Add( imageView );
802 application.SendNotification();
803 application.Render();
805 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
806 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
811 int UtcDaliImageViewSetImageUrl(void)
813 ToolkitTestApplication application;
815 ImageView imageView = ImageView::New();
816 imageView.SetImage( TEST_IMAGE_FILE_NAME );
817 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
820 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
821 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
826 bool gResourceReadySignalFired = false;
827 Vector3 gNaturalSize;
829 void ResourceReadySignal( Control control )
831 gResourceReadySignalFired = true;
834 int UtcDaliImageViewCheckResourceReady(void)
836 ToolkitTestApplication application;
838 gResourceReadySignalFired = false;
840 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
841 ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
843 imageView.SetProperty( Control::Property::BACKGROUND,
845 { Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE },
846 { Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg" },
847 { ImageVisual::Property::DESIRED_WIDTH, 100 },
848 { ImageVisual::Property::DESIRED_HEIGHT, 200 }
852 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
854 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
856 Stage::GetCurrent().Add( imageView );
858 // loading started, this waits for the loader thread
859 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
861 application.SendNotification();
862 application.Render(16);
864 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
866 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
871 int UtcDaliImageViewSetImageTypeChangesP(void)
873 ToolkitTestApplication application;
875 ImageView imageView = ImageView::New();
876 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
878 Stage::GetCurrent().Add( imageView );
882 Toolkit::Visual::Base visual;
884 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
885 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
887 application.SendNotification();
888 application.Render( 16 );
890 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
892 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
893 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
896 imageView.SetImage( "TEST_URL" );
898 application.SendNotification();
899 application.Render( 16 );
901 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
902 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
904 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
905 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
906 DALI_TEST_CHECK( visual ); // Visual should be valid
909 imageView.SetImage( "" );
911 application.SendNotification();
912 application.Render( 16 );
914 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
915 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
917 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
919 DALI_TEST_CHECK( map.Empty() ); // Value should be empty
920 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
922 // Set a URL in property map
923 Property::Map propertyMap;
924 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
925 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
927 application.SendNotification();
928 application.Render( 16 );
930 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
931 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
933 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
934 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
935 DALI_TEST_CHECK( visual ); // Visual should be valid
937 // Set a URL in property map again
938 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
939 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
941 application.SendNotification();
942 application.Render( 16 );
944 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
945 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
947 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
948 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
949 DALI_TEST_CHECK( visual ); // Visual should be valid
951 // Set an empty URL in property map
952 propertyMap[ImageVisual::Property::URL] = std::string();
953 imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
955 application.SendNotification();
956 application.Render( 16 );
958 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
959 visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
961 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
962 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
963 DALI_TEST_CHECK( ! visual ); // Visual should be invalid
968 int UtcDaliImageViewResourceUrlP(void)
970 ToolkitTestApplication application;
972 ImageView imageView = ImageView::New();
973 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >().empty() );
975 imageView.SetProperty( ImageView::Property::IMAGE, "TestString" );
976 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::IMAGE ).Get< std::string >(), "TestString", TEST_LOCATION );
981 int UtcDaliImageViewReplaceImage(void)
983 ToolkitTestApplication application;
985 gResourceReadySignalFired = false;
987 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
988 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
990 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
992 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
994 Stage::GetCurrent().Add( imageView );
996 application.SendNotification();
997 application.Render(16);
999 // loading started, this waits for the loader thread for max 30 seconds
1000 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1002 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1004 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1006 gResourceReadySignalFired = false;
1008 imageView.SetImage(TEST_IMAGE_2);
1010 application.SendNotification();
1011 application.Render(16);
1013 // loading started, this waits for the loader thread for max 30 seconds
1014 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1016 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
1018 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
1020 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1025 void OnRelayoutOverride( Size size )
1027 gNaturalSize = size; // Size Relayout is using
1030 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1032 ToolkitTestApplication application;
1034 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1035 ImageView imageView = ImageView::New( TEST_IMAGE_1 );
1036 imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1038 DummyControl dummyControl = DummyControl::New( true );
1039 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1040 dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
1042 dummyControl.Add( imageView );
1043 dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
1044 Stage::GetCurrent().Add( dummyControl );
1046 application.SendNotification();
1047 application.Render();
1049 // loading started, this waits for the loader thread for max 30 seconds
1050 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1052 DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
1053 DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
1055 gNaturalSize = Vector3::ZERO;
1057 imageView.SetImage(gImage_600_RGB);
1059 // Waiting for resourceReady so SendNotifcation not called here.
1061 // loading started, this waits for the loader thread for max 30 seconds
1062 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1064 // Trigger a potential relayout
1065 application.SendNotification();
1066 application.Render();
1068 DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
1069 DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
1074 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1076 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1078 ToolkitTestApplication application;
1080 gResourceReadySignalFired = false;
1082 Property::Map imageMap;
1084 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1085 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1087 tet_infoline("Creating ImageView without URL so image does not start loading");
1088 ImageView imageView = ImageView::New();
1089 tet_infoline("Connect to image loaded signal before setting image");
1090 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1091 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1092 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1094 // loading started, this waits for the loader thread
1095 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1097 application.SendNotification();
1098 application.Render(16);
1100 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1105 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1107 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1109 ToolkitTestApplication application;
1111 gResourceReadySignalFired = false;
1113 Property::Map imageMap;
1115 imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1116 imageMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1118 ImageView imageView = ImageView::New();
1119 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1120 imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
1122 // loading started, this waits for the loader thread
1123 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1125 application.SendNotification();
1126 application.Render(16);
1128 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1129 gResourceReadySignalFired = false;
1131 ImageView imageViewWithExistingImage = ImageView::New();
1132 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1133 imageViewWithExistingImage.SetProperty( ImageView::Property::IMAGE, imageMap );
1135 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1140 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1142 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1144 ToolkitTestApplication application;
1146 gResourceReadySignalFired = false;
1148 Property::Map imageImmediateLoadingMap;
1149 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
1150 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
1152 tet_infoline("Immediate load an image");
1153 ImageView imageView = ImageView::New();
1154 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
1155 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
1157 // loading started, this waits for the loader thread
1158 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1160 application.SendNotification();
1161 application.Render(16);
1163 tet_infoline("Check image loaded");
1164 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1165 gResourceReadySignalFired = false;
1167 tet_infoline("Create another ImageView with the same URL");
1168 ImageView imageViewWithExistingImage = ImageView::New( gImage_34_RGBA );
1169 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1170 imageViewWithExistingImage.ResourceReadySignal().Connect( &ResourceReadySignal);
1172 Stage::GetCurrent().Add( imageViewWithExistingImage );
1174 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1179 int UtcDaliImageViewPaddingProperty(void)
1181 ToolkitTestApplication application;
1183 ImageView imageView = ImageView::New();
1184 Property::Map imagePropertyMap;
1185 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1186 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
1187 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1188 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1189 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1190 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1191 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1192 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1193 Stage::GetCurrent().Add( imageView );
1195 application.SendNotification();
1196 application.Render();
1198 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1200 ImageView childImage = ImageView::New();
1201 childImage.SetBackgroundColor( Color::BLACK );
1202 childImage.SetProperty( Actor::Property::SIZE, Vector2( 10.f, 10.f ) );
1203 imageView.Add( childImage );
1205 application.SendNotification();
1206 application.Render();
1208 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1209 DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1211 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1212 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1213 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1214 Property::Map resultMap;
1215 imageVisual.CreatePropertyMap( resultMap );
1217 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1218 DALI_TEST_CHECK( transformValue );
1219 Property::Map* retMap = transformValue->GetMap();
1220 DALI_TEST_CHECK( retMap );
1222 // Image Visual should be positioned depending on ImageView's padding
1223 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1228 int UtcDaliImageViewPaddingProperty02(void)
1230 ToolkitTestApplication application;
1232 ImageView imageView = ImageView::New();
1233 Property::Map imagePropertyMap;
1234 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1235 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1236 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1237 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1238 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1239 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1240 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1241 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1242 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1243 Stage::GetCurrent().Add( imageView );
1245 application.SendNotification();
1246 application.Render();
1248 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1250 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1251 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1252 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1253 Property::Map resultMap;
1254 imageVisual.CreatePropertyMap( resultMap );
1256 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1257 DALI_TEST_CHECK( transformValue );
1258 Property::Map* retMap = transformValue->GetMap();
1259 DALI_TEST_CHECK( retMap );
1261 // Image Visual should be positioned depending on ImageView's padding
1262 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
1267 int UtcDaliImageViewPaddingProperty03(void)
1269 tet_infoline("Test Setting Image Padding then removing it.");
1271 ToolkitTestApplication application;
1273 ImageView imageView = ImageView::New();
1274 Property::Map imagePropertyMap;
1275 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1276 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1277 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1278 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1279 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1280 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1281 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1282 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1283 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1284 Stage::GetCurrent().Add( imageView );
1286 application.SendNotification();
1287 application.Render();
1289 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1291 tet_infoline("Remove Padding and test Visual is position correctly");
1293 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1295 application.SendNotification();
1296 application.Render();
1298 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1299 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1300 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1301 Property::Map resultMap;
1302 imageVisual.CreatePropertyMap( resultMap );
1304 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1305 DALI_TEST_CHECK( transformValue );
1306 Property::Map* retMap = transformValue->GetMap();
1307 DALI_TEST_CHECK( retMap );
1309 // Image Visual should be positioned depending on ImageView's padding
1310 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1315 int UtcDaliImageViewPaddingProperty04(void)
1317 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1319 ToolkitTestApplication application;
1321 ImageView imageView = ImageView::New();
1322 Property::Map imagePropertyMap;
1323 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1324 imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
1325 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
1326 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
1327 imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FILL;
1328 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1329 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1330 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1331 imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1332 Stage::GetCurrent().Add( imageView );
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1339 tet_infoline("Remove Padding and test Visual is position correctly");
1341 imageView.SetProperty( Control::Property::PADDING, Extents( 0, 0, 0, 0 ) );
1343 application.SendNotification();
1344 application.Render();
1346 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1347 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1348 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1349 Property::Map resultMap;
1350 imageVisual.CreatePropertyMap( resultMap );
1352 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1353 DALI_TEST_CHECK( transformValue );
1354 Property::Map* retMap = transformValue->GetMap();
1355 DALI_TEST_CHECK( retMap );
1357 // Image Visual should be positioned depending on ImageView's padding
1358 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
1363 int UtcDaliImageViewTransformTest01(void)
1365 tet_infoline("Test Setting a offset transform on the ImageView");
1367 ToolkitTestApplication application;
1369 ImageView imageView = ImageView::New();
1370 Property::Map imagePropertyMap;
1371 imagePropertyMap.Add( Toolkit::Visual::Property::TYPE,Toolkit::Visual::IMAGE )
1372 .Add( Toolkit::ImageVisual::Property::URL,TEST_RESOURCE_DIR "/Kid1.svg" )
1373 .Add( ImageVisual::Property::DESIRED_WIDTH,120 )
1374 .Add( ImageVisual::Property::DESIRED_HEIGHT,120 )
1375 .Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL )
1376 .Add( Visual::Property::TRANSFORM,
1377 Property::Map().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1378 Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE ) )
1379 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 8, 8 ) ) );
1381 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
1382 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1383 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1384 Stage::GetCurrent().Add( imageView );
1386 application.SendNotification();
1387 application.Render();
1389 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1390 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
1391 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
1392 Property::Map resultMap;
1393 imageVisual.CreatePropertyMap( resultMap );
1395 Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
1396 DALI_TEST_CHECK( transformValue );
1397 Property::Map* retMap = transformValue->GetMap();
1398 DALI_TEST_CHECK( retMap );
1400 // Image Visual should be positioned depending on ImageView's padding
1401 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 8, 8 ), TEST_LOCATION );
1402 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 );
1407 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1409 ToolkitTestApplication application;
1411 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1412 ImageView imageView = ImageView::New();
1413 Property::Map imageMap;
1414 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1415 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
1416 imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
1417 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1418 Stage::GetCurrent().Add( imageView );
1420 // Trigger a potential relayout
1421 application.SendNotification();
1422 application.Render();
1424 Vector3 naturalSize = imageView.GetNaturalSize();
1426 DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
1432 int UtcDaliImageViewFillMode(void)
1434 ToolkitTestApplication application;
1436 tet_infoline( "Create an ImageVisual without padding and set the fill-mode to fill" );
1438 ImageView imageView = ImageView::New();
1439 Property::Map imageMap;
1440 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1441 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB );
1442 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL );
1444 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1446 Stage::GetCurrent().Add( imageView );
1448 // Trigger a potential relayout
1449 application.SendNotification();
1450 application.Render();
1452 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1453 Property::Map returnedMap;
1454 visual.CreatePropertyMap( returnedMap );
1456 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1457 DALI_TEST_CHECK( value );
1458 Property::Map* map = value->GetMap();
1459 DALI_TEST_CHECK( map );
1461 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1462 DALI_TEST_CHECK( value );
1463 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION );
1465 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1466 DALI_TEST_CHECK( value );
1467 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1472 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1474 ToolkitTestApplication application;
1476 tet_infoline( "Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )" );
1477 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1479 ImageView imageView = ImageView::New();
1480 Property::Map imageMap;
1481 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1482 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1483 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO );
1485 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1486 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1488 Stage::GetCurrent().Add( imageView );
1490 // Trigger a potential relayout
1491 application.SendNotification();
1492 application.Render();
1494 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1495 Property::Map returnedMap;
1496 visual.CreatePropertyMap( returnedMap );
1498 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1499 DALI_TEST_CHECK( value );
1500 Property::Map* map = value->GetMap();
1501 DALI_TEST_CHECK( map );
1504 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1505 DALI_TEST_CHECK( value );
1506 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION );
1508 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1509 DALI_TEST_CHECK( value );
1510 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1512 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1513 DALI_TEST_CHECK( value );
1514 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1519 int UtcDaliImageViewFittingModesFill(void)
1521 ToolkitTestApplication application;
1523 tet_infoline( "Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )" );
1524 tet_infoline( " There should be no need to change the transform, only size is changed to fit view");
1526 ImageView imageView = ImageView::New();
1527 Property::Map imageMap;
1528 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1529 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1530 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::FILL );
1532 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1533 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1535 Stage::GetCurrent().Add( imageView );
1537 // Trigger a potential relayout
1538 application.SendNotification();
1539 application.Render();
1541 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1542 Property::Map returnedMap;
1543 visual.CreatePropertyMap( returnedMap );
1545 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1546 DALI_TEST_CHECK( value );
1547 Property::Map* map = value->GetMap();
1548 DALI_TEST_CHECK( map );
1550 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1551 DALI_TEST_CHECK( value );
1552 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Change the internal size according to the image view size
1554 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1555 DALI_TEST_CHECK( value );
1556 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
1558 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1559 DALI_TEST_CHECK( value );
1560 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1565 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1567 ToolkitTestApplication application;
1569 tet_infoline( "Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )" );
1570 tet_infoline( " offset or size is the same as view, but adjust internally using pixelArea ");
1572 ImageView imageView = ImageView::New();
1573 Property::Map imageMap;
1574 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1575 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1576 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE , Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO );
1578 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1579 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,500) );
1581 Stage::GetCurrent().Add( imageView );
1583 // Trigger a potential relayout
1584 application.SendNotification();
1585 application.Render();
1587 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1588 Property::Map returnedMap;
1589 visual.CreatePropertyMap( returnedMap );
1591 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1592 DALI_TEST_CHECK( value );
1593 Property::Map* map = value->GetMap();
1594 DALI_TEST_CHECK( map );
1597 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1598 DALI_TEST_CHECK( value );
1599 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 500 ), TEST_LOCATION ); // Change the internal size according to the image view size
1601 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1602 DALI_TEST_CHECK( value );
1603 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1605 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1606 DALI_TEST_CHECK( value );
1607 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1612 int UtcDaliImageViewFittingModesCenter01(void)
1614 ToolkitTestApplication application;
1616 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [700,700] )" );
1617 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1619 ImageView imageView = ImageView::New();
1620 Property::Map imageMap;
1621 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1622 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1623 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1625 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1626 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1628 Stage::GetCurrent().Add( imageView );
1630 // Trigger a potential relayout
1631 application.SendNotification();
1632 application.Render();
1634 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1635 Property::Map returnedMap;
1636 visual.CreatePropertyMap( returnedMap );
1638 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1639 DALI_TEST_CHECK( value );
1640 Property::Map* map = value->GetMap();
1641 DALI_TEST_CHECK( map );
1643 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1644 DALI_TEST_CHECK( value );
1645 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1647 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1648 DALI_TEST_CHECK( value );
1649 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1651 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1652 DALI_TEST_CHECK( value );
1653 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1658 int UtcDaliImageViewFittingModesCenter02(void)
1660 ToolkitTestApplication application;
1662 tet_infoline( "Create an ImageVisual using Center ( image: [600,600], view: [500,500] )" );
1663 tet_infoline( " There should be need to change the transform, offset is adjusted to fit inside");
1665 ImageView imageView = ImageView::New();
1666 Property::Map imageMap;
1667 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1668 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1669 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1671 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1672 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,700) );
1674 Stage::GetCurrent().Add( imageView );
1676 // Trigger a potential relayout
1677 application.SendNotification();
1678 application.Render();
1680 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1681 Property::Map returnedMap;
1682 visual.CreatePropertyMap( returnedMap );
1684 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1685 DALI_TEST_CHECK( value );
1686 Property::Map* map = value->GetMap();
1687 DALI_TEST_CHECK( map );
1689 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1690 DALI_TEST_CHECK( value );
1691 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1693 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1694 DALI_TEST_CHECK( value );
1695 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1697 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1698 DALI_TEST_CHECK( value );
1699 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 50 ), TEST_LOCATION );
1704 int UtcDaliImageViewFittingModesFitHeight01(void)
1706 ToolkitTestApplication application;
1708 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )" );
1710 ImageView imageView = ImageView::New();
1711 Property::Map imageMap;
1712 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1713 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1714 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1716 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1717 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1719 Stage::GetCurrent().Add( imageView );
1721 // Trigger a potential relayout
1722 application.SendNotification();
1723 application.Render();
1725 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1726 Property::Map returnedMap;
1727 visual.CreatePropertyMap( returnedMap );
1729 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1730 DALI_TEST_CHECK( value );
1731 Property::Map* map = value->GetMap();
1732 DALI_TEST_CHECK( map );
1734 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1735 DALI_TEST_CHECK( value );
1736 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1738 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1739 DALI_TEST_CHECK( value );
1740 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1742 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1743 DALI_TEST_CHECK( value );
1744 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1749 int UtcDaliImageViewFittingModesFitHeight02(void)
1751 ToolkitTestApplication application;
1753 tet_infoline( "Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )" );
1755 ImageView imageView = ImageView::New();
1756 Property::Map imageMap;
1757 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1758 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1759 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1761 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1762 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1764 Stage::GetCurrent().Add( imageView );
1766 // Trigger a potential relayout
1767 application.SendNotification();
1768 application.Render();
1770 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1771 Property::Map returnedMap;
1772 visual.CreatePropertyMap( returnedMap );
1774 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1775 DALI_TEST_CHECK( value );
1776 Property::Map* map = value->GetMap();
1777 DALI_TEST_CHECK( map );
1779 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1780 DALI_TEST_CHECK( value );
1781 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1783 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1784 DALI_TEST_CHECK( value );
1785 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1787 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1788 DALI_TEST_CHECK( value );
1789 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1794 int UtcDaliImageViewFittingModesFitWidth01(void)
1796 ToolkitTestApplication application;
1798 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )" );
1800 ImageView imageView = ImageView::New();
1801 Property::Map imageMap;
1802 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1803 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 600x600 image
1804 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1806 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1807 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,700) );
1809 Stage::GetCurrent().Add( imageView );
1811 // Trigger a potential relayout
1812 application.SendNotification();
1813 application.Render();
1815 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1816 Property::Map returnedMap;
1817 visual.CreatePropertyMap( returnedMap );
1819 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1820 DALI_TEST_CHECK( value );
1821 Property::Map* map = value->GetMap();
1822 DALI_TEST_CHECK( map );
1824 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1825 DALI_TEST_CHECK( value );
1826 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1828 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1829 DALI_TEST_CHECK( value );
1830 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1832 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1833 DALI_TEST_CHECK( value );
1834 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 50 ), TEST_LOCATION );
1839 int UtcDaliImageViewFittingModesFitWidth02(void)
1841 ToolkitTestApplication application;
1843 tet_infoline( "Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )" );
1845 ImageView imageView = ImageView::New();
1846 Property::Map imageMap;
1847 imageMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
1848 imageMap.Add( Toolkit::ImageVisual::Property::URL, gImage_600_RGB ); // 249x169 image
1849 imageMap.Add( DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
1851 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1852 imageView.SetProperty( Actor::Property::SIZE, Vector2(700,600) );
1854 Stage::GetCurrent().Add( imageView );
1856 // Trigger a potential relayout
1857 application.SendNotification();
1858 application.Render();
1860 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1861 Property::Map returnedMap;
1862 visual.CreatePropertyMap( returnedMap );
1864 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1865 DALI_TEST_CHECK( value );
1866 Property::Map* map = value->GetMap();
1867 DALI_TEST_CHECK( map );
1869 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1870 DALI_TEST_CHECK( value );
1871 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1873 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1874 DALI_TEST_CHECK( value );
1875 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1877 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1878 DALI_TEST_CHECK( value );
1879 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
1884 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
1886 ToolkitTestApplication application;
1888 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
1890 ImageView imageView = ImageView::New();
1892 // 1. Render using FittingMode::SHRINK_TO_FIT
1893 Property::Map imageMap;
1894 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1895 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1896 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1898 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
1899 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1901 Stage::GetCurrent().Add( imageView );
1903 // Trigger a potential relayout
1904 application.SendNotification();
1905 application.Render();
1907 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1908 Property::Map returnedMap;
1909 visual.CreatePropertyMap( returnedMap );
1911 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1912 DALI_TEST_CHECK( value );
1913 Property::Map* map = value->GetMap();
1914 DALI_TEST_CHECK( map );
1916 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1917 DALI_TEST_CHECK( value );
1918 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1920 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1921 DALI_TEST_CHECK( value );
1922 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1924 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1925 DALI_TEST_CHECK( value );
1926 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
1928 // 2. Render again using DevelVisaul::CENTER
1929 Property::Map imageMap2;
1930 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1931 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1932 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
1934 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
1935 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1937 Stage::GetCurrent().Add( imageView );
1939 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1941 // Trigger a potential relayout
1942 application.SendNotification();
1943 application.Render();
1945 returnedMap.Clear();
1946 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1948 visual.CreatePropertyMap( returnedMap );
1950 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1951 DALI_TEST_CHECK( value );
1952 map = value->GetMap();
1953 DALI_TEST_CHECK( map );
1955 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1956 DALI_TEST_CHECK( value );
1957 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
1959 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1960 DALI_TEST_CHECK( value );
1961 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1963 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
1964 DALI_TEST_CHECK( value );
1965 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
1967 // 3. Render again using before fittingMode
1968 Property::Map imageMap3;
1969 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1970 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
1971 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1973 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
1974 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
1976 Stage::GetCurrent().Add( imageView );
1978 // Trigger a potential relayout
1979 application.SendNotification();
1980 application.Render();
1982 returnedMap.Clear();
1983 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
1984 visual.CreatePropertyMap( returnedMap );
1986 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
1987 DALI_TEST_CHECK( value );
1988 map = value->GetMap();
1989 DALI_TEST_CHECK( map );
1991 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
1992 DALI_TEST_CHECK( value );
1993 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 700, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
1995 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
1996 DALI_TEST_CHECK( value );
1997 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
1999 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2000 DALI_TEST_CHECK( value );
2001 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 50, 0 ), TEST_LOCATION );
2006 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2008 ToolkitTestApplication application;
2010 tet_infoline( "UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]" );
2012 ImageView imageView = ImageView::New();
2014 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2015 Property::Map imageMap;
2016 imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2017 imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2018 imageMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2020 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2021 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2023 Stage::GetCurrent().Add( imageView );
2025 // Trigger a potential relayout
2026 application.SendNotification();
2027 application.Render();
2029 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2030 Property::Map returnedMap;
2031 visual.CreatePropertyMap( returnedMap );
2033 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2034 DALI_TEST_CHECK( value );
2035 Property::Map* map = value->GetMap();
2036 DALI_TEST_CHECK( map );
2038 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2039 DALI_TEST_CHECK( value );
2040 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2042 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2043 DALI_TEST_CHECK( value );
2044 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2046 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2047 DALI_TEST_CHECK( value );
2048 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2050 // 2. Render again using DevelVisaul::CENTER
2051 Property::Map imageMap2;
2052 imageMap2[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2053 imageMap2[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2054 imageMap2[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::CENTER;
2056 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap2 );
2057 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2059 Stage::GetCurrent().Add( imageView );
2061 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2063 // Trigger a potential relayout
2064 application.SendNotification();
2065 application.Render();
2067 returnedMap.Clear();
2068 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2070 visual.CreatePropertyMap( returnedMap );
2072 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2073 DALI_TEST_CHECK( value );
2074 map = value->GetMap();
2075 DALI_TEST_CHECK( map );
2077 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2078 DALI_TEST_CHECK( value );
2079 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 600, 600 ), TEST_LOCATION ); // Change the internal size according to the image view size
2081 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2082 DALI_TEST_CHECK( value );
2083 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2085 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2086 DALI_TEST_CHECK( value );
2087 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 100, 50 ), TEST_LOCATION );
2089 // 3. Render again using before fittingMode
2090 Property::Map imageMap3;
2091 imageMap3[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
2092 imageMap3[ Toolkit::ImageVisual::Property::URL ] = gImage_600_RGB;
2093 imageMap3[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2095 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap3 );
2096 imageView.SetProperty( Actor::Property::SIZE, Vector2(800,700) );
2098 Stage::GetCurrent().Add( imageView );
2100 // Trigger a potential relayout
2101 application.SendNotification();
2102 application.Render();
2104 returnedMap.Clear();
2105 visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2106 visual.CreatePropertyMap( returnedMap );
2108 value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2109 DALI_TEST_CHECK( value );
2110 map = value->GetMap();
2111 DALI_TEST_CHECK( map );
2113 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2114 DALI_TEST_CHECK( value );
2115 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 800, 700 ), TEST_LOCATION ); // Change the internal size according to the image view size
2117 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2118 DALI_TEST_CHECK( value );
2119 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2121 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2122 DALI_TEST_CHECK( value );
2123 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION );
2128 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2130 ToolkitTestApplication application;
2132 tet_infoline( "Create an ImageVisual using ScaleToFill and animated vector image ( image: [600,600], view:[600,600] )" );
2134 ImageView imageView = ImageView::New();
2135 Property::Map imageMap;
2136 imageMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE );
2137 imageMap.Add( Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); // 249x169 image
2139 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
2140 imageView.SetProperty( Actor::Property::SIZE, Vector2(600,600) );
2142 Stage::GetCurrent().Add( imageView );
2144 // Trigger a potential relayout
2145 application.SendNotification();
2146 application.Render();
2148 Toolkit::Visual::Base visual = DevelControl::GetVisual( Toolkit::Internal::GetImplementation( imageView ), Toolkit::ImageView::Property::IMAGE );
2149 Property::Map returnedMap;
2150 visual.CreatePropertyMap( returnedMap );
2152 Property::Value* value = returnedMap.Find( Toolkit::Visual::Property::TRANSFORM );
2153 DALI_TEST_CHECK( value );
2154 Property::Map* map = value->GetMap();
2155 DALI_TEST_CHECK( map );
2157 value = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2158 DALI_TEST_CHECK( value );
2159 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2::ONE, TEST_LOCATION ); // Relative size so will take up 100%
2161 value = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2162 DALI_TEST_CHECK( value );
2163 DALI_TEST_CHECK( value->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
2165 value = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2166 DALI_TEST_CHECK( value );
2167 DALI_TEST_EQUALS( value->Get< Vector2 >(), Vector2( 0, 0 ), TEST_LOCATION ); // OFFSET is zero
2173 int UtcDaliImageViewCustomShader(void)
2175 ToolkitTestApplication application;
2177 // Set a custom shader with an image url
2179 Property::Map properties;
2180 Property::Map shader;
2181 const std::string vertexShader = "Foobar";
2182 const std::string fragmentShader = "Foobar";
2183 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2184 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2186 properties[Visual::Property::TYPE] = Visual::IMAGE;
2187 properties[Visual::Property::SHADER] = shader;
2188 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2190 ImageView imageView = ImageView::New();
2191 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2193 Stage::GetCurrent().Add( imageView );
2195 application.SendNotification();
2196 application.Render();
2198 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2200 Renderer renderer = imageView.GetRendererAt( 0 );
2201 Shader shader2 = renderer.GetShader();
2202 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2203 Property::Map* map = value.GetMap();
2204 DALI_TEST_CHECK( map );
2206 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2207 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2209 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2210 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2213 // Set a custom shader after setting an image url
2215 Property::Map properties;
2216 Property::Map shader;
2217 const std::string vertexShader = "Foobar";
2218 const std::string fragmentShader = "Foobar";
2219 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2220 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2222 properties[Visual::Property::SHADER] = shader;
2224 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
2225 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2227 Stage::GetCurrent().Add( imageView );
2229 application.SendNotification();
2230 application.Render();
2232 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2234 Renderer renderer = imageView.GetRendererAt( 0 );
2235 Shader shader2 = renderer.GetShader();
2236 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2237 Property::Map* map = value.GetMap();
2238 DALI_TEST_CHECK( map );
2240 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2241 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2243 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2244 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2247 // Set a custom shader before setting an image url
2249 Property::Map properties;
2250 Property::Map shader;
2251 const std::string vertexShader = "Foobar";
2252 const std::string fragmentShader = "Foobar";
2253 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2254 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2256 properties[Visual::Property::SHADER] = shader;
2258 ImageView imageView = ImageView::New();
2259 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2260 imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME );
2262 Stage::GetCurrent().Add( imageView );
2264 application.SendNotification();
2265 application.Render();
2266 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2268 Renderer renderer = imageView.GetRendererAt( 0 );
2269 Shader shader2 = renderer.GetShader();
2270 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2271 Property::Map* map = value.GetMap();
2272 DALI_TEST_CHECK( map );
2274 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2275 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2277 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2278 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2281 // Set a custom shader after setting a property map
2283 Property::Map properties;
2284 Property::Map shader;
2285 const std::string vertexShader = "Foobar";
2286 const std::string fragmentShader = "Foobar";
2287 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2288 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2290 properties[Visual::Property::SHADER] = shader;
2292 Property::Map properties1;
2293 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2294 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2296 ImageView imageView = ImageView::New();
2297 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2298 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2300 Stage::GetCurrent().Add( imageView );
2302 application.SendNotification();
2303 application.Render();
2304 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2306 Renderer renderer = imageView.GetRendererAt( 0 );
2307 Shader shader2 = renderer.GetShader();
2308 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2309 Property::Map* map = value.GetMap();
2310 DALI_TEST_CHECK( map );
2312 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2313 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2315 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2316 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2319 // Set a custom shader before setting a property map
2321 Property::Map properties;
2322 Property::Map shader;
2323 const std::string vertexShader = "Foobar";
2324 const std::string fragmentShader = "Foobar";
2325 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2326 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2328 properties[Visual::Property::SHADER] = shader;
2330 Property::Map properties1;
2331 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2332 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2334 ImageView imageView = ImageView::New();
2335 imageView.SetProperty( ImageView::Property::IMAGE, properties );
2336 imageView.SetProperty( ImageView::Property::IMAGE, properties1 );
2338 Stage::GetCurrent().Add( imageView );
2340 application.SendNotification();
2341 application.Render();
2342 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2344 Renderer renderer = imageView.GetRendererAt( 0 );
2345 Shader shader2 = renderer.GetShader();
2346 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2347 Property::Map* map = value.GetMap();
2348 DALI_TEST_CHECK( map );
2350 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2351 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2353 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2354 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2363 static int gFailCounter = 0;
2364 const int MAX_RETRIES(3);
2366 void ReloadImage(ImageView imageView)
2368 Property::Map imageImmediateLoadingMap;
2369 imageImmediateLoadingMap[ ImageVisual::Property::URL ] = "Non-existant-image.jpg";
2370 imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] = ImageVisual::LoadPolicy::IMMEDIATE;
2372 tet_infoline("Immediate load an image");
2373 imageView.SetProperty( ImageView::Property::IMAGE, imageImmediateLoadingMap );
2376 void ResourceFailedReload( Control control )
2379 if( gFailCounter < MAX_RETRIES )
2381 ReloadImage(ImageView::DownCast(control));
2386 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2388 tet_infoline("Test reloading failed image from within signal handler.");
2390 ToolkitTestApplication application;
2394 ImageView imageView = ImageView::New();
2395 imageView.ResourceReadySignal().Connect( &ResourceFailedReload );
2396 DALI_TEST_EQUALS( gFailCounter, 0, TEST_LOCATION );
2397 ReloadImage(imageView);
2399 // loading started, this waits for the loader thread to complete
2400 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2401 application.SendNotification();
2403 DALI_TEST_EQUALS( gFailCounter, 1, TEST_LOCATION );
2405 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2406 application.SendNotification();
2408 DALI_TEST_EQUALS( gFailCounter, 2, TEST_LOCATION );
2410 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2411 application.SendNotification();
2412 DALI_TEST_EQUALS( gFailCounter, 3, TEST_LOCATION );
2417 int UtcDaliImageViewLoadRemoteSVG(void)
2419 tet_infoline("Test load from a remote server.");
2421 ToolkitTestApplication application;
2422 Toolkit::ImageView imageView;
2423 imageView = Toolkit::ImageView::New( );
2424 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2425 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2426 imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2427 imageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2428 imageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2429 imageView.SetProperty( Actor::Property::SIZE, Vector2(300, 300) );
2430 imageView.SetProperty( Actor::Property::POSITION, Vector3( 150.0f , 150.0f , 0.0f ) );
2432 Stage::GetCurrent().Add( imageView );
2434 DALI_TEST_CHECK( imageView );
2436 DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
2438 application.SendNotification();
2440 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
2450 int UtcDaliImageViewSyncSVGLoading(void)
2452 ToolkitTestApplication application;
2454 tet_infoline("ImageView Testing SVG image sync loading");
2456 // Sync loading, automatic atlasing for small size image
2458 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2460 callStack.Enable(true);
2462 ImageView imageView = ImageView::New( );
2464 // Sync loading is used
2465 Property::Map syncLoadingMap;
2466 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2467 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2468 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2469 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2471 Stage::GetCurrent().Add( imageView );
2472 DALI_TEST_CHECK( imageView );
2474 application.SendNotification();
2475 application.Render(16);
2476 Vector3 naturalSize = imageView.GetNaturalSize();
2478 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2479 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2485 int UtcDaliImageViewAsyncSVGLoading(void)
2487 ToolkitTestApplication application;
2489 tet_infoline("ImageView Testing SVG image async loading");
2491 // Sync loading, automatic atlasing for small size image
2493 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2495 callStack.Enable(true);
2497 ImageView imageView = ImageView::New( );
2499 // Sync loading is used
2500 Property::Map syncLoadingMap;
2501 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2502 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2503 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2504 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2506 Stage::GetCurrent().Add( imageView );
2507 DALI_TEST_CHECK( imageView );
2509 application.SendNotification();
2510 application.Render(16);
2511 Vector3 naturalSize = imageView.GetNaturalSize();
2513 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2514 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2519 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2521 ToolkitTestApplication application;
2523 tet_infoline("ImageView Testing SVG image async loading");
2525 // Sync loading, automatic atlasing for small size image
2527 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2529 callStack.Enable(true);
2531 ImageView imageView = ImageView::New( );
2533 // Sync loading is used
2534 Property::Map syncLoadingMap;
2535 syncLoadingMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
2536 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg" );
2538 // Check to set invalid value
2539 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2540 // Check if error log is outputted when setting other value like string.
2541 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2542 syncLoadingMap.Insert( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5) );
2543 imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
2545 Stage::GetCurrent().Add( imageView );
2546 DALI_TEST_CHECK( imageView );
2548 application.SendNotification();
2549 application.Render(16);
2550 Vector3 naturalSize = imageView.GetNaturalSize();
2551 DALI_TEST_EQUALS( naturalSize.width, 100.0f, TEST_LOCATION );
2552 DALI_TEST_EQUALS( naturalSize.height, 100.0f, TEST_LOCATION );
2554 Property::Value value = imageView.GetProperty( ImageView::Property::IMAGE );
2555 Property::Map* map = value.GetMap();
2556 DALI_TEST_CHECK( map );
2558 Property::Value* sync = map->Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING );
2559 DALI_TEST_CHECK( sync );
2560 DALI_TEST_EQUALS( false, sync->Get< bool >(), TEST_LOCATION );
2566 int UtcDaliImageViewSvgLoadingFailure(void)
2568 ToolkitTestApplication application;
2572 gResourceReadySignalFired = false;
2574 ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/Kid1.svg" );
2575 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2576 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2578 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2580 Stage::GetCurrent().Add( imageView );
2582 application.SendNotification();
2584 // loading started, this waits for the loader thread
2585 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2587 application.SendNotification();
2588 application.Render(16);
2590 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2591 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2592 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2597 gResourceReadySignalFired = false;
2599 ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
2600 imageView.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2601 imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
2603 DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
2605 Stage::GetCurrent().Add( imageView );
2607 application.SendNotification();
2609 // loading started, this waits for the loader thread
2610 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2612 application.SendNotification();
2613 application.Render(16);
2615 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2616 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
2617 DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
2626 static int gResourceReadySignalCounter = 0;
2628 void OnResourceReadySignal( Control control )
2630 gResourceReadySignalCounter++;
2632 if( gResourceReadySignalCounter == 1 )
2635 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2636 ImageView::DownCast( control ).SetImage( gImage_34_RGBA );
2642 int UtcDaliImageViewSetImageOnResourceReadySignal(void)
2644 tet_infoline("Test setting image from within signal handler.");
2646 ToolkitTestApplication application;
2648 gResourceReadySignalCounter = 0;
2650 ImageView imageView = ImageView::New( gImage_34_RGBA );
2651 imageView.ResourceReadySignal().Connect( &OnResourceReadySignal );
2653 Stage::GetCurrent().Add( imageView );
2655 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2657 application.SendNotification();
2658 application.Render();
2660 DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
2662 DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );