2 * Copyright (c) 2016 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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali/public-api/rendering/renderer.h>
21 #include <dali/public-api/rendering/texture-set.h>
22 #include <dali/public-api/rendering/shader.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
24 #include <dali-toolkit/dali-toolkit.h>
27 using namespace Dali::Toolkit;
31 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
32 const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
33 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
34 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
35 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
36 const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
39 void dali_visual_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_visual_cleanup(void)
46 test_return_value = TET_PASS;
49 int UtcDaliVisualCopyAndAssignment(void)
51 ToolkitTestApplication application;
52 tet_infoline( "UtcDaliVisualCopyAndAssignment" );
54 VisualFactory factory = VisualFactory::Get();
55 Property::Map propertyMap;
56 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
57 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
58 Visual::Base visual = factory.CreateVisual( propertyMap );
60 Visual::Base visualCopy( visual );
61 DALI_TEST_CHECK(visual == visualCopy);
63 Visual::Base emptyVisual;
64 Visual::Base emptyVisualCopy( emptyVisual );
65 DALI_TEST_CHECK(emptyVisual == emptyVisualCopy);
67 Visual::Base visualEquals;
68 visualEquals = visual;
69 DALI_TEST_CHECK(visual == visualEquals);
71 Visual::Base emptyVisualEquals;
72 emptyVisualEquals = emptyVisual;
73 DALI_TEST_CHECK( emptyVisual == emptyVisualEquals );
77 DALI_TEST_CHECK( visual = visualCopy );
82 int UtcDaliVisualSetGetDepthIndex(void)
84 ToolkitTestApplication application;
85 tet_infoline( "UtcDaliVisualSetDepthIndex" );
87 VisualFactory factory = VisualFactory::Get();
88 Property::Map propertyMap;
89 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
90 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
91 Visual::Base visual = factory.CreateVisual( propertyMap );
93 visual.SetDepthIndex( 1.f );
95 Actor actor = Actor::New();
96 actor.SetSize(200.f, 200.f);
97 Stage::GetCurrent().Add( actor );
98 visual.SetOnStage( actor );
100 int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
101 DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
102 DALI_TEST_EQUALS( visual.GetDepthIndex(), 1.f, TEST_LOCATION );
104 visual.SetDepthIndex( -1.f );
105 depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
106 DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
107 DALI_TEST_EQUALS( visual.GetDepthIndex(), -1.f, TEST_LOCATION );
112 int UtcDaliVisualSize(void)
114 ToolkitTestApplication application;
115 tet_infoline( "UtcDaliVisualGetNaturalSize" );
117 VisualFactory factory = VisualFactory::Get();
118 Vector2 visualSize( 20.f, 30.f );
122 Dali::Property::Map map;
123 map[ Visual::Property::TYPE ] = Visual::COLOR;
124 map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
125 Visual::Base colorVisual = factory.CreateVisual( map );
126 colorVisual.SetSize( visualSize );
127 DALI_TEST_EQUALS( colorVisual.GetSize(), visualSize, TEST_LOCATION );
128 colorVisual.GetNaturalSize(naturalSize);
129 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
132 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
133 Visual::Base imageVisual = factory.CreateVisual( image );
134 imageVisual.SetSize( visualSize );
135 DALI_TEST_EQUALS( imageVisual.GetSize(), visualSize, TEST_LOCATION );
136 imageVisual.GetNaturalSize(naturalSize);
137 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
140 TestPlatformAbstraction& platform = application.GetPlatform();
141 Vector2 testSize(80.f, 160.f);
142 platform.SetClosestImageSize(testSize);
143 image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
144 Visual::Base nPatchVisual = factory.CreateVisual( image );
145 nPatchVisual.SetSize( visualSize );
146 DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION );
147 nPatchVisual.GetNaturalSize(naturalSize);
148 DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION );
151 float borderSize = 5.f;
153 map[ Visual::Property::TYPE ] = Visual::BORDER;
154 map[ BorderVisual::Property::COLOR ] = Color::RED;
155 map[ BorderVisual::Property::SIZE ] = borderSize;
156 Visual::Base borderVisual = factory.CreateVisual( map );
157 borderVisual.SetSize( visualSize );
158 DALI_TEST_EQUALS( borderVisual.GetSize(), visualSize, TEST_LOCATION );
159 borderVisual.GetNaturalSize(naturalSize);
160 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
162 // gradient gradientVisual
163 Property::Map propertyMap;
164 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
165 Vector2 start(-1.f, -1.f);
166 Vector2 end(1.f, 1.f);
167 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
168 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
169 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.f, 1.f));
170 Property::Array stopColors;
171 stopColors.PushBack( Color::RED );
172 stopColors.PushBack( Color::GREEN );
173 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
174 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
175 gradientVisual.SetSize( visualSize );
176 DALI_TEST_EQUALS( gradientVisual.GetSize(), visualSize, TEST_LOCATION );
177 gradientVisual.GetNaturalSize(naturalSize);
178 DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
181 Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
182 svgVisual.SetSize( visualSize );
183 DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION );
184 svgVisual.GetNaturalSize(naturalSize);
186 // <svg width="100" height="100">
187 // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
189 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
191 // svg visual with a size
192 Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
193 DALI_TEST_EQUALS( svgVisual2.GetSize(), Vector2( 200.f, 200.f ), TEST_LOCATION );
194 svgVisual2.GetNaturalSize(naturalSize);
195 DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
197 // Batch Image visual
199 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
200 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
201 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
202 Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
203 batchImageVisual.SetSize( visualSize );
204 DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION );
205 batchImageVisual.GetNaturalSize( naturalSize );
206 DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION );
211 int UtcDaliVisualSetOnOffStage(void)
213 ToolkitTestApplication application;
214 tet_infoline( "UtcDaliVisualSetDepthIndex" );
216 VisualFactory factory = VisualFactory::Get();
217 Property::Map propertyMap;
218 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
219 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
220 Visual::Base visual = factory.CreateVisual( propertyMap );
222 Actor actor = Actor::New();
223 actor.SetSize(200.f, 200.f);
224 Stage::GetCurrent().Add( actor );
226 application.SendNotification();
227 application.Render(0);
228 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
230 visual.SetOnStage( actor );
231 application.SendNotification();
232 application.Render(0);
233 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
235 visual.SetOffStage( actor );
236 application.SendNotification();
237 application.Render(0);
238 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
243 int UtcDaliVisualRemoveAndReset(void)
245 ToolkitTestApplication application;
246 tet_infoline( "intUtcDaliVisualRemoveAndReset" );
248 VisualFactory factory = VisualFactory::Get();
250 Actor actor = Actor::New();
251 actor.SetSize(200.f, 200.f);
252 Stage::GetCurrent().Add( actor );
254 Visual::Base imageVisual;
255 // test calling RemoveAndReset with an empty handle
258 imageVisual.RemoveAndReset( actor );
259 tet_result(TET_PASS);
261 catch (DaliException& exception)
263 tet_result(TET_FAIL);
266 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
267 imageVisual = factory.CreateVisual(image);
268 DALI_TEST_CHECK( imageVisual );
270 imageVisual.SetOnStage( actor );
271 application.SendNotification();
272 application.Render(0);
273 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
275 imageVisual.RemoveAndReset( actor );
276 application.SendNotification();
277 application.Render(0);
278 DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); // visual is removed from actor
279 DALI_TEST_CHECK( !imageVisual ); // visual is reset
284 int UtcDaliVisualGetPropertyMap1(void)
286 ToolkitTestApplication application;
287 tet_infoline( "UtcDaliVisualGetPropertyMap1: ColorVisual" );
289 VisualFactory factory = VisualFactory::Get();
290 Property::Map propertyMap;
291 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
292 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
293 Visual::Base colorVisual = factory.CreateVisual( propertyMap );
295 Property::Map resultMap;
296 colorVisual.CreatePropertyMap( resultMap );
298 Property::Value* typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
299 DALI_TEST_CHECK( typeValue );
300 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::COLOR );
302 Property::Value* colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
303 DALI_TEST_CHECK( colorValue );
304 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
306 // change the blend color
308 colorVisual.RemoveAndReset( actor );
309 propertyMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
310 colorVisual = factory.CreateVisual( propertyMap );
311 colorVisual.CreatePropertyMap( resultMap );
313 colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
314 DALI_TEST_CHECK( colorValue );
315 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
317 // Test the properties. TODO: to be completed.
318 colorVisual.SetProperty( ColorVisual::Property::MIX_COLOR, Color::RED );
319 Property::Value value = colorVisual.GetProperty( ColorVisual::Property::MIX_COLOR );
324 int UtcDaliVisualGetPropertyMap2(void)
326 ToolkitTestApplication application;
327 tet_infoline( "UtcDaliVisualGetPropertyMap2: BorderVisual" );
329 VisualFactory factory = VisualFactory::Get();
330 Property::Map propertyMap;
331 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
332 propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
333 propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
334 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
336 Property::Map resultMap;
337 borderVisual.CreatePropertyMap( resultMap );
339 // check the property values from the returned map from visual
340 Property::Value* typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
341 DALI_TEST_CHECK( typeValue );
342 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
344 Property::Value* colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
345 DALI_TEST_CHECK( colorValue );
346 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
348 Property::Value* sizeValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
349 DALI_TEST_CHECK( sizeValue );
350 DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
352 Property::Map propertyMap1;
353 propertyMap1[ Visual::Property::TYPE ] = Visual::BORDER;
354 propertyMap1[ BorderVisual::Property::COLOR ] = Color::CYAN;
355 propertyMap1[ BorderVisual::Property::SIZE ] = 10.0f;
356 borderVisual = factory.CreateVisual( propertyMap1 );
357 borderVisual.CreatePropertyMap( resultMap );
359 typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
360 DALI_TEST_CHECK( typeValue );
361 DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
363 colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
364 DALI_TEST_CHECK( colorValue );
365 DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
367 colorValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
368 DALI_TEST_CHECK( colorValue );
369 DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
371 // Test the properties. TODO: to be completed.
372 borderVisual.SetProperty( BorderVisual::Property::COLOR, Color::RED );
373 Property::Value value = borderVisual.GetProperty( BorderVisual::Property::COLOR );
378 int UtcDaliVisualGetPropertyMap3(void)
380 ToolkitTestApplication application;
381 tet_infoline( "UtcDaliVisualGetPropertyMap3: linear GradientVisual" );
383 VisualFactory factory = VisualFactory::Get();
384 DALI_TEST_CHECK( factory );
386 Property::Map propertyMap;
387 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
389 Vector2 start(-1.f, -1.f);
390 Vector2 end(1.f, 1.f);
391 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
392 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
393 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
395 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.2f, 0.8f));
397 Property::Array stopColors;
398 stopColors.PushBack( Color::RED );
399 stopColors.PushBack( Color::GREEN );
400 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
402 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
404 Property::Map resultMap;
405 gradientVisual.CreatePropertyMap( resultMap );
407 // check the property values from the returned map from visual
408 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
409 DALI_TEST_CHECK( value );
410 DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
412 value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
413 DALI_TEST_CHECK( value );
414 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::OBJECT_BOUNDING_BOX );
416 value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
417 DALI_TEST_CHECK( value );
418 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::REPEAT );
420 value = resultMap.Find( GradientVisual::Property::START_POSITION, Property::VECTOR2 );
421 DALI_TEST_CHECK( value );
422 DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
424 value = resultMap.Find( GradientVisual::Property::END_POSITION, Property::VECTOR2 );
425 DALI_TEST_CHECK( value );
426 DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
428 value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
429 DALI_TEST_CHECK( value );
430 Property::Array* offsetArray = value->GetArray();
431 DALI_TEST_CHECK( offsetArray->Count() == 2 );
432 DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
433 DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
435 value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
436 DALI_TEST_CHECK( value );
437 Property::Array* colorArray = value->GetArray();
438 DALI_TEST_CHECK( colorArray->Count() == 2 );
439 DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
440 DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
442 // Test the properties. TODO: to be completed.
443 gradientVisual.SetProperty( GradientVisual::Property::STOP_COLOR, Color::RED );
444 Property::Value gradientValue = gradientVisual.GetProperty( GradientVisual::Property::STOP_COLOR );
449 int UtcDaliVisualGetPropertyMap4(void)
451 ToolkitTestApplication application;
452 tet_infoline( "UtcDaliVisualGetPropertyMap4: radial GradientVisual" );
454 VisualFactory factory = VisualFactory::Get();
455 DALI_TEST_CHECK( factory );
457 Property::Map propertyMap;
458 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
460 Vector2 center(100.f, 100.f);
461 float radius = 100.f;
462 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
463 propertyMap.Insert(GradientVisual::Property::CENTER, center);
464 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
465 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector3(0.1f, 0.3f, 1.1f));
467 Property::Array stopColors;
468 stopColors.PushBack( Color::RED );
469 stopColors.PushBack( Color::BLACK );
470 stopColors.PushBack( Color::GREEN );
471 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
473 Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
474 DALI_TEST_CHECK( gradientVisual );
476 Property::Map resultMap;
477 gradientVisual.CreatePropertyMap( resultMap );
479 // check the property values from the returned map from visual
480 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
481 DALI_TEST_CHECK( value );
482 DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
484 value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
485 DALI_TEST_CHECK( value );
486 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::USER_SPACE );
488 value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
489 DALI_TEST_CHECK( value );
490 DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::PAD );
492 value = resultMap.Find( GradientVisual::Property::CENTER, Property::VECTOR2 );
493 DALI_TEST_CHECK( value );
494 DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
496 value = resultMap.Find( GradientVisual::Property::RADIUS, Property::FLOAT );
497 DALI_TEST_CHECK( value );
498 DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
500 value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
501 DALI_TEST_CHECK( value );
502 Property::Array* offsetArray = value->GetArray();
503 DALI_TEST_CHECK( offsetArray->Count() == 3 );
504 DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
505 DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
506 // any stop value will be clamped to [0.0, 1.0];
507 DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
509 value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
510 DALI_TEST_CHECK( value );
511 Property::Array* colorArray = value->GetArray();
512 DALI_TEST_CHECK( colorArray->Count() == 3 );
513 DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
514 DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
515 DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
520 int UtcDaliVisualGetPropertyMap5(void)
522 ToolkitTestApplication application;
523 tet_infoline( "UtcDaliVisualGetPropertyMap5: ImageVisual" );
525 VisualFactory factory = VisualFactory::Get();
526 Property::Map propertyMap;
527 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
528 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
529 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
530 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
531 propertyMap.Insert( ImageVisual::Property::FITTING_MODE, FittingMode::FIT_HEIGHT );
532 propertyMap.Insert( ImageVisual::Property::SAMPLING_MODE, SamplingMode::BOX_THEN_NEAREST );
533 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, Vector4( 0.25f, 0.25f, 0.5f, 0.5f ) );
534 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT );
535 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::MIRRORED_REPEAT );
536 propertyMap.Insert( "synchronousLoading", true );
538 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
539 DALI_TEST_CHECK( imageVisual );
541 Property::Map resultMap;
542 imageVisual.CreatePropertyMap( resultMap );
544 // check the property values from the returned map from visual
545 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
546 DALI_TEST_CHECK( value );
547 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
549 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
550 DALI_TEST_CHECK( value );
551 DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
553 value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
554 DALI_TEST_CHECK( value );
555 DALI_TEST_CHECK( value->Get<int>() == FittingMode::FIT_HEIGHT );
557 value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
558 DALI_TEST_CHECK( value );
559 DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX_THEN_NEAREST );
561 value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
562 DALI_TEST_CHECK( value );
563 DALI_TEST_CHECK( value->Get<int>() == 20 );
565 value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
566 DALI_TEST_CHECK( value );
567 DALI_TEST_CHECK( value->Get<int>() == 30 );
569 value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
570 DALI_TEST_CHECK( value );
571 DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.25f, 0.25f, 0.5f, 0.5f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
573 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
574 DALI_TEST_CHECK( value );
575 DALI_TEST_CHECK( value->Get<int>() == WrapMode::REPEAT);
577 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
578 DALI_TEST_CHECK( value );
579 DALI_TEST_CHECK( value->Get<int>() == WrapMode::MIRRORED_REPEAT);
581 value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
582 DALI_TEST_CHECK( value );
583 DALI_TEST_CHECK( value->Get<bool>() == true );
585 // Get an image visual with an image handle, and test the default property values
586 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
587 imageVisual = factory.CreateVisual(image);
588 imageVisual.CreatePropertyMap( resultMap );
590 value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
591 DALI_TEST_CHECK( value );
592 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
594 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
595 DALI_TEST_CHECK( value );
596 DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
598 value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
599 DALI_TEST_CHECK( value );
600 DALI_TEST_CHECK( value->Get<int>() == FittingMode::SHRINK_TO_FIT );
602 value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
603 DALI_TEST_CHECK( value );
604 DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX );
606 value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
607 DALI_TEST_CHECK( value );
608 DALI_TEST_CHECK( value->Get<int>() == 100 );
610 value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
611 DALI_TEST_CHECK( value );
612 DALI_TEST_CHECK( value->Get<int>() == 200 );
614 value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
615 DALI_TEST_CHECK( value );
616 DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.f, 0.f, 1.f, 1.f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
618 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
619 DALI_TEST_CHECK( value );
620 DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
622 value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
623 DALI_TEST_CHECK( value );
624 DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
626 value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
627 DALI_TEST_CHECK( value );
628 DALI_TEST_CHECK( value->Get<bool>() == false );
630 // Test the properties. TODO: to be completed.
631 imageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
632 Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL );
637 int UtcDaliVisualGetPropertyMap6(void)
639 ToolkitTestApplication application;
640 tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" );
642 VisualFactory factory = VisualFactory::Get();
643 Property::Map propertyMap;
644 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
645 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
646 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
647 Visual::Base nPatchVisual = factory.CreateVisual( propertyMap );
649 Property::Map resultMap;
650 nPatchVisual.CreatePropertyMap( resultMap );
652 // check the property values from the returned map from visual
653 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
654 DALI_TEST_CHECK( value );
655 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
657 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
658 DALI_TEST_CHECK( value );
659 DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
661 value = resultMap.Find( ImageVisual::Property::BORDER_ONLY, Property::BOOLEAN );
662 DALI_TEST_CHECK( value );
663 DALI_TEST_CHECK( value->Get<bool>() );
665 // Test the properties. TODO: to be completed.
666 nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
667 Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL );
672 int UtcDaliVisualGetPropertyMap7(void)
674 ToolkitTestApplication application;
675 tet_infoline( "UtcDaliVisualGetPropertyMap7: SvgVisual" );
677 // request SvgVisual with a property map
678 VisualFactory factory = VisualFactory::Get();
679 Property::Map propertyMap;
680 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
681 propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
682 Visual::Base svgVisual = factory.CreateVisual( propertyMap );
684 Property::Map resultMap;
685 svgVisual.CreatePropertyMap( resultMap );
686 // check the property values from the returned map from a visual
687 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
688 DALI_TEST_CHECK( value );
689 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
691 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
692 DALI_TEST_CHECK( value );
693 DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
695 // request SvgVisual with an URL
696 Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
698 svgVisual2.CreatePropertyMap( resultMap );
699 // check the property values from the returned map from a visual
700 value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
701 DALI_TEST_CHECK( value );
702 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
704 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
705 DALI_TEST_CHECK( value );
706 DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
708 // Test the properties. TODO: to be completed.
709 svgVisual.SetProperty( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
710 Property::Value svgValue = svgVisual.GetProperty( ImageVisual::Property::URL );
716 int UtcDaliVisualGetPropertyMap8(void)
718 ToolkitTestApplication application;
719 tet_infoline( "UtcDaliVisualGetPropertyMap8: MeshVisual" );
721 //Request MeshVisual using a property map.
722 VisualFactory factory = VisualFactory::Get();
723 Property::Map propertyMap;
724 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
725 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
726 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
727 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_LOCATION );
728 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
729 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
730 Visual::Base meshVisual = factory.CreateVisual( propertyMap );
732 Property::Map resultMap;
733 meshVisual.CreatePropertyMap( resultMap );
735 //Check values in the result map are identical to the initial map's values.
736 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
737 DALI_TEST_CHECK( value );
738 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::MESH, TEST_LOCATION );
740 value = resultMap.Find( MeshVisual::Property::OBJECT_URL, Property::STRING );
741 DALI_TEST_CHECK( value );
742 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
744 value = resultMap.Find( MeshVisual::Property::MATERIAL_URL, Property::STRING );
745 DALI_TEST_CHECK( value );
746 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_MTL_FILE_NAME, TEST_LOCATION );
748 value = resultMap.Find( MeshVisual::Property::TEXTURES_PATH, Property::STRING );
749 DALI_TEST_CHECK( value );
750 DALI_TEST_EQUALS( value->Get<std::string>(), TEST_RESOURCE_LOCATION, TEST_LOCATION );
752 value = resultMap.Find( MeshVisual::Property::SHADING_MODE, Property::INTEGER );
753 DALI_TEST_CHECK( value );
754 DALI_TEST_EQUALS( value->Get<int>(), (int)MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING, TEST_LOCATION );
756 value = resultMap.Find( MeshVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
757 DALI_TEST_CHECK( value );
758 DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
760 // Test the properties. TODO: to be completed.
761 meshVisual.SetProperty( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
762 Property::Value meshValue = meshVisual.GetProperty( MeshVisual::Property::OBJECT_URL );
767 //Primitive shape visual
768 int UtcDaliVisualGetPropertyMap9(void)
770 ToolkitTestApplication application;
771 tet_infoline( "UtcDaliVisualGetPropertyMap9: PrimitiveVisual" );
773 Vector4 color = Vector4( 1.0, 0.8, 0.6, 1.0);
774 Vector3 dimensions = Vector3( 1.0, 2.0, 3.0 );
776 //Request PrimitiveVisual using a property map.
777 VisualFactory factory = VisualFactory::Get();
778 Property::Map propertyMap;
779 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
780 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
781 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color );
782 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
783 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
784 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
785 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
786 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
787 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
788 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, dimensions );
789 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.3f );
790 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.6f );
791 propertyMap.Insert( PrimitiveVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
792 Visual::Base primitiveVisual = factory.CreateVisual( propertyMap );
794 Property::Map resultMap;
795 primitiveVisual.CreatePropertyMap( resultMap );
797 //Check values in the result map are identical to the initial map's values.
798 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
799 DALI_TEST_CHECK( value );
800 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::PRIMITIVE, TEST_LOCATION );
802 value = resultMap.Find( PrimitiveVisual::Property::SHAPE, Property::INTEGER );
803 DALI_TEST_CHECK( value );
804 DALI_TEST_EQUALS( value->Get<int>(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION );
806 value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 );
807 DALI_TEST_CHECK( value );
808 DALI_TEST_CHECK( value->Get<Vector4>() == color );
809 DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
811 value = resultMap.Find( PrimitiveVisual::Property::SLICES, Property::INTEGER );
812 DALI_TEST_CHECK( value );
813 DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
815 value = resultMap.Find( PrimitiveVisual::Property::STACKS, Property::INTEGER );
816 DALI_TEST_CHECK( value );
817 DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
819 value = resultMap.Find( PrimitiveVisual::Property::SCALE_TOP_RADIUS, Property::FLOAT );
820 DALI_TEST_CHECK( value );
821 DALI_TEST_EQUALS( value->Get<float>(), 30.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
823 value = resultMap.Find( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, Property::FLOAT );
824 DALI_TEST_CHECK( value );
825 DALI_TEST_EQUALS( value->Get<float>(), 40.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
827 value = resultMap.Find( PrimitiveVisual::Property::SCALE_HEIGHT, Property::FLOAT );
828 DALI_TEST_CHECK( value );
829 DALI_TEST_EQUALS( value->Get<float>(), 50.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
831 value = resultMap.Find( PrimitiveVisual::Property::SCALE_RADIUS, Property::FLOAT );
832 DALI_TEST_CHECK( value );
833 DALI_TEST_EQUALS( value->Get<float>(), 60.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
835 value = resultMap.Find( PrimitiveVisual::Property::SCALE_DIMENSIONS, Property::VECTOR3 );
836 DALI_TEST_CHECK( value );
837 DALI_TEST_EQUALS( value->Get<Vector3>(), dimensions, Math::MACHINE_EPSILON_100, TEST_LOCATION );
839 value = resultMap.Find( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::FLOAT );
840 DALI_TEST_CHECK( value );
841 DALI_TEST_EQUALS( value->Get<float>(), 0.3f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
843 value = resultMap.Find( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::FLOAT );
844 DALI_TEST_CHECK( value );
845 DALI_TEST_EQUALS( value->Get<float>(), 0.6f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
847 value = resultMap.Find( PrimitiveVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
848 DALI_TEST_CHECK( value );
849 DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
851 // Test the properties. TODO: to be completed.
852 primitiveVisual.SetProperty( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
853 Property::Value primitiveValue = primitiveVisual.GetProperty( PrimitiveVisual::Property::SHAPE );
858 int UtcDaliVisualGetPropertyMapBatchImageVisual(void)
860 ToolkitTestApplication application;
861 tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisual:" );
863 VisualFactory factory = VisualFactory::Get();
864 Property::Map propertyMap;
865 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
866 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
867 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
868 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
869 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
871 Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
872 DALI_TEST_CHECK( batchImageVisual );
874 Property::Map resultMap;
875 batchImageVisual.CreatePropertyMap( resultMap );
877 // Check the property values from the returned map from visual
878 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
879 DALI_TEST_CHECK( value );
880 DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
882 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
883 DALI_TEST_CHECK( value );
884 DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
886 value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
887 DALI_TEST_CHECK( value );
888 DALI_TEST_CHECK( value->Get<int>() == 20 );
890 value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
891 DALI_TEST_CHECK( value );
892 DALI_TEST_CHECK( value->Get<int>() == 30 );
894 // Test the properties. TODO: to be completed.
895 batchImageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
896 Property::Value primitiveValue = batchImageVisual.GetProperty( ImageVisual::Property::URL );
901 int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void)
903 ToolkitTestApplication application;
904 tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas:" );
906 VisualFactory factory = VisualFactory::Get();
907 Property::Map propertyMap;
908 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
909 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
910 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
912 // Set the desired size to be larger than the atlas limit of 1024x1024.
913 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 );
914 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 );
916 // Create the visual.
917 Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
919 DALI_TEST_CHECK( batchImageVisual );
921 Actor actor = Actor::New();
922 batchImageVisual.SetOnStage( actor );
924 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
929 int UtcDaliVisualAnimateBorderVisual01(void)
931 ToolkitTestApplication application;
932 tet_infoline( "UtcDaliAnimateBorderVisual Color" );
934 VisualFactory factory = VisualFactory::Get();
935 Property::Map propertyMap;
936 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
937 propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
938 propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
939 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
941 Actor actor = Actor::New();
942 actor.SetSize(2000, 2000);
943 actor.SetParentOrigin(ParentOrigin::CENTER);
944 Stage::GetCurrent().Add(actor);
945 borderVisual.SetOnStage( actor );
947 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
949 Renderer renderer = actor.GetRendererAt(0);
950 Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::COLOR );
952 Animation animation = Animation::New(4.0f);
953 animation.AnimateTo( Property(renderer, index), Color::WHITE );
956 application.SendNotification();
957 application.Render(0);
958 application.Render(2000u); // halfway point between blue and white
960 Vector4 color = renderer.GetProperty<Vector4>( index );
961 Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f;
962 DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
963 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", testColor ), true, TEST_LOCATION );
965 application.Render(2000u); // halfway point between blue and white
967 color = renderer.GetProperty<Vector4>( index );
968 DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION );
969 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", Color::WHITE ), true, TEST_LOCATION );
975 int UtcDaliVisualAnimateBorderVisual02(void)
977 ToolkitTestApplication application;
978 tet_infoline( "UtcDaliAnimateBorderVisual Size" );
980 VisualFactory factory = VisualFactory::Get();
981 Property::Map propertyMap;
982 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
983 propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
984 propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
985 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
987 Actor actor = Actor::New();
988 actor.SetSize(2000, 2000);
989 actor.SetParentOrigin(ParentOrigin::CENTER);
990 Stage::GetCurrent().Add(actor);
991 borderVisual.SetOnStage( actor );
993 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
995 Renderer renderer = actor.GetRendererAt(0);
996 Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE );
998 Animation animation = Animation::New(4.0f);
999 animation.AnimateTo( Property(renderer, index), 9.0f );
1002 application.SendNotification();
1003 application.Render(0);
1004 application.Render(2000u); // halfway point
1006 float size = renderer.GetProperty<float>( index );
1007 DALI_TEST_EQUALS( size, 7.0f, 0.0001f, TEST_LOCATION );
1008 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 7.0f ), true, TEST_LOCATION );
1010 application.Render(2000u); // halfway point between blue and white
1012 size = renderer.GetProperty<float>( index );
1013 DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION );
1014 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 9.0f ), true, TEST_LOCATION );
1019 int UtcDaliVisualAnimateColorVisual(void)
1021 ToolkitTestApplication application;
1022 tet_infoline( "UtcDaliAnimateColorVisual mixColor" );
1024 VisualFactory factory = VisualFactory::Get();
1025 Property::Map propertyMap;
1026 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1027 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1028 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1030 Actor actor = Actor::New();
1031 actor.SetSize(2000, 2000);
1032 actor.SetParentOrigin(ParentOrigin::CENTER);
1033 Stage::GetCurrent().Add(actor);
1034 borderVisual.SetOnStage( actor );
1036 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1038 Renderer renderer = actor.GetRendererAt(0);
1039 Property::Index index = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
1041 Animation animation = Animation::New(4.0f);
1042 animation.AnimateTo( Property(renderer, index), Color::WHITE );
1045 application.SendNotification();
1046 application.Render(0);
1047 application.Render(2000u); // halfway point
1049 Vector4 color = renderer.GetProperty<Vector4>( index );
1050 Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f;
1051 DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1053 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("mixColor", testColor ), true, TEST_LOCATION );
1055 application.Render(2000u); // halfway point between blue and white
1057 color = renderer.GetProperty<Vector4>( index );
1058 DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION );
1060 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("mixColor", Color::WHITE ), true, TEST_LOCATION );
1067 int UtcDaliVisualAnimatePrimitiveVisual(void)
1069 ToolkitTestApplication application;
1070 tet_infoline( "UtcDaliAnimatePrimitiveVisual color" );
1072 VisualFactory factory = VisualFactory::Get();
1073 Property::Map propertyMap;
1074 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1075 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1076 Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1078 Actor actor = Actor::New();
1079 actor.SetSize(2000, 2000);
1080 actor.SetParentOrigin(ParentOrigin::CENTER);
1081 actor.SetColor(Color::BLACK);
1082 Stage::GetCurrent().Add(actor);
1083 borderVisual.SetOnStage( actor );
1085 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1087 Renderer renderer = actor.GetRendererAt(0);
1088 Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR );
1090 // The property isn't registered on the renderer, it's instead registered on the shader.
1091 DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
1093 Animation animation = Animation::New(4.0f);
1094 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
1097 application.SendNotification();
1098 application.Render(0);
1099 application.Render(2000u); // halfway point
1101 // Actor color overrides renderer color.
1102 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION );
1104 application.Render(2000u); // halfway point between blue and white
1106 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1107 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Color::WHITE ), true, TEST_LOCATION );
1113 int UtcDaliVisualWireframeVisual(void)
1115 ToolkitTestApplication application;
1117 VisualFactory factory = VisualFactory::Get();
1118 Property::Map propertyMap;
1119 propertyMap.Insert( Visual::Property::TYPE, Visual::WIREFRAME );
1121 // Create the visual.
1122 Visual::Base visual = factory.CreateVisual( propertyMap );
1124 DALI_TEST_CHECK( visual );
1126 Property::Map resultMap;
1127 visual.CreatePropertyMap( resultMap );
1129 // Check the property values from the returned map from visual
1130 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
1131 DALI_TEST_CHECK( value );
1132 DALI_TEST_CHECK( value->Get<int>() == Visual::WIREFRAME );
1134 // Test the properties. TODO: to be completed.
1135 Property::Value primitiveValue = visual.GetProperty( Visual::Property::TYPE );