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.
21 #include <toolkit-event-thread-callback.h>
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
27 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
28 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
29 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
30 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
32 #include <dali-toolkit/devel-api/visuals/text-visual-properties-devel.h>
33 #include <dali-toolkit/devel-api/visuals/animated-gradient-visual-properties-devel.h>
34 #include <dali-toolkit/dali-toolkit.h>
36 #include "dummy-control.h"
39 using namespace Dali::Toolkit;
43 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
44 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
45 const char* TEST_NPATCH_FILE_NAME = TEST_RESOURCE_DIR "/button-up.9.png";
46 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
47 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
48 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
49 const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
52 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
54 Property::Map DefaultTransform()
56 Property::Map transformMap;
58 .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
59 .Add( Toolkit::Visual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
60 .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
61 .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN )
62 .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) )
63 .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
67 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
69 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
71 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
73 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
75 Property::Value* valueSet = NULL;
76 if ( valueGet.first.type == Property::Key::INDEX )
78 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
82 // Get Key is a string so searching Set Map for a string key
83 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
86 if( NULL != valueSet )
88 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
90 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
93 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
95 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
98 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
100 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
103 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
105 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
108 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
110 Vector2 vector2Get = valueGet.second.Get<Vector2>();
111 Vector2 vector2Set = valueSet->Get<Vector2>();
112 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
115 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
117 Vector4 vector4Get = valueGet.second.Get<Vector4>();
118 Vector4 vector4Set = valueSet->Get<Vector4>();
119 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
125 if ( valueGet.first.type == Property::Key::INDEX )
127 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
131 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
141 void PrepareResourceImage( ToolkitTestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
143 TestPlatformAbstraction& platform = application.GetPlatform();
144 platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
146 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
147 Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
148 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
149 unsigned int initialColor = 0xFF;
150 memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
152 Integration::ResourcePointer resourcePtr(bitmap);
153 platform.SetSynchronouslyLoadedResource( resourcePtr );
157 void dali_visual_startup(void)
159 test_return_value = TET_UNDEF;
162 void dali_visual_cleanup(void)
164 test_return_value = TET_PASS;
168 static void TestMixColor( Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor )
171 visual.CreatePropertyMap(map);
172 Property::Value* value = map.Find( mixColorIndex );
173 DALI_TEST_CHECK( value );
175 DALI_TEST_CHECK( value->Get( mixColor1 ) );
176 DALI_TEST_EQUALS( mixColor1, Vector3(testColor), 0.001, TEST_LOCATION );
178 value = map.Find( Visual::Property::MIX_COLOR );
179 DALI_TEST_CHECK( value );
181 DALI_TEST_CHECK( value->Get( mixColor2 ) );
182 DALI_TEST_EQUALS( mixColor2, testColor, 0.001, TEST_LOCATION );
184 value = map.Find( Visual::Property::OPACITY );
185 DALI_TEST_CHECK( value );
187 DALI_TEST_CHECK( value->Get( opacity ) );
188 DALI_TEST_EQUALS( opacity, testColor.a, 0.001, TEST_LOCATION );
192 int UtcDaliVisualCopyAndAssignment(void)
194 ToolkitTestApplication application;
195 tet_infoline( "UtcDaliVisualCopyAndAssignment" );
197 VisualFactory factory = VisualFactory::Get();
198 Property::Map propertyMap;
199 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
200 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
201 Visual::Base visual = factory.CreateVisual( propertyMap );
203 Visual::Base visualCopy( visual );
204 DALI_TEST_CHECK(visual == visualCopy);
206 Visual::Base emptyVisual;
207 Visual::Base emptyVisualCopy( emptyVisual );
208 DALI_TEST_CHECK(emptyVisual == emptyVisualCopy);
210 Visual::Base visualEquals;
211 visualEquals = visual;
212 DALI_TEST_CHECK(visual == visualEquals);
214 Visual::Base emptyVisualEquals;
215 emptyVisualEquals = emptyVisual;
216 DALI_TEST_CHECK( emptyVisual == emptyVisualEquals );
220 DALI_TEST_CHECK( visual = visualCopy );
225 int UtcDaliVisualSetName01(void)
227 ToolkitTestApplication application;
228 tet_infoline( "UtcDaliVisualSetName" );
230 VisualFactory factory = VisualFactory::Get();
231 Property::Map propertyMap;
232 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
233 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
234 Visual::Base visual = factory.CreateVisual( propertyMap );
236 const char* visualName = "backgroundVisual";
237 visual.SetName( visualName );
239 DALI_TEST_EQUALS( visual.GetName(), visualName, TEST_LOCATION );
244 int UtcDaliVisualSetGetDepthIndex(void)
246 ToolkitTestApplication application;
247 tet_infoline( "UtcDaliVisualSetDepthIndex" );
249 VisualFactory factory = VisualFactory::Get();
250 Property::Map propertyMap;
251 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
252 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
253 Visual::Base visual = factory.CreateVisual( propertyMap );
255 visual.SetDepthIndex( 1 );
257 DummyControl dummyControl = DummyControl::New(true);
258 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
259 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
261 dummyControl.SetSize(200.f, 200.f);
262 Stage::GetCurrent().Add( dummyControl );
265 int depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
266 DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
267 DALI_TEST_EQUALS( visual.GetDepthIndex(), 1, TEST_LOCATION );
269 visual.SetDepthIndex( -1 );
270 depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
271 DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
272 DALI_TEST_EQUALS( visual.GetDepthIndex(), -1, TEST_LOCATION );
277 int UtcDaliVisualSize(void)
279 ToolkitTestApplication application;
280 tet_infoline( "UtcDaliVisualSize" );
282 VisualFactory factory = VisualFactory::Get();
283 Vector2 controlSize( 20.f, 30.f );
287 Dali::Property::Map map;
288 map[ Toolkit::Visual::Property::TYPE ] = Visual::COLOR;
289 map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
291 Visual::Base colorVisual = factory.CreateVisual( map );
292 colorVisual.SetTransformAndSize(DefaultTransform(), controlSize );
294 colorVisual.GetNaturalSize(naturalSize);
295 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
298 PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
299 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
300 Visual::Base imageVisual = factory.CreateVisual( image );
301 imageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
303 imageVisual.GetNaturalSize(naturalSize);
304 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
306 // n patch visual is tested in the utc-Dali-VisualFactory.cpp
309 float borderSize = 5.f;
311 map[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
312 map[ BorderVisual::Property::COLOR ] = Color::RED;
313 map[ BorderVisual::Property::SIZE ] = borderSize;
314 Visual::Base borderVisual = factory.CreateVisual( map );
315 borderVisual.SetTransformAndSize(DefaultTransform(), controlSize );
316 borderVisual.GetNaturalSize(naturalSize);
317 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
319 // gradient gradientVisual
320 Property::Map propertyMap;
321 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
322 Vector2 start(-1.f, -1.f);
323 Vector2 end(1.f, 1.f);
324 propertyMap.Insert( "mixColor", Color::MAGENTA );
325 propertyMap.Insert( GradientVisual::Property::START_POSITION, start) ;
326 propertyMap.Insert( GradientVisual::Property::END_POSITION, end );
327 propertyMap.Insert( GradientVisual::Property::STOP_OFFSET, Vector2(0.f, 1.f) );
328 propertyMap.Insert( GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT) ;
329 Property::Array stopColors;
330 stopColors.PushBack( Color::RED );
331 stopColors.PushBack( Color::GREEN );
332 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
333 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
334 gradientVisual.SetTransformAndSize(DefaultTransform(), controlSize );
335 gradientVisual.GetNaturalSize(naturalSize);
336 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
338 // animated gradient visual
339 Vector2 animated_gradient_visual_size(10.f, 10.f);
341 propertyMap.Insert( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT );
342 Visual::Base animatedGradientVisual = factory.CreateVisual( propertyMap );
343 animatedGradientVisual.GetNaturalSize(naturalSize);
344 animatedGradientVisual.SetTransformAndSize(DefaultTransform(), controlSize );
345 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
348 Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
349 svgVisual.GetNaturalSize(naturalSize);
351 // <svg width="100" height="100">
352 // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
354 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
356 // svg visual with a size
357 Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
358 svgVisual2.GetNaturalSize(naturalSize);
359 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
363 // Load some fonts to get the same metrics on different platforms.
364 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
365 fontClient.SetDpi( 96u, 96u );
367 char* pathNamePtr = get_current_dir_name();
368 const std::string pathName( pathNamePtr );
371 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
373 // Create a TextVisual with a font size of 12 first
375 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
376 propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
377 propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
378 propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
380 Visual::Base smallTextVisual = factory.CreateVisual( propertyMap );
381 Vector2 smallTextVisualNaturalSize;
382 smallTextVisual.GetNaturalSize( smallTextVisualNaturalSize );
384 // Then create a TextVisual with a font size of 20
385 propertyMap[ TextVisual::Property::TEXT ] = "<font family='TizenSans' size='20'>Hello world</font>";
386 Visual::Base largeTextVisual = factory.CreateVisual( propertyMap );
387 Vector2 largeTextVisualNaturalSize;
388 largeTextVisual.GetNaturalSize( largeTextVisualNaturalSize );
390 // Compare the sizes of the two text visuals, the second one should be bigger as it has a larger point size in the markup.
391 DALI_TEST_CHECK( smallTextVisualNaturalSize.width < largeTextVisualNaturalSize.width &&
392 smallTextVisualNaturalSize.height < largeTextVisualNaturalSize.height );
394 // The height returned for a particular width should also be greater for the large text visual
395 DALI_TEST_CHECK( smallTextVisual.GetHeightForWidth( 40.f ) < largeTextVisual.GetHeightForWidth( 40.f ) );
397 //AnimatedImageVisual
398 Visual::Base animatedImageVisual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
399 animatedImageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
400 animatedImageVisual.GetNaturalSize(naturalSize);
401 // TEST_GIF_FILE: anim.gif
402 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
403 DALI_TEST_EQUALS( naturalSize, Vector2(50.f, 50.f), TEST_LOCATION );
408 int UtcDaliVisualSetOnOffStage(void)
410 ToolkitTestApplication application;
411 tet_infoline( "UtcDaliVisualSetOnOffStage" );
413 VisualFactory factory = VisualFactory::Get();
414 Property::Map propertyMap;
415 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
416 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
417 Visual::Base visual = factory.CreateVisual( propertyMap );
419 DummyControl actor = DummyControl::New(true);
420 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
421 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
423 actor.SetSize(200.f, 200.f);
425 application.SendNotification();
426 application.Render(0);
427 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
429 Stage::GetCurrent().Add( actor );
431 application.SendNotification();
432 application.Render(0);
433 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
435 Stage::GetCurrent().Remove( actor );
437 application.SendNotification();
438 application.Render(0);
439 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
444 int UtcDaliVisualSetOnOffStage2(void)
446 ToolkitTestApplication application;
447 tet_infoline( "UtcDaliVisualSetOnOffStage2" );
449 VisualFactory factory = VisualFactory::Get();
450 Property::Map propertyMap;
451 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG );
452 propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
453 Visual::Base visual = factory.CreateVisual( propertyMap );
455 DummyControl actor = DummyControl::New(true);
456 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
457 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
459 actor.SetSize(200.f, 200.f);
461 application.SendNotification();
462 application.Render(0);
463 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
466 Stage::GetCurrent().Add( actor );
468 application.SendNotification();
469 application.Render(0);
470 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
471 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
472 Renderer renderer = actor.GetRendererAt( 0 );
473 auto textures = renderer.GetTextures();
474 DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
476 Stage::GetCurrent().Remove( actor );
478 application.SendNotification();
479 application.Render(0);
480 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
483 Stage::GetCurrent().Add( actor );
485 application.SendNotification();
486 application.Render(0);
487 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
488 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
489 renderer = actor.GetRendererAt( 0 );
490 textures = renderer.GetTextures();
491 DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
493 Stage::GetCurrent().Remove( actor );
495 application.SendNotification();
496 application.Render(0);
497 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
502 int UtcDaliVisualGetPropertyMap1(void)
504 ToolkitTestApplication application;
505 tet_infoline( "UtcDaliVisualGetPropertyMap1: ColorVisual (With base MixColor" );
507 VisualFactory factory = VisualFactory::Get();
508 Property::Map propertyMap;
509 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
510 propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE);
511 propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 10.0f );
512 propertyMap.Insert( DevelColorVisual::Property::BLUR_RADIUS, 20.0f );
513 Visual::Base colorVisual = factory.CreateVisual( propertyMap );
515 Property::Map resultMap;
516 colorVisual.CreatePropertyMap( resultMap );
518 Property::Value* typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
519 DALI_TEST_CHECK( typeValue );
520 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::COLOR );
522 Property::Value* colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
523 DALI_TEST_CHECK( colorValue );
524 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
526 Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
527 DALI_TEST_CHECK( cornerRadiusValue );
528 DALI_TEST_CHECK( cornerRadiusValue->Get< float >() == 10.0f );
530 Property::Value* blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
531 DALI_TEST_CHECK( blurRadiusValue );
532 DALI_TEST_CHECK( blurRadiusValue->Get< float >() == 20.0f );
534 // change the blend color
535 propertyMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
536 colorVisual = factory.CreateVisual( propertyMap );
537 colorVisual.CreatePropertyMap( resultMap );
539 colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
540 DALI_TEST_CHECK( colorValue );
541 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
544 propertyMap[DevelColorVisual::Property::BLUR_RADIUS] = "3.0f";
546 colorVisual = factory.CreateVisual( propertyMap );
547 colorVisual.CreatePropertyMap( resultMap );
549 blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
550 DALI_TEST_CHECK( blurRadiusValue );
551 DALI_TEST_CHECK( blurRadiusValue->Get< float >() == 0.0f );
556 int UtcDaliVisualGetPropertyMap2(void)
558 ToolkitTestApplication application;
559 tet_infoline( "UtcDaliVisualGetPropertyMap2: BorderVisual" );
561 VisualFactory factory = VisualFactory::Get();
562 Property::Map propertyMap;
563 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
564 propertyMap.Insert("mixColor", Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
565 propertyMap.Insert("borderColor", Color::BLUE);
566 propertyMap.Insert("borderSize", 5.f);
567 propertyMap.Insert("antiAliasing", true);
568 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
570 Property::Map resultMap;
571 borderVisual.CreatePropertyMap( resultMap );
573 // check the property values from the returned map from visual
574 Property::Value* typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
575 DALI_TEST_CHECK( typeValue );
576 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
578 Property::Value* colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
579 DALI_TEST_CHECK( colorValue );
580 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
582 Property::Value* sizeValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
583 DALI_TEST_CHECK( sizeValue );
584 DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
586 Property::Value* AAValue = resultMap.Find( BorderVisual::Property::ANTI_ALIASING, Property::BOOLEAN );
587 DALI_TEST_CHECK( AAValue );
588 DALI_TEST_CHECK( AAValue->Get<bool>() == true );
590 Property::Map propertyMap1;
591 propertyMap1[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
592 propertyMap1[ BorderVisual::Property::COLOR ] = Color::CYAN;
593 propertyMap1[ BorderVisual::Property::SIZE ] = 10.0f;
594 borderVisual = factory.CreateVisual( propertyMap1 );
595 borderVisual.CreatePropertyMap( resultMap );
597 typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
598 DALI_TEST_CHECK( typeValue );
599 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
601 colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
602 DALI_TEST_CHECK( colorValue );
603 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
605 colorValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
606 DALI_TEST_CHECK( colorValue );
607 DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
613 int UtcDaliVisualGetPropertyMap2N(void)
615 ToolkitTestApplication application;
616 tet_infoline( "UtcDaliVisualGetPropertyMap2N: BorderVisual with no setup properties" );
618 VisualFactory factory = VisualFactory::Get();
619 Property::Map propertyMap;
620 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
621 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
623 tet_infoline( "Test that the visual is created, with a default renderer" );
624 DALI_TEST_CHECK( borderVisual );
626 DummyControl dummyControl = DummyControl::New(true);
627 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
628 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
629 Stage::GetCurrent().Add( dummyControl );
631 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
637 int UtcDaliVisualGetPropertyMap3(void)
639 ToolkitTestApplication application;
640 tet_infoline( "UtcDaliVisualGetPropertyMap3: linear GradientVisual" );
642 VisualFactory factory = VisualFactory::Get();
643 DALI_TEST_CHECK( factory );
645 Property::Map propertyMap;
646 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
648 Vector2 start(-1.f, -1.f);
649 Vector2 end(1.f, 1.f);
650 propertyMap.Insert( "startPosition", start);
651 propertyMap.Insert( "endPosition", end);
652 propertyMap.Insert( "spreadMethod", GradientVisual::SpreadMethod::REPEAT);
654 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.2f, 0.8f));
656 Property::Array stopColors;
657 stopColors.PushBack( Color::RED );
658 stopColors.PushBack( Color::GREEN );
659 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
661 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
663 Property::Map resultMap;
664 gradientVisual.CreatePropertyMap( resultMap );
666 // check the property values from the returned map from visual
667 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
668 DALI_TEST_CHECK( value );
669 DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
671 value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
672 DALI_TEST_CHECK( value );
673 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::OBJECT_BOUNDING_BOX );
675 value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
676 DALI_TEST_CHECK( value );
677 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::REPEAT );
679 value = resultMap.Find( GradientVisual::Property::START_POSITION, Property::VECTOR2 );
680 DALI_TEST_CHECK( value );
681 DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
683 value = resultMap.Find( GradientVisual::Property::END_POSITION, Property::VECTOR2 );
684 DALI_TEST_CHECK( value );
685 DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
687 value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
688 DALI_TEST_CHECK( value );
689 Property::Array* offsetArray = value->GetArray();
690 DALI_TEST_CHECK( offsetArray->Count() == 2 );
691 DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
692 DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
694 value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
695 DALI_TEST_CHECK( value );
696 Property::Array* colorArray = value->GetArray();
697 DALI_TEST_CHECK( colorArray->Count() == 2 );
698 DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
699 DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
704 int UtcDaliVisualGetPropertyMap4(void)
706 ToolkitTestApplication application;
707 tet_infoline( "UtcDaliVisualGetPropertyMap4: radial GradientVisual" );
709 VisualFactory factory = VisualFactory::Get();
710 DALI_TEST_CHECK( factory );
712 Property::Map propertyMap;
713 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
715 Vector2 center(100.f, 100.f);
716 float radius = 100.f;
717 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
718 propertyMap.Insert(GradientVisual::Property::CENTER, center);
719 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
720 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector3(0.1f, 0.3f, 1.1f));
722 Property::Array stopColors;
723 stopColors.PushBack( Color::RED );
724 stopColors.PushBack( Color::BLACK );
725 stopColors.PushBack( Color::GREEN );
726 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
728 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
729 DALI_TEST_CHECK( gradientVisual );
731 Property::Map resultMap;
732 gradientVisual.CreatePropertyMap( resultMap );
734 // check the property values from the returned map from visual
735 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
736 DALI_TEST_CHECK( value );
737 DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
739 value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
740 DALI_TEST_CHECK( value );
741 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::USER_SPACE );
743 value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
744 DALI_TEST_CHECK( value );
745 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::PAD );
747 value = resultMap.Find( GradientVisual::Property::CENTER, Property::VECTOR2 );
748 DALI_TEST_CHECK( value );
749 DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
751 value = resultMap.Find( GradientVisual::Property::RADIUS, Property::FLOAT );
752 DALI_TEST_CHECK( value );
753 DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
755 value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
756 DALI_TEST_CHECK( value );
757 Property::Array* offsetArray = value->GetArray();
758 DALI_TEST_CHECK( offsetArray->Count() == 3 );
759 DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
760 DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
761 // any stop value will be clamped to [0.0, 1.0];
762 DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
764 value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
765 DALI_TEST_CHECK( value );
766 Property::Array* colorArray = value->GetArray();
767 DALI_TEST_CHECK( colorArray->Count() == 3 );
768 DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
769 DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
770 DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
775 int UtcDaliVisualGetPropertyMap5(void)
777 ToolkitTestApplication application;
778 tet_infoline( "UtcDaliVisualGetPropertyMap5: ImageVisual" );
780 VisualFactory factory = VisualFactory::Get();
781 Property::Map propertyMap;
782 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
783 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::MAGENTA );
784 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
785 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
786 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
787 propertyMap.Insert( "fittingMode", FittingMode::FIT_HEIGHT );
788 propertyMap.Insert( "samplingMode", SamplingMode::BOX_THEN_NEAREST );
789 propertyMap.Insert( "pixelArea", Vector4( 0.25f, 0.25f, 0.5f, 0.5f ) );
790 propertyMap.Insert( "wrapModeU", WrapMode::REPEAT );
791 propertyMap.Insert( "wrapModeV", WrapMode::MIRRORED_REPEAT );
792 propertyMap.Insert( "synchronousLoading", true );
794 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
795 DALI_TEST_CHECK( imageVisual );
797 Property::Map resultMap;
798 imageVisual.CreatePropertyMap( resultMap );
800 // check the property values from the returned map from visual
801 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
802 DALI_TEST_CHECK( value );
803 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
805 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
806 DALI_TEST_CHECK( value );
807 DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
809 value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
810 DALI_TEST_CHECK( value );
811 DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
813 value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
814 DALI_TEST_CHECK( value );
815 DALI_TEST_CHECK( value->Get<int>() == FittingMode::FIT_HEIGHT );
817 value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
818 DALI_TEST_CHECK( value );
819 DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX_THEN_NEAREST );
821 value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
822 DALI_TEST_CHECK( value );
823 DALI_TEST_CHECK( value->Get<int>() == 20 );
825 value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
826 DALI_TEST_CHECK( value );
827 DALI_TEST_CHECK( value->Get<int>() == 30 );
829 value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
830 DALI_TEST_CHECK( value );
831 DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.25f, 0.25f, 0.5f, 0.5f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
833 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
834 DALI_TEST_CHECK( value );
835 DALI_TEST_CHECK( value->Get<int>() == WrapMode::REPEAT);
837 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
838 DALI_TEST_CHECK( value );
839 DALI_TEST_CHECK( value->Get<int>() == WrapMode::MIRRORED_REPEAT);
841 value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
842 DALI_TEST_CHECK( value );
843 DALI_TEST_CHECK( value->Get<bool>() == true );
845 // Get an image visual with an image handle, and test the default property values
846 PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
847 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
848 imageVisual = factory.CreateVisual(image);
849 imageVisual.CreatePropertyMap( resultMap );
851 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
852 DALI_TEST_CHECK( value );
853 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
855 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
856 DALI_TEST_CHECK( value );
857 DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
859 value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
860 DALI_TEST_CHECK( value );
861 DALI_TEST_CHECK( value->Get<int>() == FittingMode::SHRINK_TO_FIT );
863 value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
864 DALI_TEST_CHECK( value );
865 DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX );
867 value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
868 DALI_TEST_CHECK( value );
869 DALI_TEST_CHECK( value->Get<int>() == 100 );
871 value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
872 DALI_TEST_CHECK( value );
873 DALI_TEST_CHECK( value->Get<int>() == 200 );
875 value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
876 DALI_TEST_CHECK( value );
877 DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.f, 0.f, 1.f, 1.f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
879 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
880 DALI_TEST_CHECK( value );
881 DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
883 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
884 DALI_TEST_CHECK( value );
885 DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
887 value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
888 DALI_TEST_CHECK( value );
889 DALI_TEST_CHECK( value->Get<bool>() == false );
894 int UtcDaliVisualGetPropertyMap6(void)
896 ToolkitTestApplication application;
897 tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" );
899 Rect< int > border( 1, 1, 1, 1 );
901 VisualFactory factory = VisualFactory::Get();
902 Property::Map propertyMap;
903 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
904 propertyMap.Insert( "mixColor", Color::MAGENTA );
905 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
906 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
907 propertyMap.Insert( ImageVisual::Property::BORDER, border );
908 propertyMap.Insert( DevelImageVisual::Property::AUXILIARY_IMAGE, "application-icon-30.png" );
909 propertyMap.Insert( DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, 0.9f );
910 Visual::Base nPatchVisual = factory.CreateVisual( propertyMap );
912 Property::Map resultMap;
913 nPatchVisual.CreatePropertyMap( resultMap );
915 // check the property values from the returned map from visual
916 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
917 DALI_TEST_CHECK( value );
918 DALI_TEST_CHECK( value->Get<int>() == Visual::N_PATCH );
920 value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
921 DALI_TEST_CHECK( value );
922 DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
924 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
925 DALI_TEST_CHECK( value );
926 DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
928 value = resultMap.Find( ImageVisual::Property::BORDER_ONLY, Property::BOOLEAN );
929 DALI_TEST_CHECK( value );
930 DALI_TEST_CHECK( value->Get<bool>() );
932 value = resultMap.Find( ImageVisual::Property::BORDER, Property::RECTANGLE );
933 DALI_TEST_CHECK( value );
934 DALI_TEST_CHECK( value->Get< Rect< int > >() == border );
936 value = resultMap.Find( DevelImageVisual::Property::AUXILIARY_IMAGE, Property::STRING );
937 DALI_TEST_CHECK( value );
938 DALI_TEST_CHECK( value->Get<std::string>() == "application-icon-30.png" );
940 value = resultMap.Find( DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, Property::FLOAT );
941 DALI_TEST_CHECK( value );
942 DALI_TEST_CHECK( value->Get<float>() == 0.9f );
944 Vector4 border1( 1.0f, 1.0f, 1.0f, 1.0f );
946 Property::Map propertyMap1;
947 propertyMap1.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
948 propertyMap1.Insert( "mixColor", Color::MAGENTA );
949 propertyMap1.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
950 propertyMap1.Insert( ImageVisual::Property::BORDER_ONLY, true );
951 propertyMap1.Insert( ImageVisual::Property::BORDER, border1 );
952 nPatchVisual = factory.CreateVisual( propertyMap1 );
954 nPatchVisual.CreatePropertyMap( resultMap );
956 // check the property values from the returned map from visual
957 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
958 DALI_TEST_CHECK( value );
959 DALI_TEST_CHECK( value->Get<int>() == Visual::N_PATCH );
961 value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
962 DALI_TEST_CHECK( value );
963 DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
965 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
966 DALI_TEST_CHECK( value );
967 DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
969 value = resultMap.Find( ImageVisual::Property::BORDER_ONLY, Property::BOOLEAN );
970 DALI_TEST_CHECK( value );
971 DALI_TEST_CHECK( value->Get<bool>() );
973 value = resultMap.Find( ImageVisual::Property::BORDER, Property::RECTANGLE );
974 DALI_TEST_CHECK( value );
975 DALI_TEST_CHECK( value->Get< Rect< int > >() == border );
980 int UtcDaliVisualGetPropertyMap7(void)
982 ToolkitTestApplication application;
983 tet_infoline( "UtcDaliVisualGetPropertyMap7: SvgVisual" );
985 // request SvgVisual with a property map
986 VisualFactory factory = VisualFactory::Get();
987 Property::Map propertyMap;
988 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG );
989 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::WHITE );
990 propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
991 propertyMap.Insert( ImageVisual::Property::ATLASING, false );
992 Visual::Base svgVisual = factory.CreateVisual( propertyMap );
994 Property::Map resultMap;
995 svgVisual.CreatePropertyMap( resultMap );
996 // check the property values from the returned map from a visual
997 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
998 DALI_TEST_CHECK( value );
999 DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
1001 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
1002 DALI_TEST_CHECK( value );
1003 DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
1005 value = resultMap.Find( ImageVisual::Property::ATLASING, Property::BOOLEAN );
1006 DALI_TEST_CHECK( value );
1007 DALI_TEST_CHECK( value->Get<bool>() == false );
1009 // request SvgVisual with a property map 2
1010 propertyMap.Clear();
1011 propertyMap[ "visualType" ] = Visual::SVG;
1012 propertyMap[ "mixColor" ] = Color::WHITE;
1013 propertyMap[ "url" ] = TEST_SVG_FILE_NAME;
1014 propertyMap[ "atlasing" ] = true;
1015 Visual::Base svgVisual1 = factory.CreateVisual( propertyMap );
1018 svgVisual1.CreatePropertyMap( resultMap );
1019 // check the property values from the returned map from a visual
1020 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1021 DALI_TEST_CHECK( value );
1022 DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
1024 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
1025 DALI_TEST_CHECK( value );
1026 DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
1028 value = resultMap.Find( ImageVisual::Property::ATLASING, Property::BOOLEAN );
1029 DALI_TEST_CHECK( value );
1030 DALI_TEST_CHECK( value->Get<bool>() == true );
1032 // request SvgVisual with an URL
1033 Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
1035 svgVisual2.CreatePropertyMap( resultMap );
1036 // check the property values from the returned map from a visual
1037 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1038 DALI_TEST_CHECK( value );
1039 DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
1041 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
1042 DALI_TEST_CHECK( value );
1043 DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
1049 int UtcDaliVisualGetPropertyMap8(void)
1051 ToolkitTestApplication application;
1052 tet_infoline( "UtcDaliVisualGetPropertyMap8: MeshVisual" );
1054 //Request MeshVisual using a property map.
1055 VisualFactory factory = VisualFactory::Get();
1056 Property::Map propertyMap;
1057 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1058 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLUE );
1059 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1060 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1061 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_LOCATION );
1062 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1063 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
1064 Visual::Base meshVisual = factory.CreateVisual( propertyMap );
1066 Property::Map resultMap;
1067 meshVisual.CreatePropertyMap( resultMap );
1068 TestMixColor( meshVisual, Visual::Property::MIX_COLOR, Color::BLUE );
1070 //Check values in the result map are identical to the initial map's values.
1071 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1072 DALI_TEST_CHECK( value );
1073 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::MESH, TEST_LOCATION );
1075 value = resultMap.Find( MeshVisual::Property::OBJECT_URL, Property::STRING );
1076 DALI_TEST_CHECK( value );
1077 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
1079 value = resultMap.Find( MeshVisual::Property::MATERIAL_URL, Property::STRING );
1080 DALI_TEST_CHECK( value );
1081 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_MTL_FILE_NAME, TEST_LOCATION );
1083 value = resultMap.Find( MeshVisual::Property::TEXTURES_PATH, Property::STRING );
1084 DALI_TEST_CHECK( value );
1085 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_RESOURCE_LOCATION, TEST_LOCATION );
1087 value = resultMap.Find( MeshVisual::Property::SHADING_MODE, Property::INTEGER );
1088 DALI_TEST_CHECK( value );
1089 DALI_TEST_EQUALS( value->Get<int>(), (int)MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING, TEST_LOCATION );
1091 value = resultMap.Find( MeshVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
1092 DALI_TEST_CHECK( value );
1093 DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1098 //Primitive shape visual
1099 int UtcDaliVisualGetPropertyMap9(void)
1101 ToolkitTestApplication application;
1102 tet_infoline( "UtcDaliVisualGetPropertyMap9: PrimitiveVisual" );
1104 Vector4 color = Vector4( 1.0, 0.8, 0.6, 1.0);
1105 Vector3 dimensions = Vector3( 1.0, 2.0, 3.0 );
1107 //Request PrimitiveVisual using a property map.
1108 VisualFactory factory = VisualFactory::Get();
1109 Property::Map propertyMap;
1110 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1111 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1112 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color );
1113 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1114 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1115 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1116 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1117 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1118 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1119 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, dimensions );
1120 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.3f );
1121 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.6f );
1122 propertyMap.Insert( PrimitiveVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
1123 Visual::Base primitiveVisual = factory.CreateVisual( propertyMap );
1125 Property::Map resultMap;
1126 primitiveVisual.CreatePropertyMap( resultMap );
1128 //Check values in the result map are identical to the initial map's values.
1129 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1130 DALI_TEST_CHECK( value );
1131 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::PRIMITIVE, TEST_LOCATION );
1133 value = resultMap.Find( PrimitiveVisual::Property::SHAPE, Property::INTEGER );
1134 DALI_TEST_CHECK( value );
1135 DALI_TEST_EQUALS( value->Get<int>(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION );
1137 value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 );
1138 DALI_TEST_CHECK( value );
1139 DALI_TEST_CHECK( value->Get<Vector4>() == color );
1140 DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1142 value = resultMap.Find( PrimitiveVisual::Property::SLICES, Property::INTEGER );
1143 DALI_TEST_CHECK( value );
1144 DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
1146 value = resultMap.Find( PrimitiveVisual::Property::STACKS, Property::INTEGER );
1147 DALI_TEST_CHECK( value );
1148 DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
1150 value = resultMap.Find( PrimitiveVisual::Property::SCALE_TOP_RADIUS, Property::FLOAT );
1151 DALI_TEST_CHECK( value );
1152 DALI_TEST_EQUALS( value->Get<float>(), 30.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1154 value = resultMap.Find( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, Property::FLOAT );
1155 DALI_TEST_CHECK( value );
1156 DALI_TEST_EQUALS( value->Get<float>(), 40.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1158 value = resultMap.Find( PrimitiveVisual::Property::SCALE_HEIGHT, Property::FLOAT );
1159 DALI_TEST_CHECK( value );
1160 DALI_TEST_EQUALS( value->Get<float>(), 50.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1162 value = resultMap.Find( PrimitiveVisual::Property::SCALE_RADIUS, Property::FLOAT );
1163 DALI_TEST_CHECK( value );
1164 DALI_TEST_EQUALS( value->Get<float>(), 60.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1166 value = resultMap.Find( PrimitiveVisual::Property::SCALE_DIMENSIONS, Property::VECTOR3 );
1167 DALI_TEST_CHECK( value );
1168 DALI_TEST_EQUALS( value->Get<Vector3>(), dimensions, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1170 value = resultMap.Find( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::FLOAT );
1171 DALI_TEST_CHECK( value );
1172 DALI_TEST_EQUALS( value->Get<float>(), 0.3f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1174 value = resultMap.Find( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::FLOAT );
1175 DALI_TEST_CHECK( value );
1176 DALI_TEST_EQUALS( value->Get<float>(), 0.6f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1178 value = resultMap.Find( PrimitiveVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
1179 DALI_TEST_CHECK( value );
1180 DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1186 int UtcDaliVisualGetPropertyMap10(void)
1188 ToolkitTestApplication application;
1189 tet_infoline( "UtcDaliVisualGetPropertyMap10: TextVisual" );
1191 //Request PrimitiveVisual using a property map.
1192 VisualFactory factory = VisualFactory::Get();
1194 Property::Map propertyMap;
1195 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
1196 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLACK );
1197 propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
1198 propertyMap.Insert( "enableMarkup", false );
1199 propertyMap.Insert( "text", "Hello world" );
1200 propertyMap.Insert( "fontFamily", "TizenSans" );
1202 Property::Map fontStyleMapSet;
1203 fontStyleMapSet.Insert( "weight", "bold" );
1204 propertyMap.Insert( "fontStyle", fontStyleMapSet );
1206 propertyMap.Insert( "pointSize", 12.f );
1207 propertyMap.Insert( "multiLine", true );
1208 propertyMap.Insert( "horizontalAlignment", "CENTER" );
1209 propertyMap.Insert( "verticalAlignment", "CENTER" );
1210 propertyMap.Insert( "textColor", Color::RED );
1212 Property::Map shadowMapSet;
1213 propertyMap.Insert( "shadow", shadowMapSet.Add("color", Color::RED).Add("offset", Vector2(2.0f, 2.0f)).Add("blurRadius", 3.0f) );
1215 Property::Map underlineMapSet;
1216 propertyMap.Insert( "underline", underlineMapSet.Add("enable", true).Add("color", Color::GREEN).Add("height", 1) );
1218 Property::Map outlineMapSet;
1219 propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) );
1221 Property::Map backgroundMapSet;
1222 propertyMap.Insert( "textBackground", backgroundMapSet.Add("enable", true).Add("color", Color::CYAN) );
1224 Visual::Base textVisual = factory.CreateVisual( propertyMap );
1226 Property::Map resultMap;
1227 textVisual.CreatePropertyMap( resultMap );
1229 //Check values in the result map are identical to the initial map's values.
1230 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1231 DALI_TEST_CHECK( value );
1232 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::TEXT, TEST_LOCATION );
1234 value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
1235 DALI_TEST_CHECK( value );
1236 DALI_TEST_EQUALS( value->Get<Vector4>(), Color::BLACK, 0.001f, TEST_LOCATION );
1238 value = resultMap.Find( TextVisual::Property::TEXT, Property::STRING );
1239 DALI_TEST_CHECK( value );
1240 DALI_TEST_EQUALS( value->Get<std::string>(), "Hello world", TEST_LOCATION );
1242 value = resultMap.Find( TextVisual::Property::FONT_FAMILY, Property::STRING );
1243 DALI_TEST_CHECK( value );
1244 DALI_TEST_EQUALS( value->Get<std::string>(), "TizenSans", TEST_LOCATION );
1246 value = resultMap.Find( TextVisual::Property::FONT_STYLE, Property::MAP );
1247 DALI_TEST_CHECK( value );
1249 Property::Map fontStyleMapGet = value->Get<Property::Map>();
1250 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1251 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1253 value = resultMap.Find( TextVisual::Property::POINT_SIZE, Property::FLOAT );
1254 DALI_TEST_CHECK( value );
1255 DALI_TEST_EQUALS( value->Get<float>(), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1257 value = resultMap.Find( TextVisual::Property::MULTI_LINE, Property::BOOLEAN );
1258 DALI_TEST_CHECK( value );
1259 DALI_TEST_CHECK( value->Get<bool>() );
1261 value = resultMap.Find( TextVisual::Property::HORIZONTAL_ALIGNMENT, Property::INTEGER );
1262 DALI_TEST_CHECK( value );
1263 DALI_TEST_EQUALS( value->Get<int>(), (int)Text::HorizontalAlignment::CENTER, TEST_LOCATION );
1265 value = resultMap.Find( TextVisual::Property::VERTICAL_ALIGNMENT, Property::INTEGER );
1266 DALI_TEST_CHECK( value );
1267 DALI_TEST_EQUALS( value->Get<int>(), (int)Text::VerticalAlignment::CENTER, TEST_LOCATION );
1269 value = resultMap.Find( TextVisual::Property::TEXT_COLOR, Property::VECTOR4 );
1270 DALI_TEST_CHECK( value );
1271 DALI_TEST_EQUALS( value->Get<Vector4>(), Color::RED, TEST_LOCATION );
1273 value = resultMap.Find( TextVisual::Property::ENABLE_MARKUP, Property::BOOLEAN );
1274 DALI_TEST_CHECK( value );
1275 DALI_TEST_CHECK( !value->Get<bool>() );
1277 value = resultMap.Find( TextVisual::Property::SHADOW, Property::MAP );
1278 DALI_TEST_CHECK( value );
1280 Property::Map shadowMapGet = value->Get<Property::Map>();
1281 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
1282 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
1284 value = resultMap.Find( TextVisual::Property::UNDERLINE, Property::MAP );
1285 DALI_TEST_CHECK( value );
1287 Property::Map underlineMapGet = value->Get<Property::Map>();
1288 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1289 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
1291 value = resultMap.Find( DevelTextVisual::Property::OUTLINE, Property::MAP );
1292 DALI_TEST_CHECK( value );
1294 Property::Map outlineMapGet = value->Get<Property::Map>();
1295 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
1296 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
1298 value = resultMap.Find( DevelTextVisual::Property::BACKGROUND, Property::MAP );
1299 DALI_TEST_CHECK( value );
1301 Property::Map backgroundMapGet = value->Get<Property::Map>();
1302 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
1303 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
1308 int UtcDaliVisualGetPropertyMap11(void)
1310 ToolkitTestApplication application;
1311 tet_infoline( "UtcDaliVisualGetPropertyMap11: AnimatedGradientVisual" );
1313 VisualFactory factory = VisualFactory::Get();
1314 DALI_TEST_CHECK( factory );
1316 Property::Map propertyMap;
1317 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
1319 Vector2 start(-0.5f, 0.5f);
1320 Vector2 end (0.5f, -0.0f);
1321 Vector4 start_color(1.0f, 0.7f, 0.5f, 1.0f);
1322 Vector4 end_color (0.7f, 0.5f, 1.0f, 1.0f);
1323 Vector2 rotate_center(0.0f, 0.4f);
1324 float rotate_amount = 1.57f;
1325 float offset = 100.f;
1327 propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, DevelAnimatedGradientVisual::GradientType::RADIAL);
1328 propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE, DevelAnimatedGradientVisual::UnitType::USER_SPACE);
1329 propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE, DevelAnimatedGradientVisual::SpreadType::CLAMP);
1331 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, start);
1332 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION, end);
1333 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR, start_color);
1334 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR, end_color);
1335 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER, rotate_center);
1336 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, rotate_amount);
1337 propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET, offset);
1339 Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1340 DALI_TEST_CHECK( animatedGradientVisual );
1342 Property::Map resultMap;
1343 animatedGradientVisual.CreatePropertyMap( resultMap );
1345 // check the property values from the returned map from visual
1346 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1347 DALI_TEST_CHECK( value );
1348 DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1350 value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, Property::INTEGER );
1351 DALI_TEST_CHECK( value );
1352 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::RADIAL );
1354 value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE, Property::INTEGER );
1355 DALI_TEST_CHECK( value );
1356 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::USER_SPACE );
1358 value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE, Property::INTEGER );
1359 DALI_TEST_CHECK( value );
1360 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::CLAMP );
1363 value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_POSITION, Property::VECTOR2 );
1364 DALI_TEST_CHECK( value );
1365 DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1367 value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_POSITION, Property::VECTOR2 );
1368 DALI_TEST_CHECK( value );
1369 DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1371 value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_COLOR, Property::VECTOR4 );
1372 DALI_TEST_CHECK( value );
1373 DALI_TEST_EQUALS( value->Get<Vector4>(), start_color , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1375 value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_COLOR, Property::VECTOR4 );
1376 DALI_TEST_CHECK( value );
1377 DALI_TEST_EQUALS( value->Get<Vector4>(), end_color , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1379 value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_CENTER, Property::VECTOR2 );
1380 DALI_TEST_CHECK( value );
1381 DALI_TEST_EQUALS( value->Get<Vector2>(), rotate_center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1383 value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, Property::FLOAT );
1384 DALI_TEST_CHECK( value );
1385 DALI_TEST_EQUALS( value->Get<float>(), rotate_amount , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1387 value = resultMap.Find( DevelAnimatedGradientVisual::Property::OFFSET, Property::FLOAT );
1388 DALI_TEST_CHECK( value );
1389 DALI_TEST_EQUALS( value->Get<float>(), offset , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1394 int UtcDaliVisualGetPropertyMap12(void)
1396 ToolkitTestApplication application;
1397 tet_infoline( "UtcDaliVisualGetPropertyMap12: AnimatedGradientVisual with animation param" );
1399 // Case 1 : Set values by index
1401 tet_printf( " - Set Values by Index\n" );
1402 // NOTE : PropertyMap doesn't optimized even delay < -loop_count * (duration + repeat_delay) so this animation will not run
1403 // _delay = -10.0f is this case. It will progress (10.0f / 1.5f) amount. and 10.0f / 1.5f > 5.
1404 for(float _delay = -10.0f; _delay <= 5.0f; _delay += 5.0f)
1406 tet_printf( "test with delay [%f]\n", _delay );
1407 VisualFactory factory = VisualFactory::Get();
1408 DALI_TEST_CHECK( factory );
1410 Property::Map propertyMap;
1411 Property::Map animationMap;
1412 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
1414 float duration = 1.1f;
1415 float delay = _delay;
1416 float repeat_delay = 0.4f;
1418 int direction = DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD;
1420 int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR;
1421 int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::OUT;
1423 auto buildAnimatedMap = [&animationMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Value &start, const Property::Value &target)->Property::Map&
1425 animationMap.Clear();
1426 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::START, start);
1427 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target);
1428 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, direction);
1429 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
1430 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
1431 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
1432 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
1433 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, motion);
1434 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, easing);
1436 return animationMap;
1439 Vector2 start1(-0.5f, 0.5f);
1440 Vector2 end1 (0.5f, -0.5f);
1441 Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1442 Vector4 end_color1 (0.7f, 0.5f, 1.0f, 1.0f);
1443 Vector2 rotate_center1(0.0f, 0.4f);
1444 float rotate_amount1 = 0.0f;
1445 float offset1 = 0.f;
1447 Vector2 start2(-0.5f, -0.5f);
1448 Vector2 end2 (0.5f, 0.5f);
1449 Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1450 Vector4 end_color2 (0.3f, 1.0f, 0.1f, 0.0f);
1451 Vector2 rotate_center2(0.0f, -0.4f);
1452 float rotate_amount2 = 6.2832f;
1453 float offset2 = 2.f;
1455 propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, DevelAnimatedGradientVisual::GradientType::LINEAR);
1456 propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE, DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX);
1457 propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE, DevelAnimatedGradientVisual::SpreadType::REPEAT);
1459 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1 , start2 ));
1460 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION, buildAnimatedMap(end1 , end2 ));
1461 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR, buildAnimatedMap(start_color1 , start_color2 ));
1462 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR, buildAnimatedMap(end_color1 , end_color2 ));
1463 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER, buildAnimatedMap(rotate_center1, rotate_center2));
1464 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, buildAnimatedMap(rotate_amount1, rotate_amount2));
1465 propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET, buildAnimatedMap(offset1 , offset2 ));
1467 Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1468 DALI_TEST_CHECK( animatedGradientVisual );
1470 Property::Map resultMap;
1471 animatedGradientVisual.CreatePropertyMap( resultMap );
1473 // check the property values from the returned map from visual
1474 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1475 DALI_TEST_CHECK( value );
1476 DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1478 value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, Property::INTEGER );
1479 DALI_TEST_CHECK( value );
1480 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::LINEAR );
1482 value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE, Property::INTEGER );
1483 DALI_TEST_CHECK( value );
1484 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX );
1486 value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE, Property::INTEGER );
1487 DALI_TEST_CHECK( value );
1488 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REPEAT );
1490 auto checkAnimatedMap = [&value, &resultMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Index &index, const Property::Value &start, const Property::Value &target, int line_num)->void
1492 tet_printf("Check value at %d\n", line_num);
1493 value = resultMap.Find( index, Property::MAP );
1494 DALI_TEST_CHECK( value );
1495 DALI_TEST_CHECK( value->GetType() == Property::MAP );
1496 Property::Map *temp_map = value->GetMap();
1497 DALI_TEST_CHECK( temp_map );
1499 auto checkMapValue = [&temp_map](const Property::Index index)->Property::Value
1501 Property::Value *res = temp_map->Find( index );
1502 DALI_TEST_CHECK( res );
1506 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::START) , start, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1507 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET) , target, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1508 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION) , Property::Value( direction ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1509 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION) , Property::Value( duration ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1510 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY) , Property::Value( delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1511 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT) , Property::Value( loop_count ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1512 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY), Property::Value( repeat_delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1513 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE) , Property::Value( motion ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1514 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE) , Property::Value( easing ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1517 // check the animation map data is good
1518 checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_POSITION, start1 , start2 , __LINE__);
1519 checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_POSITION , end1 , end2 , __LINE__);
1520 checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_COLOR , start_color1 , start_color2 , __LINE__);
1521 checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_COLOR , end_color1 , end_color2 , __LINE__);
1522 checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_CENTER , rotate_center1, rotate_center2, __LINE__);
1523 checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT , rotate_amount1, rotate_amount2, __LINE__);
1524 checkAnimatedMap(DevelAnimatedGradientVisual::Property::OFFSET , offset1 , offset2 , __LINE__);
1528 // Case 2 : Set values by string
1530 tet_printf( " - Set Values by String\n" );
1531 // NOTE : PropertyMap doesn't optimized even delay < -loop_count * (duration + repeat_delay) so this animation will not run
1532 // _delay = -10.0f is this case. It will progress (10.0f / 1.5f) amount. and 10.0f / 1.5f > 5.
1533 for(float _delay = -10.0f; _delay <= 5.0f; _delay += 5.0f)
1535 tet_printf( "test with delay [%f]\n", _delay );
1536 VisualFactory factory = VisualFactory::Get();
1537 DALI_TEST_CHECK( factory );
1539 Property::Map propertyMap;
1540 Property::Map animationMap;
1541 propertyMap.Insert("visualType", "ANIMATED_GRADIENT");
1543 float duration = 1.1f;
1544 float delay = _delay;
1545 float repeat_delay = 0.4f;
1547 int direction = DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD;
1549 int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR;
1550 int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN_OUT;
1552 auto buildAnimatedMap = [&animationMap, &duration, &delay, &loop_count, &repeat_delay](const Property::Value &start, const Property::Value &target)->Property::Map&
1554 animationMap.Clear();
1555 animationMap.Insert("startValue" , start);
1556 animationMap.Insert("targetValue" , target);
1557 animationMap.Insert("directionType", "BACKWARD");
1558 animationMap.Insert("duration" , duration);
1559 animationMap.Insert("delay" , delay);
1560 animationMap.Insert("repeat" , loop_count);
1561 animationMap.Insert("repeatDelay" , repeat_delay);
1562 animationMap.Insert("motionType" , "MIRROR");
1563 animationMap.Insert("easingType" , "IN_OUT");
1565 return animationMap;
1568 Vector2 start1(-0.5f, 0.5f);
1569 Vector2 end1 (0.5f, -0.5f);
1570 Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1571 Vector4 end_color1 (0.7f, 0.5f, 1.0f, 1.0f);
1572 Vector2 rotate_center1(0.0f, 0.4f);
1573 float rotate_amount1 = 0.0f;
1574 float offset1 = 0.f;
1576 Vector2 start2(-0.5f, -0.5f);
1577 Vector2 end2 (0.5f, 0.5f);
1578 Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1579 Vector4 end_color2 (0.3f, 1.0f, 0.1f, 0.0f);
1580 Vector2 rotate_center2(0.0f, -0.4f);
1581 float rotate_amount2 = 6.2832f;
1582 float offset2 = 2.f;
1584 // For test mix the type string/index key and string/index value works well.
1585 propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, "RADIAL");
1586 propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE, DevelAnimatedGradientVisual::UnitType::USER_SPACE);
1587 propertyMap.Insert("spreadType" , DevelAnimatedGradientVisual::SpreadType::REFLECT);
1589 propertyMap.Insert("startPosition", buildAnimatedMap(start1 , start2 ));
1590 propertyMap.Insert("endPosition" , buildAnimatedMap(end1 , end2 ));
1591 propertyMap.Insert("startColor" , buildAnimatedMap(start_color1 , start_color2 ));
1592 propertyMap.Insert("endColor" , buildAnimatedMap(end_color1 , end_color2 ));
1593 propertyMap.Insert("rotateCenter" , buildAnimatedMap(rotate_center1, rotate_center2));
1594 propertyMap.Insert("rotateAmount" , buildAnimatedMap(rotate_amount1, rotate_amount2));
1595 propertyMap.Insert("offset" , buildAnimatedMap(offset1 , offset2 ));
1597 Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1598 DALI_TEST_CHECK( animatedGradientVisual );
1600 Property::Map resultMap;
1601 animatedGradientVisual.CreatePropertyMap( resultMap );
1603 // check the property values from the returned map from visual
1604 // Note : resultMap from CreatePropertyMap only contain indexKey
1605 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1606 DALI_TEST_CHECK( value );
1607 DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1609 value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, Property::INTEGER );
1610 DALI_TEST_CHECK( value );
1611 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::RADIAL );
1613 value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE, Property::INTEGER );
1614 DALI_TEST_CHECK( value );
1615 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::USER_SPACE );
1617 value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE, Property::INTEGER );
1618 DALI_TEST_CHECK( value );
1619 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REFLECT );
1621 auto checkAnimatedMap = [&value, &resultMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Index &index, const Property::Value &start, const Property::Value &target, int line_num)->void
1623 tet_printf("Check value at %d\n", line_num);
1624 value = resultMap.Find( index, Property::MAP );
1625 DALI_TEST_CHECK( value );
1626 DALI_TEST_CHECK( value->GetType() == Property::MAP );
1627 Property::Map *temp_map = value->GetMap();
1628 DALI_TEST_CHECK( temp_map );
1630 auto checkMapValue = [&temp_map](const Property::Index index)->Property::Value
1632 Property::Value *res = temp_map->Find( index );
1633 DALI_TEST_CHECK( res );
1637 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::START) , start, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1638 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET) , target, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1639 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION) , Property::Value( direction ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1640 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION) , Property::Value( duration ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1641 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY) , Property::Value( delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1642 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT) , Property::Value( loop_count ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1643 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY), Property::Value( repeat_delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1644 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE) , Property::Value( motion ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1645 DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE) , Property::Value( easing ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1648 // check the animation map data is good
1649 checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_POSITION, start1 , start2 , __LINE__);
1650 checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_POSITION , end1 , end2 , __LINE__);
1651 checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_COLOR , start_color1 , start_color2 , __LINE__);
1652 checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_COLOR , end_color1 , end_color2 , __LINE__);
1653 checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_CENTER , rotate_center1, rotate_center2, __LINE__);
1654 checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT , rotate_amount1, rotate_amount2, __LINE__);
1655 checkAnimatedMap(DevelAnimatedGradientVisual::Property::OFFSET , offset1 , offset2 , __LINE__);
1661 int UtcDaliVisualGetPropertyMap13(void)
1663 ToolkitTestApplication application;
1664 tet_infoline( "UtcDaliVisualGetPropertyMap13: AnimatedGradientVisual when repeat = 0" );
1666 for(int _direction = 0; _direction <= 1; ++_direction)
1668 for(float _delay = -10.0f; _delay <= 10.0f; _delay += 10.0f)
1670 tet_printf( ((_direction == 0) ? "Forward test with delay [%f]\n" : "Backward test with delay [%f]\n") , _delay );
1671 VisualFactory factory = VisualFactory::Get();
1672 DALI_TEST_CHECK( factory );
1674 Property::Map propertyMap;
1675 Property::Map animationMap;
1676 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
1678 float duration = 1.0f;
1679 float delay = _delay;
1680 float repeat_delay = 0.5f;
1682 int direction = _direction;
1683 int loop_count = 0; // When loop_count is 0, Animation will not be created.
1684 int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP;
1685 int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN;
1687 auto buildAnimatedMap = [&animationMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Value &start, const Property::Value &target)->Property::Map&
1689 animationMap.Clear();
1690 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::START, start);
1691 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target);
1692 if(direction == 0)animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::FORWARD);
1693 else animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD);
1694 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, direction);
1695 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
1696 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
1697 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
1698 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
1699 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, motion);
1700 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, easing);
1702 return animationMap;
1705 Vector2 start1(-0.5f, 0.5f);
1706 Vector2 end1 (0.5f, -0.5f);
1707 Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1708 Vector4 end_color1 (0.7f, 0.5f, 1.0f, 1.0f);
1709 Vector2 rotate_center1(1.0f, 0.4f);
1710 float rotate_amount1 = 2.0f;
1711 float offset1 = 1.f;
1713 Vector2 start2(-0.5f, -0.5f);
1714 Vector2 end2 (0.5f, 0.5f);
1715 Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1716 Vector4 end_color2 (0.3f, 1.0f, 0.1f, 0.0f);
1717 Vector2 rotate_center2(1.0f, -0.4f);
1718 float rotate_amount2 = 1.0f;
1719 float offset2 = 3.f;
1721 propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, DevelAnimatedGradientVisual::GradientType::LINEAR);
1722 propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE, DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX);
1723 propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE, DevelAnimatedGradientVisual::SpreadType::REFLECT);
1725 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1 , start2 ));
1726 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION, buildAnimatedMap(end1 , end2 ));
1727 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR, buildAnimatedMap(start_color1 , start_color2 ));
1728 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR, buildAnimatedMap(end_color1 , end_color2 ));
1729 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER, buildAnimatedMap(rotate_center1, rotate_center2));
1730 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, buildAnimatedMap(rotate_amount1, rotate_amount2));
1731 propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET, buildAnimatedMap(offset1 , offset2 ));
1733 Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1734 DALI_TEST_CHECK( animatedGradientVisual );
1736 Property::Map resultMap;
1737 animatedGradientVisual.CreatePropertyMap( resultMap );
1739 // check the property values from the returned map from visual
1740 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1741 DALI_TEST_CHECK( value );
1742 DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1744 value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, Property::INTEGER );
1745 DALI_TEST_CHECK( value );
1746 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::LINEAR );
1748 value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE, Property::INTEGER );
1749 DALI_TEST_CHECK( value );
1750 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX );
1752 value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE, Property::INTEGER );
1753 DALI_TEST_CHECK( value );
1754 DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REFLECT );
1756 // If loop_count = 0, Animation doesn't created.
1757 // Optimized resultMap only have one value, which is target value
1758 // Note: target value will be changed by direction option.
1759 value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_POSITION, Property::VECTOR2 );
1760 DALI_TEST_CHECK( value );
1761 DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? start1 : start2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1763 value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_POSITION, Property::VECTOR2 );
1764 DALI_TEST_CHECK( value );
1765 DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? end1 : end2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1767 value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_COLOR, Property::VECTOR4 );
1768 DALI_TEST_CHECK( value );
1769 DALI_TEST_EQUALS( value->Get<Vector4>(), direction ? start_color1 : start_color2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1771 value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_COLOR, Property::VECTOR4 );
1772 DALI_TEST_CHECK( value );
1773 DALI_TEST_EQUALS( value->Get<Vector4>(), direction ? end_color1 : end_color2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1775 value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_CENTER, Property::VECTOR2 );
1776 DALI_TEST_CHECK( value );
1777 DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? rotate_center1 : rotate_center2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1779 value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, Property::FLOAT );
1780 DALI_TEST_CHECK( value );
1781 DALI_TEST_EQUALS( value->Get<float>(), direction ? rotate_amount1 : rotate_amount2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1783 value = resultMap.Find( DevelAnimatedGradientVisual::Property::OFFSET, Property::FLOAT );
1784 DALI_TEST_CHECK( value );
1785 DALI_TEST_EQUALS( value->Get<float>(), direction ? offset1 : offset2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1792 int UtcDaliVisualAnimateBorderVisual01(void)
1794 ToolkitTestApplication application;
1795 tet_infoline( "UtcDaliAnimateBorderVisual Color" );
1797 VisualFactory factory = VisualFactory::Get();
1798 Property::Map propertyMap;
1799 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
1800 propertyMap.Insert(Visual::Property::MIX_COLOR, Vector4(1, 1, 1, 0.8f));
1801 propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
1802 propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
1803 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1806 map["target"] = "testVisual";
1807 map["property"] = "mixColor";
1808 map["targetValue"] = Vector4(1,1,1,0.1);
1809 map["animator"] = Property::Map()
1810 .Add("alphaFunction", "LINEAR")
1811 .Add("timePeriod", Property::Map()
1813 .Add("duration", 4.0f));
1815 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
1817 DummyControl actor = DummyControl::New(true);
1818 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1819 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1820 actor.SetSize(2000, 2000);
1821 actor.SetParentOrigin(ParentOrigin::CENTER);
1822 Stage::GetCurrent().Add(actor);
1824 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1826 Renderer renderer = actor.GetRendererAt(0);
1827 Property::Index borderColorIndex = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::COLOR );
1828 Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, Visual::Property::MIX_COLOR );
1830 Animation animation = dummyImpl.CreateTransition( transition );
1832 // Animate the mix color through the transition, and the border color through
1833 // programmatic method.
1834 animation.AnimateTo( Property(renderer, borderColorIndex), Color::WHITE );
1837 application.SendNotification();
1838 application.Render(0);
1839 application.Render(2000u); // halfway point between blue and white
1841 Vector4 color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex );
1842 Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f;
1843 DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1844 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", testColor ), true, TEST_LOCATION );
1846 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1847 testColor = Vector4( 1,1,1,0.45f );
1848 DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), 0.0001f, TEST_LOCATION );
1849 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(testColor) ), true, TEST_LOCATION );
1852 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", uColor ) );
1853 DALI_TEST_EQUALS( uColor.a, testColor.a, TEST_LOCATION );
1855 application.Render(2000u);
1857 color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex );
1858 DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION );
1859 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", Color::WHITE ), true, TEST_LOCATION );
1861 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1862 testColor = Vector4(1,1,1,0.1);
1863 DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), TEST_LOCATION );
1864 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(testColor) ), true, TEST_LOCATION );
1866 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", uColor ) );
1867 DALI_TEST_EQUALS( uColor.a, testColor.a, TEST_LOCATION );
1873 int UtcDaliVisualAnimateBorderVisual02(void)
1875 ToolkitTestApplication application;
1876 tet_infoline( "UtcDaliAnimateBorderVisual Size" );
1878 VisualFactory factory = VisualFactory::Get();
1879 Property::Map propertyMap;
1880 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
1881 propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
1882 propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
1883 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1885 DummyControl actor = DummyControl::New(true);
1886 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1887 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1888 actor.SetSize(2000, 2000);
1889 actor.SetParentOrigin(ParentOrigin::CENTER);
1890 Stage::GetCurrent().Add(actor);
1892 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1894 Renderer renderer = actor.GetRendererAt(0);
1895 Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::SIZE );
1897 Animation animation = Animation::New(4.0f);
1898 animation.AnimateTo( Property(renderer, index), 9.0f );
1901 application.SendNotification();
1902 application.Render(0);
1903 application.Render(2000u); // halfway point
1905 float size = renderer.GetCurrentProperty< float >( index );
1906 DALI_TEST_EQUALS( size, 7.0f, 0.0001f, TEST_LOCATION );
1907 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 7.0f ), true, TEST_LOCATION );
1909 application.Render(2000u); // halfway point between blue and white
1911 size = renderer.GetCurrentProperty< float >( index );
1912 DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION );
1913 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 9.0f ), true, TEST_LOCATION );
1918 int UtcDaliVisualAnimateColorVisual(void)
1920 ToolkitTestApplication application;
1921 tet_infoline( "UtcDaliAnimateColorVisual mixColor" );
1923 VisualFactory factory = VisualFactory::Get();
1924 Property::Map propertyMap;
1925 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1926 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1927 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1929 DummyControl actor = DummyControl::New(true);
1930 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1931 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1932 actor.SetSize(2000, 2000);
1933 actor.SetParentOrigin(ParentOrigin::CENTER);
1934 Stage::GetCurrent().Add(actor);
1936 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1938 Renderer renderer = actor.GetRendererAt(0);
1939 Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
1941 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
1942 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1944 Animation animation = Animation::New(4.0f);
1945 animation.AnimateTo( Property(renderer, mixColorIndex), Vector3(Color::WHITE) );
1948 application.SendNotification();
1949 application.Render(0);
1950 application.Render(2000u); // halfway point
1952 Vector3 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1953 Vector3 testColor = Vector3(Color::BLUE + Color::WHITE)*0.5f;
1954 DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1956 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", testColor ), true, TEST_LOCATION );
1958 application.Render(2000u); // halfway point between blue and white
1960 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1961 DALI_TEST_EQUALS( color, Vector3(Color::WHITE), TEST_LOCATION );
1963 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(Color::WHITE) ), true, TEST_LOCATION );
1965 blendModeValue = renderer.GetCurrentProperty( Renderer::Property::BLEND_MODE );
1966 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1971 int UtcDaliVisualAnimatePrimitiveVisual(void)
1973 ToolkitTestApplication application;
1974 tet_infoline( "UtcDaliAnimatePrimitiveVisual color" );
1977 VisualFactory factory = VisualFactory::Get();
1978 Property::Map propertyMap;
1979 propertyMap.Insert(Visual::Property::TYPE, Visual::PRIMITIVE);
1980 propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE);
1981 propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Color::BLUE);
1982 Visual::Base visual = factory.CreateVisual( propertyMap );
1984 DummyControl actor = DummyControl::New(true);
1985 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1986 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1987 actor.SetSize(2000, 2000);
1988 actor.SetParentOrigin(ParentOrigin::CENTER);
1989 actor.SetColor(Color::BLACK);
1990 Stage::GetCurrent().Add(actor);
1992 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1994 Renderer renderer = actor.GetRendererAt(0);
1995 Property::Index index = DevelHandle::GetPropertyIndex( renderer, PrimitiveVisual::Property::MIX_COLOR );
1997 tet_infoline("Test that the renderer has the Primitive mix color");
1998 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2000 const Vector4 INITIAL_MIX_COLOR( 1.0f,0.0f,1.0f,0.5f ); // Magenta with half alpha
2001 const Vector4 TARGET_MIX_COLOR( Color::RED );
2004 map["target"] = "testVisual";
2005 map["property"] = "mixColor";
2006 map["initialValue"] = INITIAL_MIX_COLOR;
2007 map["targetValue"] = TARGET_MIX_COLOR;
2008 map["animator"] = Property::Map()
2009 .Add("alphaFunction", "LINEAR")
2010 .Add("timePeriod", Property::Map()
2012 .Add("duration", 4.0f));
2014 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
2016 Animation animation = dummyImpl.CreateTransition( transition );
2017 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
2018 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
2020 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
2023 application.SendNotification();
2024 application.Render(0);
2025 application.Render(2000u); // halfway point
2026 application.SendNotification();
2028 Vector4 halfwayColor = (INITIAL_MIX_COLOR + TARGET_MIX_COLOR)*0.5;
2029 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, halfwayColor.a )), true, TEST_LOCATION );
2030 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(halfwayColor) ), true, TEST_LOCATION );
2032 application.Render(2001u); // go past end
2033 application.SendNotification(); // Trigger signals
2035 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2036 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4( 1.0f, 1.0f, 1.0f, TARGET_MIX_COLOR.a ) ), true, TEST_LOCATION );
2037 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION );
2039 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
2040 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
2048 int UtcDaliVisualAnimatedGradientVisual01(void)
2050 ToolkitTestApplication application;
2051 tet_infoline( "UtcDaliAnimatedGradientVisual with default" );
2054 VisualFactory factory = VisualFactory::Get();
2055 Property::Map propertyMap;
2056 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
2057 Visual::Base visual = factory.CreateVisual( propertyMap );
2059 DummyControl actor = DummyControl::New(true);
2060 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2061 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2062 actor.SetSize(2000, 2000);
2063 actor.SetParentOrigin(ParentOrigin::CENTER);
2064 actor.SetColor(Color::BLACK);
2065 Stage::GetCurrent().Add(actor);
2067 application.SendNotification();
2068 application.Render(0);
2069 application.SendNotification();
2071 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
2073 for(int step_iter = 0; step_iter < 3; step_iter++)
2075 application.SendNotification();
2076 application.Render(0);
2077 application.Render(750u); // step i/4
2078 application.SendNotification();
2080 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "start_point" , Vector2( -0.5f, 0.0f ) ), true, TEST_LOCATION );
2081 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "end_point" , Vector2( 0.5f, 0.0f ) ), true, TEST_LOCATION );
2082 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "start_color" , Vector4( 143.0f, 170.0f, 220.0f, 255.0f ) / 255.0f ), true, TEST_LOCATION );
2083 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "end_color" , Vector4( 255.0f, 163.0f, 163.0f, 255.0f ) / 255.0f ), true, TEST_LOCATION );
2084 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "rotate_center", Vector2( 0.0f, 0.0f ) ), true, TEST_LOCATION );
2085 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>( "rotate_angle" , 0.0f ), true, TEST_LOCATION );
2086 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>( "gradient_offset", 0.5f * step_iter + 0.5f ), true, TEST_LOCATION );
2089 //Not check here. cause gradient_offset value can be 2.0f or 0.0f
2090 application.Render(750u); // go to end
2091 application.SendNotification();
2093 application.Render(10u); // finish
2094 application.SendNotification();
2097 application.SendNotification();
2098 application.Render(0u);
2099 application.SendNotification();
2105 int UtcDaliVisualAnimatedGradientVisual02(void)
2107 ToolkitTestApplication application;
2108 tet_infoline( "UtcDaliAnimatedGradientVisual with full-option" );
2111 float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
2112 int _direction[2] = {0, 1};
2113 int _loop_count[3] = {-1, 0, 1};
2114 int _motion[2] = {0, 1};
2115 int _easing[4] = {0, 1, 2, 3};
2117 int test_case_max = 4 * 2 * 3 * 2 * 4;
2119 int test_case_d = 7; // 7 is the number of animated properties.
2121 float _duration = 0.4f;
2122 float _repeat_delay = _duration * 0.25f; // < _duration. cause real_duration = _duration - _repeat_delay;
2123 float noise_maker = 0.0f;
2124 // total testing time = ceil((4*2*3*2*4) / 7) * (_duration(=0.4) * 2 + 0.01) = 22.68 seconds
2125 for( test_case = 0; test_case < test_case_max + test_case_d; test_case += test_case_d )
2127 tet_printf( "test [%d ~ %d / %d]\n" , test_case, test_case + test_case_d - 1, test_case_max);
2129 VisualFactory factory = VisualFactory::Get();
2130 Property::Map propertyMap;
2131 Property::Map animationMap;
2132 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
2134 int gradient_type = DevelAnimatedGradientVisual::GradientType::LINEAR;
2135 int unit_type = DevelAnimatedGradientVisual::UnitType::USER_SPACE;
2136 int spread_type = DevelAnimatedGradientVisual::SpreadType::REPEAT;
2138 auto buildAnimatedMap = [&animationMap, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const Property::Value &start, const Property::Value &target, int tc_offset)->Property::Map&
2140 int tc = (test_case + tc_offset);
2141 int idx_easing = tc % 4; tc /= 4;
2142 int idx_motion = tc % 2; tc /= 2;
2143 int idx_loop_count = tc % 3; tc /= 3;
2144 int idx_direction = tc % 2; tc /= 2;
2145 int idx_delay = tc % 4; tc /= 4;
2147 float duration = _duration - _repeat_delay;
2148 float repeat_delay = _repeat_delay;
2149 float delay = _delay[idx_delay] * _duration;
2150 int direction = _direction[idx_direction];
2151 int loop_count = _loop_count[idx_loop_count];
2152 int motion = _motion[idx_motion];
2153 int easing = _easing[idx_easing];
2155 animationMap.Clear();
2156 animationMap.Insert( DevelAnimatedGradientVisual::AnimationParameter::Property::START, start );
2157 animationMap.Insert( DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target );
2158 if( direction == 0 )
2160 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::FORWARD);
2164 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD);
2166 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
2167 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
2168 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
2169 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
2172 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP);
2176 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR);
2180 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::LINEAR);
2182 else if( easing == 1 )
2184 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN);
2186 else if( easing == 2 )
2188 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::OUT);
2192 animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN_OUT);
2195 return animationMap;
2198 // Give different values for debuging
2199 noise_maker += 1.0f;
2200 Vector2 start1(-0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2201 Vector2 end1 (0.5f + noise_maker * 0.1f, -0.5f + noise_maker * 0.1f);
2202 Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
2203 Vector4 end_color1 (0.7f, 0.5f, 1.0f, 1.0f);
2204 Vector2 rotate_center1(0.0f + noise_maker * 0.1f, 0.4f + noise_maker * 0.1f);
2205 float rotate_amount1 = 0.0f + noise_maker * 0.1f;
2206 float offset1 = 0.f + noise_maker * 0.1f;
2208 Vector2 start2(0.2f + noise_maker * 0.1f, -0.7f + noise_maker * 0.1f);
2209 Vector2 end2 (0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2210 Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
2211 Vector4 end_color2 (0.3f, 1.0f, 0.1f, 0.0f);
2212 Vector2 rotate_center2(0.0f + noise_maker * 0.1f, -0.4f + noise_maker * 0.1f);
2213 float rotate_amount2 = 7.0f + noise_maker * 0.1f;
2214 float offset2 = 2.f + noise_maker * 0.1f;
2216 propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, gradient_type);
2217 propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE, unit_type);
2218 propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE, spread_type);
2220 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1 , start2 ,0));
2221 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION, buildAnimatedMap(end1 , end2 ,1));
2222 propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR, buildAnimatedMap(start_color1 , start_color2 ,2));
2223 propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR, buildAnimatedMap(end_color1 , end_color2 ,3));
2224 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER, buildAnimatedMap(rotate_center1, rotate_center2,4));
2225 propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT, buildAnimatedMap(rotate_amount1, rotate_amount2,5));
2226 propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET, buildAnimatedMap(offset1 , offset2 ,6));
2228 Visual::Base visual = factory.CreateVisual( propertyMap );
2230 DummyControl actor = DummyControl::New( true );
2231 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
2232 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2233 actor.SetSize( 2000, 2000 );
2234 actor.SetParentOrigin(ParentOrigin::CENTER);
2235 actor.SetColor(Color::BLACK);
2236 Stage::GetCurrent().Add(actor);
2238 application.SendNotification();
2239 application.Render( 0 );
2240 application.SendNotification();
2242 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
2244 application.SendNotification();
2246 //Compare between CPU calculated value and Shader Visual calculated value
2247 auto testProperty = [&application, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const char* name, const Property::Value& start, const Property::Value& target, int tc_offset, int value_type, float progress)->void
2249 int tc = (test_case + tc_offset);
2250 int idx_easing = tc % 4; tc /= 4;
2251 int idx_motion = tc % 2; tc /= 2;
2252 int idx_loop_count = tc % 3; tc /= 3;
2253 int idx_direction = tc % 2; tc /= 2;
2254 int idx_delay = tc % 4; tc /= 4;
2256 float duration = _duration - _repeat_delay;
2257 float repeat_delay = _repeat_delay;
2258 float delay = _delay[idx_delay] * _duration;
2259 int direction = _direction[idx_direction];
2260 int loop_count = _loop_count[idx_loop_count];
2261 int motion = _motion[idx_motion];
2262 int easing = _easing[idx_easing];
2264 progress -= delay / _duration;
2266 Property::Value s = start;
2267 Property::Value t = target;
2268 if( direction == 1 )
2273 float x; ///< Animator progress value
2274 if( loop_count == 0 )
2278 else if( loop_count > 0 && progress + 0.01f > loop_count )
2280 x = ( motion == 0 ) ? 1.0f : 0.0f;
2284 if( progress < 0.0f )
2288 progress = fmodf( progress, 1.0f );
2289 progress = Dali::Clamp( (progress * (duration + repeat_delay) - repeat_delay) / duration, 0.0f, 1.0f );
2294 x = progress * 2.0f;
2301 if( easing == 1 ) // EASE_IN
2305 else if( easing == 2 ) // EASE_OUT
2309 else if( easing == 3 ) // EASE_IN_OUT
2311 x = x * x * (3.0f - 2.0f * x);
2314 if( value_type == 0 ) // result type is Float
2318 res = s.Get<float>() * (1.0f - x) + t.Get<float>() * (x);
2319 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<float>(name, cur), true, TEST_LOCATION );
2320 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2322 else if( value_type == 1 ) // result type is Vector2
2326 res = s.Get<Vector2>() * (1.0f - x) + t.Get<Vector2>() * (x);
2327 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector2>(name, cur), true, TEST_LOCATION );
2328 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2330 else if( value_type == 2 ) // result type is Vector3
2334 res = s.Get<Vector3>() * (1.0f - x) + t.Get<Vector3>() * (x);
2335 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector3>(name, cur), true, TEST_LOCATION );
2336 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2338 else // result type is Vector4
2342 res = s.Get<Vector4>() * (1.0f - x) + t.Get<Vector4>() * (x);
2343 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector4>(name, cur), true, TEST_LOCATION );
2344 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2349 for( int iter = 0; iter < 2; iter++ ) // test 2*duration seconds
2351 for( int step_iter = 0; step_iter < 3; step_iter++ )
2353 application.SendNotification();
2354 application.Render( _duration * 250.f ); // step i/4
2355 application.SendNotification();
2358 testProperty( "start_point" , Property::Value( start1 ) , Property::Value( start2 ) , 0, 1, step );
2359 testProperty( "end_point" , Property::Value( end1 ) , Property::Value( end2 ) , 1, 1, step );
2360 testProperty( "start_color" , Property::Value( start_color1 ) , Property::Value( start_color2 ) , 2, 3, step );
2361 testProperty( "end_color" , Property::Value( end_color1 ) , Property::Value( end_color2 ) , 3, 3, step );
2362 testProperty( "rotate_center" , Property::Value( rotate_center1 ), Property::Value( rotate_center2 ), 4, 1, step );
2363 testProperty( "rotate_angle" , Property::Value( rotate_amount1 ), Property::Value( rotate_amount2 ), 5, 0, step );
2364 testProperty( "gradient_offset", Property::Value( offset1 ) , Property::Value( offset2 ) , 6, 0, step );
2366 application.SendNotification();
2367 application.Render(_duration * 250.f); // step 4/4 will not test
2368 application.SendNotification();
2372 application.SendNotification();
2374 application.SendNotification();
2375 application.Render(10.f); // tempral time
2376 application.SendNotification();
2383 int UtcDaliVisualAnimatedGradientVisual03(void)
2385 ToolkitTestApplication application;
2386 tet_infoline( "UtcDaliAnimatedGradientVisual with full-option use string key" );
2389 float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
2390 int _direction[2] = {0, 1};
2391 int _loop_count[3] = {-1, 0, 1};
2392 int _motion[2] = {0, 1};
2393 int _easing[4] = {0, 1, 2, 3};
2395 int test_case_max = 4 * 2 * 3 * 2 * 4;
2397 int test_case_d = 7; // 7 is the number of animated properties.
2399 float _duration = 0.4f;
2400 float _repeat_delay = _duration * 0.25f; // < _duration. cause real_duration = _duration - _repeat_delay;
2401 float noise_maker = 0.2f;
2402 // total testing time = ceil((4*2*3*2*4) / 7) * (_duration(=0.4) * 2 + 0.01) = 22.68 seconds
2403 for( test_case = 0; test_case < test_case_max + test_case_d; test_case += test_case_d )
2405 tet_printf( "test [%d ~ %d / %d]\n" , test_case, test_case + test_case_d - 1, test_case_max);
2407 VisualFactory factory = VisualFactory::Get();
2408 Property::Map propertyMap;
2409 Property::Map animationMap;
2410 propertyMap.Insert(Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
2412 auto buildAnimatedMap = [&animationMap, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const Property::Value &start, const Property::Value &target, int tc_offset)->Property::Map&
2414 int tc = (test_case + tc_offset);
2415 int idx_easing = tc % 4; tc /= 4;
2416 int idx_motion = tc % 2; tc /= 2;
2417 int idx_loop_count = tc % 3; tc /= 3;
2418 int idx_direction = tc % 2; tc /= 2;
2419 int idx_delay = tc % 4; tc /= 4;
2421 float duration = _duration - _repeat_delay;
2422 float repeat_delay = _repeat_delay;
2423 float delay = _delay[idx_delay] * _duration;
2424 int direction = _direction[idx_direction];
2425 int loop_count = _loop_count[idx_loop_count];
2426 int motion = _motion[idx_motion];
2427 int easing = _easing[idx_easing];
2429 animationMap.Clear();
2430 animationMap.Insert( "startValue", start );
2431 animationMap.Insert( "targetValue", target );
2432 if( direction == 0 )
2434 animationMap.Insert("directionType", "FORWARD");
2438 animationMap.Insert("directionType", "BACKWARD");
2440 animationMap.Insert("duration", duration);
2441 animationMap.Insert("delay", delay);
2442 animationMap.Insert("repeat", loop_count);
2443 animationMap.Insert("repeatDelay", repeat_delay);
2446 animationMap.Insert("motionType", "LOOP");
2450 animationMap.Insert("motionType", "MIRROR");
2454 animationMap.Insert("easingType", "LINEAR");
2456 else if( easing == 1 )
2458 animationMap.Insert("easingType", "IN");
2460 else if( easing == 2 )
2462 animationMap.Insert("easingType", "OUT");
2466 animationMap.Insert("easingType", "IN_OUT");
2469 return animationMap;
2472 // Give different values for debuging
2473 noise_maker += 0.8f;
2474 Vector2 start1(-0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2475 Vector2 end1 (0.5f + noise_maker * 0.1f, -0.5f + noise_maker * 0.1f);
2476 Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
2477 Vector4 end_color1 (0.7f, 0.5f, 1.0f, 1.0f);
2478 Vector2 rotate_center1(0.0f + noise_maker * 0.1f, 0.4f + noise_maker * 0.1f);
2479 float rotate_amount1 = 0.0f + noise_maker * 0.1f;
2480 float offset1 = 0.f + noise_maker * 0.1f;
2482 Vector2 start2(0.2f + noise_maker * 0.1f, -0.7f + noise_maker * 0.1f);
2483 Vector2 end2 (0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2484 Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
2485 Vector4 end_color2 (0.3f, 1.0f, 0.1f, 0.0f);
2486 Vector2 rotate_center2(0.0f + noise_maker * 0.1f, -0.4f + noise_maker * 0.1f);
2487 float rotate_amount2 = 7.0f + noise_maker * 0.1f;
2488 float offset2 = 2.f + noise_maker * 0.1f;
2490 propertyMap.Insert("gradientType", "LINEAR");
2491 propertyMap.Insert("unitType", "USER_SPACE");
2492 propertyMap.Insert("spreadType", "CLAMP");
2494 propertyMap.Insert("startPosition", buildAnimatedMap(start1 , start2 ,0));
2495 propertyMap.Insert("endPosition", buildAnimatedMap(end1 , end2 ,1));
2496 propertyMap.Insert("startColor", buildAnimatedMap(start_color1 , start_color2 ,2));
2497 propertyMap.Insert("endColor", buildAnimatedMap(end_color1 , end_color2 ,3));
2498 propertyMap.Insert("rotateCenter", buildAnimatedMap(rotate_center1, rotate_center2,4));
2499 propertyMap.Insert("rotateAmount", buildAnimatedMap(rotate_amount1, rotate_amount2,5));
2500 propertyMap.Insert("offset", buildAnimatedMap(offset1 , offset2 ,6));
2502 Visual::Base visual = factory.CreateVisual( propertyMap );
2504 DummyControl actor = DummyControl::New( true );
2505 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
2506 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2507 actor.SetSize( 2000, 2000 );
2508 actor.SetParentOrigin(ParentOrigin::CENTER);
2509 actor.SetColor(Color::BLACK);
2510 Stage::GetCurrent().Add(actor);
2512 application.SendNotification();
2513 application.Render( 0 );
2514 application.SendNotification();
2516 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
2518 application.SendNotification();
2520 //Compare between CPU calculated value and Shader Visual calculated value
2521 auto testProperty = [&application, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const char* name, const Property::Value& start, const Property::Value& target, int tc_offset, int value_type, float progress)->void
2523 int tc = (test_case + tc_offset);
2524 int idx_easing = tc % 4; tc /= 4;
2525 int idx_motion = tc % 2; tc /= 2;
2526 int idx_loop_count = tc % 3; tc /= 3;
2527 int idx_direction = tc % 2; tc /= 2;
2528 int idx_delay = tc % 4; tc /= 4;
2530 float duration = _duration - _repeat_delay;
2531 float repeat_delay = _repeat_delay;
2532 float delay = _delay[idx_delay] * _duration;
2533 int direction = _direction[idx_direction];
2534 int loop_count = _loop_count[idx_loop_count];
2535 int motion = _motion[idx_motion];
2536 int easing = _easing[idx_easing];
2538 progress -= delay / _duration;
2540 Property::Value s = start;
2541 Property::Value t = target;
2542 if( direction == 1 )
2547 float x; ///< Animator progress value
2548 if( loop_count == 0 )
2552 else if( loop_count > 0 && progress + 0.01f > loop_count )
2554 x = ( motion == 0 ) ? 1.0f : 0.0f;
2558 if( progress < 0.0f )
2562 progress = fmodf( progress, 1.0f );
2563 progress = Dali::Clamp( (progress * (duration + repeat_delay) - repeat_delay) / duration, 0.0f, 1.0f );
2568 x = progress * 2.0f;
2575 if( easing == 1 ) // EASE_IN
2579 else if( easing == 2 ) // EASE_OUT
2583 else if( easing == 3 ) // EASE_IN_OUT
2585 x = x * x * (3.0f - 2.0f * x);
2588 if( value_type == 0 ) // result type is Float
2592 res = s.Get<float>() * (1.0f - x) + t.Get<float>() * (x);
2593 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<float>(name, cur), true, TEST_LOCATION );
2594 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2596 else if( value_type == 1 ) // result type is Vector2
2600 res = s.Get<Vector2>() * (1.0f - x) + t.Get<Vector2>() * (x);
2601 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector2>(name, cur), true, TEST_LOCATION );
2602 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2604 else if( value_type == 2 ) // result type is Vector3
2608 res = s.Get<Vector3>() * (1.0f - x) + t.Get<Vector3>() * (x);
2609 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector3>(name, cur), true, TEST_LOCATION );
2610 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2612 else // result type is Vector4
2616 res = s.Get<Vector4>() * (1.0f - x) + t.Get<Vector4>() * (x);
2617 DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector4>(name, cur), true, TEST_LOCATION );
2618 DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2623 for( int iter = 0; iter < 2; iter++ ) // test 2*duration seconds
2625 for( int step_iter = 0; step_iter < 3; step_iter++ )
2627 application.SendNotification();
2628 application.Render( _duration * 250.f ); // step i/4
2629 application.SendNotification();
2632 testProperty( "start_point" , Property::Value( start1 ) , Property::Value( start2 ) , 0, 1, step );
2633 testProperty( "end_point" , Property::Value( end1 ) , Property::Value( end2 ) , 1, 1, step );
2634 testProperty( "start_color" , Property::Value( start_color1 ) , Property::Value( start_color2 ) , 2, 3, step );
2635 testProperty( "end_color" , Property::Value( end_color1 ) , Property::Value( end_color2 ) , 3, 3, step );
2636 testProperty( "rotate_center" , Property::Value( rotate_center1 ), Property::Value( rotate_center2 ), 4, 1, step );
2637 testProperty( "rotate_angle" , Property::Value( rotate_amount1 ), Property::Value( rotate_amount2 ), 5, 0, step );
2638 testProperty( "gradient_offset", Property::Value( offset1 ) , Property::Value( offset2 ) , 6, 0, step );
2640 application.SendNotification();
2641 application.Render(_duration * 250.f); // step 4/4 will not test
2642 application.SendNotification();
2646 application.SendNotification();
2648 application.SendNotification();
2649 application.Render(10.f); // tempral time
2650 application.SendNotification();
2657 int UtcDaliVisualWireframeVisual(void)
2659 ToolkitTestApplication application;
2661 VisualFactory factory = VisualFactory::Get();
2662 Property::Map propertyMap;
2663 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::WIREFRAME );
2665 // Create the visual.
2666 Visual::Base visual = factory.CreateVisual( propertyMap );
2668 DALI_TEST_CHECK( visual );
2670 Property::Map resultMap;
2671 visual.CreatePropertyMap( resultMap );
2673 // Check the property values from the returned map from visual
2674 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
2675 DALI_TEST_CHECK( value );
2676 DALI_TEST_CHECK( value->Get<int>() == Visual::WIREFRAME );
2681 int UtcDaliVisualGetTransform(void)
2683 ToolkitTestApplication application;
2684 tet_infoline( "UtcDaliVisualGetTransform: ColorVisual" );
2686 VisualFactory factory = VisualFactory::Get();
2687 Property::Map propertyMap;
2688 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
2689 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
2690 Visual::Base colorVisual = factory.CreateVisual( propertyMap );
2692 Dali::Property::Map visualMap;
2693 colorVisual.CreatePropertyMap( visualMap );
2694 Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
2695 Dali::Property::Map* map = value->GetMap();
2696 DALI_TEST_CHECK( map );
2698 //Test default values
2700 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2701 DALI_TEST_CHECK( typeValue );
2702 DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(0.0f,0.0f) );
2705 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2706 DALI_TEST_CHECK( typeValue );
2707 DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(1.0f,1.0f) );
2710 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
2711 DALI_TEST_CHECK( typeValue );
2712 DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
2715 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2716 DALI_TEST_CHECK( typeValue );
2717 DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
2720 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ORIGIN );
2721 DALI_TEST_CHECK( typeValue );
2722 DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::TOP_BEGIN );
2725 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ANCHOR_POINT );
2726 DALI_TEST_CHECK( typeValue );
2727 DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::TOP_BEGIN );
2730 Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::EXTRA_SIZE );
2731 DALI_TEST_CHECK( typeValue );
2732 DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(0.0f,0.0f) );
2738 static void TestTransform( ToolkitTestApplication& application, Visual::Base visual )
2740 Property::Map transform;
2741 transform.Insert( Visual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) );
2742 transform.Insert( Visual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) );
2743 transform.Insert( Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
2744 transform.Insert( Visual::Transform::Property::ORIGIN, "CENTER" );
2745 transform.Insert( Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END );
2746 transform.Insert( DevelVisual::Transform::Property::EXTRA_SIZE, Vector2(50.0f, 50.0f) );
2748 visual.SetTransformAndSize( transform, Vector2(100, 100) );
2750 Dali::Property::Map visualMap;
2751 visual.CreatePropertyMap( visualMap );
2752 Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
2753 Dali::Property::Map* map = value->GetMap();
2754 DALI_TEST_CHECK( map );
2757 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2758 DALI_TEST_CHECK( typeValue );
2759 DALI_TEST_EQUALS( typeValue->Get<Vector2>(),Vector2(10.0f,10.0f), TEST_LOCATION );
2762 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2763 DALI_TEST_CHECK( typeValue );
2764 DALI_TEST_EQUALS( typeValue->Get<Vector2>(), Vector2(0.2f,0.2f), TEST_LOCATION );
2767 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
2768 DALI_TEST_CHECK( typeValue );
2769 DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2772 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2773 DALI_TEST_CHECK( typeValue );
2774 DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ), TEST_LOCATION );
2777 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ORIGIN );
2778 DALI_TEST_CHECK( typeValue );
2779 DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::CENTER, TEST_LOCATION );
2782 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ANCHOR_POINT );
2783 DALI_TEST_CHECK( typeValue );
2784 DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::BOTTOM_END, TEST_LOCATION );
2787 Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::EXTRA_SIZE );
2788 DALI_TEST_CHECK( typeValue );
2789 DALI_TEST_EQUALS( typeValue->Get<Vector2>(),Vector2(50.0f,50.0f), TEST_LOCATION );
2792 //Put the visual on the stage
2793 DummyControl actor = DummyControl::New(true);
2794 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2795 actor.SetSize(2000, 2000);
2796 actor.SetParentOrigin(ParentOrigin::CENTER);
2797 Stage::GetCurrent().Add(actor);
2799 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2800 dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transform );
2802 application.SendNotification();
2803 application.Render(0);
2804 Renderer renderer( actor.GetRendererAt(0) );
2806 //Check that the properties have been registered on the Renderer
2807 Property::Index index = renderer.GetPropertyIndex( "offset" );
2808 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2809 Vector2 offset = renderer.GetProperty<Vector2>( index );
2810 DALI_TEST_EQUALS( offset, Vector2(10.0f,10.0f), TEST_LOCATION );
2812 index = renderer.GetPropertyIndex( "size" );
2813 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2814 Vector2 size = renderer.GetProperty<Vector2>( index );
2815 DALI_TEST_EQUALS( size, Vector2(0.2f,0.2f), TEST_LOCATION );
2817 index = renderer.GetPropertyIndex( "offsetSizeMode" );
2818 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2819 Vector4 offsetSizeMode = renderer.GetProperty<Vector4>( index );
2820 DALI_TEST_EQUALS( offsetSizeMode, Vector4(1.0f,1.0f,0.0f,0.0f), TEST_LOCATION );
2822 index = renderer.GetPropertyIndex( "origin" );
2823 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2824 Vector2 parentOrigin = renderer.GetProperty<Vector2>( index );
2825 DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION );
2827 index = renderer.GetPropertyIndex( "anchorPoint" );
2828 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2829 Vector2 anchorPoint = renderer.GetProperty<Vector2>( index );
2830 DALI_TEST_EQUALS( anchorPoint, Vector2(-0.5f,-0.5f), TEST_LOCATION );
2832 index = renderer.GetPropertyIndex( "extraSize" );
2833 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2834 Vector2 extraSize = renderer.GetProperty<Vector2>( index );
2835 DALI_TEST_EQUALS( extraSize, Vector2(50.0f,50.0f), TEST_LOCATION );
2837 //Set a new transform
2839 transform = DefaultTransform();
2840 transform.Insert( Visual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
2841 transform.Insert( Visual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
2842 transform.Insert( Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
2843 transform.Insert( DevelVisual::Transform::Property::EXTRA_SIZE, Vector2(0.5f, 0.5f) );
2844 visual.SetTransformAndSize( transform, Vector2(100, 100) );
2845 application.SendNotification();
2846 application.Render(0);
2848 //Check that the values have changed in the renderer
2849 offset = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "offset" ) );
2850 DALI_TEST_EQUALS( offset, Vector2(20.0f,20.0f), TEST_LOCATION );
2852 size = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "size" ) );
2853 DALI_TEST_EQUALS( size, Vector2(100.0f,100.0f), TEST_LOCATION );
2855 offsetSizeMode = renderer.GetProperty<Vector4>( renderer.GetPropertyIndex( "offsetSizeMode" ) );
2856 DALI_TEST_EQUALS( offsetSizeMode, Vector4(0.0f,0.0f,1.0f,1.0f), TEST_LOCATION );
2858 //Parent origin and anchor point should have the default values
2859 parentOrigin = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "origin" ) );
2860 DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION );
2862 anchorPoint = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "anchorPoint" ) );
2863 DALI_TEST_EQUALS( anchorPoint, Vector2(0.5f,0.5f), TEST_LOCATION );
2865 extraSize = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "extraSize" ) );
2866 DALI_TEST_EQUALS( extraSize, Vector2(0.5f,0.5f), TEST_LOCATION );
2869 int UtcDaliVisualSetTransform0(void)
2871 ToolkitTestApplication application;
2872 tet_infoline( "UtcDaliVisualSetTransform: ColorVisual" );
2874 VisualFactory factory = VisualFactory::Get();
2875 Property::Map propertyMap;
2876 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
2877 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
2878 Visual::Base visual = factory.CreateVisual( propertyMap );
2879 TestTransform( application, visual );
2880 TestMixColor( visual, ColorVisual::Property::MIX_COLOR, Color::BLUE );
2885 int UtcDaliVisualSetTransform1(void)
2887 ToolkitTestApplication application;
2888 tet_infoline( "UtcDaliVisualSetTransform: PrimitiveVisual" );
2890 VisualFactory factory = VisualFactory::Get();
2891 Property::Map propertyMap;
2892 propertyMap[ Toolkit::Visual::Property::TYPE ] = Visual::PRIMITIVE;
2893 propertyMap[ PrimitiveVisual::Property::MIX_COLOR ] = Color::WHITE;
2894 propertyMap[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::SPHERE;
2895 propertyMap[ PrimitiveVisual::Property::SLICES ] = 10;
2896 propertyMap[ PrimitiveVisual::Property::STACKS ] = 10;
2897 Visual::Base visual = factory.CreateVisual( propertyMap );
2898 TestTransform( application, visual );
2899 TestMixColor( visual, PrimitiveVisual::Property::MIX_COLOR, Color::WHITE );
2904 int UtcDaliVisualSetTransform2(void)
2906 ToolkitTestApplication application;
2907 tet_infoline( "UtcDaliVisualSetTransform: GradientVisual" );
2909 VisualFactory factory = VisualFactory::Get();
2910 Property::Map propertyMap;
2911 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::GRADIENT );
2912 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::GREEN );
2914 Property::Array stopOffsets;
2915 stopOffsets.PushBack( 0.0f );
2916 stopOffsets.PushBack( 0.3f );
2917 stopOffsets.PushBack( 0.6f );
2918 stopOffsets.PushBack( 0.8f );
2919 stopOffsets.PushBack( 1.0f );
2920 propertyMap.Insert( GradientVisual::Property::STOP_OFFSET, stopOffsets );
2922 Property::Array stopColors;
2923 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
2924 stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
2925 stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
2926 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
2927 stopColors.PushBack( Color::YELLOW );
2928 propertyMap.Insert( GradientVisual::Property::STOP_COLOR, stopColors );
2929 propertyMap.Insert( GradientVisual::Property::CENTER, Vector2( 0.5f, 0.5f ) );
2930 propertyMap.Insert( GradientVisual::Property::RADIUS, 1.414f );
2931 Visual::Base visual = factory.CreateVisual( propertyMap );
2932 TestTransform( application, visual );
2933 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::GREEN );
2938 int UtcDaliVisualSetTransform3(void)
2940 ToolkitTestApplication application;
2941 tet_infoline( "UtcDaliVisualSetTransform: BorderVisual" );
2943 VisualFactory factory = VisualFactory::Get();
2944 Property::Map propertyMap;
2945 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::BORDER );
2946 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::MAGENTA );
2947 propertyMap.Insert( BorderVisual::Property::COLOR, Vector4(0.f, 1.f, 0.f, 0.6f) );
2948 propertyMap.Insert( BorderVisual::Property::SIZE, 3.0f );
2949 Visual::Base visual = factory.CreateVisual( propertyMap );
2950 TestTransform( application, visual );
2951 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::MAGENTA );
2956 int UtcDaliVisualSetTransform4(void)
2958 ToolkitTestApplication application;
2959 tet_infoline( "UtcDaliVisualSetTransform: MeshVisual" );
2961 VisualFactory factory = VisualFactory::Get();
2962 Property::Map propertyMap;
2963 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
2964 propertyMap.Insert( Visual::Property::MIX_COLOR, Color::CYAN );
2966 propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
2967 propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
2968 propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION );
2969 propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
2970 propertyMap.Insert( "lightPosition", Vector3( 5.0f, 10.0f, 15.0f) );
2971 Visual::Base visual = factory.CreateVisual( propertyMap );
2972 TestTransform( application, visual );
2973 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::CYAN );
2978 int UtcDaliVisualSetTransform5(void)
2980 ToolkitTestApplication application;
2981 tet_infoline( "UtcDaliVisualSetTransform: ImageVisual from Image" );
2983 VisualFactory factory = VisualFactory::Get();
2984 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
2985 Visual::Base visual = factory.CreateVisual(image);
2986 TestTransform( application, visual );
2987 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::WHITE );
2992 int UtcDaliVisualSetTransform6(void)
2994 ToolkitTestApplication application;
2995 tet_infoline( "UtcDaliVisualSetTransform: ImageVisual for URL " );
2997 VisualFactory factory = VisualFactory::Get();
2998 Property::Map propertyMap;
2999 propertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
3000 propertyMap[Visual::Property::MIX_COLOR] = Color::YELLOW;
3001 propertyMap[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
3002 propertyMap[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = 100.0f;
3003 propertyMap[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = 100.0f;
3004 propertyMap[Toolkit::ImageVisual::Property::FITTING_MODE] = FittingMode::SCALE_TO_FILL;
3005 propertyMap[Toolkit::ImageVisual::Property::SAMPLING_MODE] = SamplingMode::BOX_THEN_LINEAR;
3006 propertyMap[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
3007 Visual::Base visual = factory.CreateVisual(propertyMap);
3008 TestTransform( application, visual );
3009 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::YELLOW );
3014 int UtcDaliVisualSetTransform7(void)
3016 ToolkitTestApplication application;
3017 tet_infoline( "UtcDaliVisualSetTransform: NPatch visual" );
3019 VisualFactory factory = VisualFactory::Get();
3020 Property::Map propertyMap;
3021 propertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
3022 propertyMap[Toolkit::ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
3023 propertyMap[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
3024 Visual::Base visual = factory.CreateVisual(propertyMap);
3025 TestTransform( application, visual );
3026 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::WHITE );
3031 int UtcDaliVisualTestTransformPoliciesAsStrings(void)
3033 ToolkitTestApplication application;
3034 tet_infoline( "UtcDaliVisualTestTransformPoliciesAsStrings: Use a ColorVisual and test the offset and size policies as strings" );
3036 VisualFactory factory = VisualFactory::Get();
3037 Property::Map propertyMap;
3038 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
3039 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
3040 Visual::Base visual = factory.CreateVisual( propertyMap );
3042 Property::Map transform;
3043 transform[ "offsetPolicy" ] = Property::Array().Add( "ABSOLUTE" )
3045 transform[ "sizePolicy" ] = Property::Array().Add( "RELATIVE" )
3047 visual.SetTransformAndSize( transform, Vector2(100, 100) );
3049 Dali::Property::Map visualMap;
3050 visual.CreatePropertyMap( visualMap );
3051 Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
3052 Dali::Property::Map* map = value->GetMap();
3053 DALI_TEST_CHECK( map );
3056 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
3057 DALI_TEST_CHECK( typeValue );
3058 DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::RELATIVE ), TEST_LOCATION );
3061 Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
3062 DALI_TEST_CHECK( typeValue );
3063 DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
3069 int UtcDaliNPatchVisualCustomShader(void)
3071 ToolkitTestApplication application;
3072 tet_infoline( "NPatchVisual with custom shader" );
3074 VisualFactory factory = VisualFactory::Get();
3075 Property::Map properties;
3076 Property::Map shader;
3077 const std::string vertexShader = "Foobar";
3078 const std::string fragmentShader = "Foobar";
3079 shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3080 shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3082 Property::Map transformMap;
3083 transformMap["size"] = Vector2( 0.5f, 0.5f ) ;
3084 transformMap["offset"] = Vector2( 20.0f, 0.0f ) ;
3085 transformMap["offsetPolicy"] = Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE );
3086 transformMap["anchorPoint"] = Align::CENTER;
3087 transformMap["origin"] = Align::CENTER;
3088 transformMap["extraSize"] = Vector2( 0.0f, 50.0f );
3089 properties[Visual::Property::TRANSFORM] = transformMap;
3091 properties[Visual::Property::TYPE] = Visual::IMAGE;
3092 properties[Visual::Property::MIX_COLOR] = Color::BLUE;
3093 properties[Visual::Property::SHADER]=shader;
3094 properties[ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
3095 properties[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
3097 Visual::Base visual = factory.CreateVisual( properties );
3098 TestMixColor( visual, Visual::Property::MIX_COLOR, Color::BLUE );
3100 // trigger creation through setting on stage
3101 DummyControl dummy = DummyControl::New(true);
3102 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
3103 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3104 dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
3105 dummy.SetSize(2000, 2000);
3106 dummy.SetParentOrigin(ParentOrigin::CENTER);
3107 Stage::GetCurrent().Add(dummy);
3108 application.SendNotification();
3110 Renderer renderer = dummy.GetRendererAt( 0 );
3111 Shader shader2 = renderer.GetShader();
3112 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
3113 Property::Map* map = value.GetMap();
3114 DALI_TEST_CHECK( map );
3116 Property::Index index = renderer.GetPropertyIndex("size");
3117 DALI_TEST_EQUALS( renderer.GetProperty( index ), Property::Value(Vector2(0.5, 0.5)), 0.001, TEST_LOCATION );
3119 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
3120 DALI_TEST_EQUALS( fragmentShader, fragment->Get<std::string>(), TEST_LOCATION );
3122 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
3123 DALI_TEST_EQUALS( vertexShader, vertex->Get<std::string>(), TEST_LOCATION );
3125 Vector2 extraSize = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "extraSize" ) );
3126 DALI_TEST_EQUALS( extraSize, Vector2(0.0f, 50.0f), TEST_LOCATION );
3131 int UtcDaliGradientVisualBlendMode(void)
3133 ToolkitTestApplication application;
3134 VisualFactory factory = VisualFactory::Get();
3136 Visual::Base opaqueGradientVisual = factory.CreateVisual(
3137 Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT )
3138 .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) )
3139 .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) )
3140 .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED )
3141 .Add( Color::GREEN ) ) );
3143 Visual::Base alphaGradientVisual = factory.CreateVisual(
3144 Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT )
3145 .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) )
3146 .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) )
3147 .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED )
3148 .Add( Vector4( 1.0f, 1.0f, 1.0f, 0.5f ) ) ) );
3150 DummyControl control = DummyControl::New(true);
3151 control.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
3152 Stage::GetCurrent().Add( control );
3154 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( control.GetImplementation() );
3155 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, opaqueGradientVisual );
3156 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, alphaGradientVisual );
3158 application.SendNotification();
3159 application.Render();
3161 // Control should have two renderers, the first one is opaque so our blending mode should be off, the second one has some alpha so should be set to automatic
3162 DALI_TEST_EQUALS( 2u, control.GetRendererCount(), TEST_LOCATION );
3163 DALI_TEST_EQUALS( control.GetRendererAt( 0 ).GetProperty( Renderer::Property::BLEND_MODE ).Get<int>(), (int)BlendMode::OFF, TEST_LOCATION );
3164 DALI_TEST_EQUALS( control.GetRendererAt( 1 ).GetProperty( Renderer::Property::BLEND_MODE ).Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
3169 int UtcDaliVisualRendererRemovalAndReAddition(void)
3171 ToolkitTestApplication application;
3172 tet_infoline( "UtcDaliVisualRendererRemoval" );
3174 VisualFactory factory = VisualFactory::Get();
3175 Property::Map propertyMap;
3176 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
3177 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
3178 Visual::Base visual = factory.CreateVisual( propertyMap );
3180 visual.SetDepthIndex( 1 );
3182 DummyControl dummyControl = DummyControl::New(true);
3183 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3184 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3185 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3187 dummyControl.SetSize(200.f, 200.f);
3188 tet_infoline( "Add control with visual to stage and check renderer count is 1" );
3190 Stage::GetCurrent().Add( dummyControl );
3192 application.SendNotification();
3193 application.Render();
3195 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3197 tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
3198 Stage::GetCurrent().Remove( dummyControl );
3199 application.SendNotification();
3200 application.Render();
3202 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3204 tet_infoline( "Re-add control with visual to stage and check renderer count is still 1" );
3206 Stage::GetCurrent().Add( dummyControl );
3208 application.SendNotification();
3209 application.Render();
3211 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3218 int UtcDaliVisualTextVisualRender(void)
3220 ToolkitTestApplication application;
3221 tet_infoline( "UtcDaliVisualTextVisualRender" );
3223 VisualFactory factory = VisualFactory::Get();
3224 Property::Map propertyMap;
3225 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3226 propertyMap.Insert( "mixColor", Color::WHITE );
3227 propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
3228 propertyMap.Insert( "enableMarkup", false );
3229 propertyMap.Insert( "text", "Hello world" );
3230 propertyMap.Insert( "fontFamily", "TizenSans" );
3232 Property::Map fontStyleMapSet;
3233 fontStyleMapSet.Insert( "weight", "bold" );
3234 propertyMap.Insert( "fontStyle", fontStyleMapSet );
3236 propertyMap.Insert( "pointSize", 12.f );
3237 propertyMap.Insert( "multiLine", true );
3238 propertyMap.Insert( "horizontalAlignment", "CENTER" );
3239 propertyMap.Insert( "verticalAlignment", "CENTER" );
3240 propertyMap.Insert( "textColor", Color::RED );
3241 Visual::Base textVisual = factory.CreateVisual( propertyMap );
3242 textVisual.SetDepthIndex( 1 );
3244 DummyControl dummyControl = DummyControl::New(true);
3245 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3246 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3247 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3249 dummyControl.SetSize(200.f, 200.f);
3250 dummyControl.SetParentOrigin( ParentOrigin::CENTER );
3252 Stage::GetCurrent().Add( dummyControl );
3253 application.SendNotification();
3254 application.Render();
3257 // Create a texture bigger than the maximum allowed by the image atlas. Used to increase coverage.
3258 propertyMap.Clear();
3259 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3260 propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
3261 propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
3262 propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
3264 Property::Map transformMap;
3265 transformMap.Insert( "size", Vector2( 0.5f, 0.5f ) );
3266 propertyMap.Insert( Visual::Property::TRANSFORM, transformMap );
3268 textVisual = factory.CreateVisual( propertyMap );
3269 textVisual.SetDepthIndex( 1 );
3271 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3272 dummyControl.SetSize( 720.f, 640.f );
3274 application.SendNotification(); // force process events to ensure text visual
3275 // adds renderer to the dummy control in OnRelayout
3276 application.Render();
3278 Renderer renderer = dummyControl.GetRendererAt(0u);
3279 Property::Index index = renderer.GetPropertyIndex("size");
3281 tet_infoline( "Test that the TextVisual has NOT overridden what was set by developer" );
3282 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 0.5f, 0.5f ), 0.001f, TEST_LOCATION );
3287 int UtcDaliVisualTextVisualDisableEnable(void)
3289 ToolkitTestApplication application;
3290 tet_infoline( "UtcDaliVisualTextVisualDisableEnable Ensure Text visible can be re-enabled" );
3292 VisualFactory factory = VisualFactory::Get();
3293 Property::Map propertyMap;
3294 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3295 propertyMap.Insert( "mixColor", Color::WHITE );
3296 propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
3297 propertyMap.Insert( "enableMarkup", false );
3298 propertyMap.Insert( "text", "Hello world" );
3299 propertyMap.Insert( "fontFamily", "TizenSans" );
3301 Property::Map fontStyleMapSet;
3302 fontStyleMapSet.Insert( "weight", "bold" );
3303 propertyMap.Insert( "fontStyle", fontStyleMapSet );
3305 propertyMap.Insert( "pointSize", 12.f );
3306 propertyMap.Insert( "multiLine", true );
3307 propertyMap.Insert( "horizontalAlignment", "CENTER" );
3308 propertyMap.Insert( "verticalAlignment", "CENTER" );
3309 propertyMap.Insert( "textColor", Color::RED );
3310 Visual::Base textVisual = factory.CreateVisual( propertyMap );
3311 textVisual.SetDepthIndex( 1 );
3313 DummyControl dummyControl = DummyControl::New(true);
3314 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3315 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3316 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3318 dummyControl.SetSize(200.f, 200.f);
3319 dummyControl.SetParentOrigin( ParentOrigin::CENTER );
3321 Stage::GetCurrent().Add( dummyControl );
3322 application.SendNotification();
3323 application.Render();
3325 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3327 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
3329 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3331 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true );
3333 DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3338 int UtcDaliVisualPremultipliedAlpha(void)
3340 ToolkitTestApplication application;
3341 tet_infoline( "UtcDaliVisualPremultipliedAlpha" );
3343 VisualFactory factory = VisualFactory::Get();
3345 // image visual, test default value ( true )
3347 Visual::Base imageVisual = factory.CreateVisual(
3349 .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3350 .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
3352 Dali::Property::Map visualMap;
3353 imageVisual.CreatePropertyMap( visualMap );
3354 Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3357 DALI_TEST_CHECK( value );
3358 DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION );
3361 // image visual, override premultiplied
3363 Visual::Base imageVisual = factory.CreateVisual(
3365 .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3366 .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME )
3367 .Add( Visual::Property::PREMULTIPLIED_ALPHA, false ) );
3369 Dali::Property::Map visualMap;
3370 imageVisual.CreatePropertyMap( visualMap );
3371 Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3374 DALI_TEST_CHECK( value );
3375 DALI_TEST_EQUALS( value->Get<bool>(), false, TEST_LOCATION);
3378 // svg visual ( premultiplied alpha by default is true )
3380 Visual::Base imageVisual = factory.CreateVisual(
3382 .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3383 .Add( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ) );
3385 Dali::Property::Map visualMap;
3386 imageVisual.CreatePropertyMap( visualMap );
3387 Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3390 DALI_TEST_CHECK( value );
3391 DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION );
3397 int UtcDaliRegisterVisualOrder(void)
3399 ToolkitTestApplication application;
3400 tet_infoline( "Register Visual Order" );
3402 DummyControl dummyControl = DummyControl::New(true);
3403 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3405 VisualFactory factory = VisualFactory::Get();
3406 Property::Map propertyMap;
3407 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
3408 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
3410 tet_infoline( "Register visual, should have depth index of 0.0f" );
3411 Visual::Base testVisual = factory.CreateVisual( propertyMap );
3412 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual );
3413 DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 0, TEST_LOCATION );
3415 tet_infoline( "Register more visuals, each added one should have a depth index greater than previous" );
3417 Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3418 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
3419 DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual.GetDepthIndex() );
3421 Visual::Base foregroundVisual = factory.CreateVisual( propertyMap );
3422 dummyImpl.RegisterVisual( DummyControl::Property::FOREGROUND_VISUAL, foregroundVisual );
3423 DALI_TEST_CHECK( foregroundVisual.GetDepthIndex() > testVisual2.GetDepthIndex() );
3425 Visual::Base focusVisual = factory.CreateVisual( propertyMap );
3426 dummyImpl.RegisterVisual( DummyControl::Property::FOCUS_VISUAL, focusVisual );
3427 DALI_TEST_CHECK( focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex() );
3429 tet_infoline( "Set depth index on a new visual before registering, the depth index should not have been changed" );
3430 Visual::Base labelVisual = factory.CreateVisual( propertyMap );
3431 labelVisual.SetDepthIndex( -2000 );
3432 dummyImpl.RegisterVisual( DummyControl::Property::LABEL_VISUAL, labelVisual );
3433 DALI_TEST_EQUALS( labelVisual.GetDepthIndex(), -2000, TEST_LOCATION );
3435 tet_infoline( "Replace visual, the depth index should be the same as what was previously set" );
3436 const int testVisual2DepthIndex = testVisual2.GetDepthIndex();
3437 Visual::Base testVisual2Replacement = factory.CreateVisual( propertyMap );
3438 DALI_TEST_CHECK( testVisual2Replacement.GetDepthIndex() != testVisual2DepthIndex );
3439 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2Replacement );
3440 DALI_TEST_EQUALS( testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION );
3442 tet_infoline( "Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured" );
3443 Visual::Base anotherTestVisual2Replacement = factory.CreateVisual( propertyMap );
3444 anotherTestVisual2Replacement.SetDepthIndex( 2000 );
3445 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement );
3446 DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION );
3448 dummyControl.SetSize(200.f, 200.f);
3449 Stage::GetCurrent().Add( dummyControl );
3454 int UtcDaliRegisterVisualOrder02(void)
3456 ToolkitTestApplication application;
3457 tet_infoline( "Register Visual Order with Background Set" );
3459 DummyControl dummyControl = DummyControl::New(true);
3460 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3462 const int backgroundDepthIndex = Toolkit::DepthIndex::BACKGROUND;
3464 VisualFactory factory = VisualFactory::Get();
3465 Property::Map propertyMap;
3466 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
3467 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
3469 tet_printf( "Register a control background visual, should have depth index of %d\n", backgroundDepthIndex );
3471 dummyControl.SetProperty( Control::Property::BACKGROUND, propertyMap );
3473 const int TEST_VISUAL_1_DEPTH_INDEX = 0;
3474 tet_printf( "Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX );
3475 Visual::Base testVisual1 = factory.CreateVisual( propertyMap );
3476 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual1 );
3477 DALI_TEST_EQUALS( testVisual1.GetDepthIndex(), TEST_VISUAL_1_DEPTH_INDEX , TEST_LOCATION );
3479 tet_printf( "Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX );
3480 Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3481 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
3482 DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex() );
3484 dummyControl.SetSize(200.f, 200.f);
3485 Stage::GetCurrent().Add( dummyControl );
3490 int UtcDaliRegisterVisualWithDepthIndex(void)
3492 ToolkitTestApplication application;
3493 tet_infoline( "Register a Visual With Depth Index" );
3495 DummyControl dummyControl = DummyControl::New(true);
3496 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3498 VisualFactory factory = VisualFactory::Get();
3499 Property::Map propertyMap;
3500 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
3501 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
3503 tet_infoline( "Register a visual with a depth index, it should be enabled by default too" );
3504 Visual::Base testVisual = factory.CreateVisual( propertyMap );
3505 DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL, testVisual, 203 );
3506 DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 203, TEST_LOCATION );
3507 DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL ), true, TEST_LOCATION );
3509 tet_infoline( "Register another visual with a depth index and it disabled" );
3510 Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3511 DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual2, false, 450 );
3512 DALI_TEST_EQUALS( testVisual2.GetDepthIndex(), 450, TEST_LOCATION );
3513 DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), false, TEST_LOCATION );
3515 tet_infoline( "Register another visual with a depth index and it enabled using the enabled API" );
3516 Visual::Base testVisual3 = factory.CreateVisual( propertyMap );
3517 DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual3, true, 300 );
3518 DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300, TEST_LOCATION );
3519 DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
3521 dummyControl.SetSize(200.f, 200.f);
3522 Stage::GetCurrent().Add( dummyControl );
3527 int UtcDaliColorVisualRenderIfTransparentProperty(void)
3529 ToolkitTestApplication application;
3530 tet_infoline( "Test the renderIfTransparent property of ColorVisual" );
3532 VisualFactory factory = VisualFactory::Get();
3533 Property::Map propertyMap;
3534 propertyMap.Insert( Visual::Property::TYPE, Visual::COLOR );
3535 propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE );
3537 tet_infoline( "Check default value" );
3539 Visual::Base testVisual = factory.CreateVisual( propertyMap );
3540 Property::Map returnedMap;
3541 testVisual.CreatePropertyMap( returnedMap );
3543 Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3544 DALI_TEST_CHECK( renderIfTransparentProperty );
3545 DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
3548 propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true );
3550 tet_infoline( "Ensure set to value required" );
3552 Visual::Base testVisual = factory.CreateVisual( propertyMap );
3553 Property::Map returnedMap;
3554 testVisual.CreatePropertyMap( returnedMap );
3556 Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3557 DALI_TEST_CHECK( renderIfTransparentProperty );
3558 DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION );
3561 propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE;
3563 tet_infoline( "Ensure it returns default value if set to wrong type" );
3565 Visual::Base testVisual = factory.CreateVisual( propertyMap );
3566 Property::Map returnedMap;
3567 testVisual.CreatePropertyMap( returnedMap );
3569 Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3570 DALI_TEST_CHECK( renderIfTransparentProperty );
3571 DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
3577 int UtcDaliSvgVisualCustomShader(void)
3579 ToolkitTestApplication application;
3580 tet_infoline( "SvgVisual with custom shader" );
3582 VisualFactory factory = VisualFactory::Get();
3583 Property::Map properties;
3584 Property::Map shader;
3585 const std::string vertexShader = "Foobar";
3586 const std::string fragmentShader = "Foobar";
3587 shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3588 shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3590 properties[Visual::Property::TYPE] = Visual::IMAGE;
3591 properties[Visual::Property::SHADER] = shader;
3592 properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
3594 Visual::Base visual = factory.CreateVisual( properties );
3596 // trigger creation through setting on stage
3597 DummyControl dummy = DummyControl::New( true );
3598 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3599 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3601 dummy.SetSize( 200.f, 200.f );
3602 dummy.SetParentOrigin( ParentOrigin::CENTER );
3603 Stage::GetCurrent().Add( dummy );
3605 application.SendNotification();
3606 application.Render();
3608 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3610 Renderer renderer = dummy.GetRendererAt( 0 );
3611 Shader shader2 = renderer.GetShader();
3612 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
3613 Property::Map* map = value.GetMap();
3614 DALI_TEST_CHECK( map );
3616 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
3617 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
3619 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
3620 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
3625 int UtcDaliVisualRoundedCorner(void)
3627 ToolkitTestApplication application;
3628 tet_infoline( "UtcDaliVisualRoundedCorner" );
3632 VisualFactory factory = VisualFactory::Get();
3633 Property::Map properties;
3634 float cornerRadius = 30.0f;
3636 properties[Visual::Property::TYPE] = Visual::IMAGE;
3637 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
3638 properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
3640 Visual::Base visual = factory.CreateVisual( properties );
3642 // trigger creation through setting on stage
3643 DummyControl dummy = DummyControl::New( true );
3644 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3645 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3647 dummy.SetSize( 200.f, 200.f );
3648 dummy.SetParentOrigin( ParentOrigin::CENTER );
3649 Stage::GetCurrent().Add( dummy );
3651 application.SendNotification();
3652 application.Render();
3654 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3656 application.SendNotification();
3657 application.Render();
3659 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
3664 VisualFactory factory = VisualFactory::Get();
3665 Property::Map properties;
3666 float cornerRadius = 30.0f;
3668 properties[Visual::Property::TYPE] = Visual::COLOR;
3669 properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
3670 properties["cornerRadius"] = cornerRadius;
3672 Visual::Base visual = factory.CreateVisual( properties );
3674 // trigger creation through setting on stage
3675 DummyControl dummy = DummyControl::New( true );
3676 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3677 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3679 dummy.SetSize( 200.f, 200.f );
3680 dummy.SetParentOrigin( ParentOrigin::CENTER );
3681 Stage::GetCurrent().Add( dummy );
3683 application.SendNotification();
3684 application.Render();
3686 application.SendNotification();
3687 application.Render();
3689 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
3695 int UtcDaliColorVisualBlurRadius(void)
3697 ToolkitTestApplication application;
3698 tet_infoline( "UtcDaliColorVisualBlurRadius" );
3700 VisualFactory factory = VisualFactory::Get();
3701 Property::Map properties;
3702 float blurRadius = 20.0f;
3704 properties[Visual::Property::TYPE] = Visual::COLOR;
3705 properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
3706 properties["blurRadius"] = blurRadius;
3708 Visual::Base visual = factory.CreateVisual( properties );
3710 // trigger creation through setting on stage
3711 DummyControl dummy = DummyControl::New( true );
3712 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3713 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3715 dummy.SetSize( 200.f, 200.f );
3716 dummy.SetParentOrigin( ParentOrigin::CENTER );
3717 Stage::GetCurrent().Add( dummy );
3719 application.SendNotification();
3720 application.Render();
3722 application.SendNotification();
3723 application.Render();
3725 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "blurRadius", blurRadius ), true, TEST_LOCATION );