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.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
35 using namespace Toolkit;
37 void dali_textlabel_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textlabel_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
65 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE = "underline";
67 const char* const PROPERTY_NAME_SHADOW = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
72 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
73 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
74 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
77 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
79 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
81 const Property::Map::SizeType size = mapGet.Count();
83 if( size == mapSet.Count() )
85 for( unsigned int index = 0u; index < size; ++index )
87 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
89 // Find the keys of the 'get' map
90 Property::Index indexKey = valueGet.first.indexKey;
91 std::string stringKey = valueGet.first.stringKey;
93 if( !indexConversionTable.empty() )
95 if( stringKey.empty() )
97 stringKey = indexConversionTable[ indexKey ];
100 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
102 Property::Index index = 0u;
103 for( auto key : indexConversionTable )
105 if( key == stringKey )
115 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
117 if( nullptr != valueSet )
119 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
121 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
124 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
126 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
129 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
131 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
134 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
136 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
139 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
141 Vector2 vector2Get = valueGet.second.Get<Vector2>();
142 Vector2 vector2Set = valueSet->Get<Vector2>();
143 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
146 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
148 Vector4 vector4Get = valueGet.second.Get<Vector4>();
149 Vector4 vector4Set = valueSet->Get<Vector4>();
150 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 );
156 if ( valueGet.first.type == Property::Key::INDEX )
158 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
162 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
174 int UtcDaliToolkitTextLabelConstructorP(void)
176 ToolkitTestApplication application;
177 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
179 DALI_TEST_CHECK( !textLabel );
183 int UtcDaliToolkitTextLabelNewP(void)
185 ToolkitTestApplication application;
186 tet_infoline(" UtcDaliToolkitTextLabelNewP");
187 TextLabel textLabel = TextLabel::New( "Test Text" );
188 DALI_TEST_CHECK( textLabel );
192 int UtcDaliToolkitTextLabelDownCastP(void)
194 ToolkitTestApplication application;
195 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
196 TextLabel textLabel1 = TextLabel::New();
197 BaseHandle object( textLabel1 );
199 TextLabel textLabel2 = TextLabel::DownCast( object );
200 DALI_TEST_CHECK( textLabel2 );
202 TextLabel textLabel3 = DownCast< TextLabel >( object );
203 DALI_TEST_CHECK( textLabel3 );
207 int UtcDaliToolkitTextLabelDownCastN(void)
209 ToolkitTestApplication application;
210 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
211 BaseHandle uninitializedObject;
212 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
213 DALI_TEST_CHECK( !textLabel1 );
215 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
216 DALI_TEST_CHECK( !textLabel2 );
220 int UtcDaliToolkitTextLabelCopyConstructorP(void)
222 ToolkitTestApplication application;
223 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
224 TextLabel textLabel = TextLabel::New();
225 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
227 TextLabel copy( textLabel );
228 DALI_TEST_CHECK( copy );
229 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
233 int UtcDaliTextLabelMoveConstructor(void)
235 ToolkitTestApplication application;
237 TextLabel textLabel = TextLabel::New();
238 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
239 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
241 TextLabel moved = std::move( textLabel );
242 DALI_TEST_CHECK( moved );
243 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
244 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
245 DALI_TEST_CHECK( !textLabel );
250 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
252 ToolkitTestApplication application;
253 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
254 TextLabel textLabel = TextLabel::New();
255 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
257 TextLabel copy = textLabel;
258 DALI_TEST_CHECK( copy );
259 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
263 int UtcDaliTextLabelMoveAssignment(void)
265 ToolkitTestApplication application;
267 TextLabel textLabel = TextLabel::New();
268 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
269 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
272 moved = std::move( textLabel );
273 DALI_TEST_CHECK( moved );
274 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
275 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
276 DALI_TEST_CHECK( !textLabel );
281 // Positive test case for a method
282 int UtcDaliToolkitTextLabelGetPropertyP(void)
284 ToolkitTestApplication application;
285 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
286 TextLabel label = TextLabel::New("Test Text");
287 DALI_TEST_CHECK( label );
289 // Check Property Indices are correct
290 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
291 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
292 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
293 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
294 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
295 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
296 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
297 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
298 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
299 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
300 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
301 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
302 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
303 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
304 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
305 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
306 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
307 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
308 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
309 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
310 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
311 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
312 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
317 int UtcDaliToolkitTextLabelSetPropertyP(void)
319 ToolkitTestApplication application;
320 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
321 TextLabel label = TextLabel::New();
322 DALI_TEST_CHECK( label );
324 application.GetScene().Add( label );
326 // Note - we can't check the defaults since the stylesheets are platform-specific
327 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
328 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
330 // Check that text can be correctly reset
331 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
332 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
334 // Check font properties.
335 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
336 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
338 Property::Map fontStyleMapSet;
339 Property::Map fontStyleMapGet;
341 fontStyleMapSet.Insert( "weight", "bold" );
342 fontStyleMapSet.Insert( "width", "condensed" );
343 fontStyleMapSet.Insert( "slant", "italic" );
344 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
346 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
347 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
348 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
350 // Check the old font style format.
351 fontStyleMapSet.Clear();
352 fontStyleMapSet.Insert( "weight", "thin" );
353 fontStyleMapSet.Insert( "width", "expanded" );
354 fontStyleMapSet.Insert( "slant", "oblique" );
355 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
357 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
358 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
359 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
361 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
362 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
365 fontStyleMapSet.Clear();
366 fontStyleMapSet.Insert( "weight", "normal" );
367 fontStyleMapSet.Insert( "slant", "oblique" );
369 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
370 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
371 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
372 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
374 fontStyleMapSet.Clear();
375 fontStyleMapSet.Insert( "slant", "roman" );
377 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
378 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
379 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
381 // Replace 'roman' for 'normal'.
382 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
383 if( NULL != slantValue )
385 if( "normal" == slantValue->Get<std::string>() )
387 fontStyleMapGet["slant"] = "roman";
390 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
392 fontStyleMapSet.Clear();
394 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
395 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
396 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
397 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
400 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
401 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
403 // Check that the Alignment properties can be correctly set
404 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
405 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
406 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
407 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
409 // Check that text color can be properly set
410 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
411 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
413 Property::Map underlineMapSet;
414 Property::Map underlineMapGet;
416 underlineMapSet.Insert( "enable", false );
417 underlineMapSet.Insert( "color", Color::BLUE );
418 underlineMapSet.Insert( "height", 0 );
420 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
421 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
422 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
424 TextLabel label2 = TextLabel::New( "New text" );
425 DALI_TEST_CHECK( label2 );
426 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
428 // Check the enable markup property.
429 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
430 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
431 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
433 // Check the text property when markup is enabled
434 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
435 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
437 // Check for incomplete marks.
438 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
439 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
442 application.SendNotification();
443 application.Render();
447 tet_result(TET_FAIL);
450 // Check autoscroll properties
451 const int SCROLL_SPEED = 80;
452 const int SCROLL_LOOPS = 4;
453 const float SCROLL_GAP = 50.0f;
454 const float SCROLL_LOOP_DELAY = 0.3f;
455 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
456 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
458 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
459 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
460 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
461 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
462 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
463 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
464 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
465 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
466 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
467 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
468 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
469 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
471 //Check autoscroll stop type property
472 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
473 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
475 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
476 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
478 // test natural size with multi-line and line spacing
480 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
481 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
482 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
483 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
484 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
486 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
487 // The height of the text when multi-line is enabled will be larger
488 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
489 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
491 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
492 // Everything else will remain the same
493 int lineSpacing = 20;
494 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
495 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
496 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
497 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
500 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
502 TextLabel label3 = TextLabel::New("Some text here end there end here");
503 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
504 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
505 Vector3 textNaturalSize = label3.GetNaturalSize();
506 int lineSpacing = 20;
507 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
508 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
509 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
510 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
512 // Check the line spacing property
513 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
514 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
515 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
517 // Check the underline property
518 underlineMapSet.Clear();
519 underlineMapSet.Insert( "enable", true );
520 underlineMapSet.Insert( "color", Color::RED );
521 underlineMapSet.Insert( "height", 1 );
523 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
525 application.SendNotification();
526 application.Render();
528 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
529 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
530 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
532 underlineMapSet.Clear();
533 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
534 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
535 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
537 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
539 application.SendNotification();
540 application.Render();
542 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
543 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
544 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
545 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
547 underlineMapSet.Clear();
549 Property::Map underlineDisabledMapGet;
550 underlineDisabledMapGet.Insert( "enable", false );
551 underlineDisabledMapGet.Insert( "color", Color::GREEN );
552 underlineDisabledMapGet.Insert( "height", 2 );
554 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
556 application.SendNotification();
557 application.Render();
559 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
560 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
561 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
563 // Check the shadow property
565 Property::Map shadowMapSet;
566 Property::Map shadowMapGet;
568 shadowMapSet.Insert( "color", Color::GREEN );
569 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
570 shadowMapSet.Insert( "blurRadius", 5.0f );
572 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
574 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
575 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
576 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
578 shadowMapSet.Clear();
580 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
581 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
582 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
584 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
586 // Replace the offset (string) by a vector2
587 shadowMapSet.Clear();
588 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
589 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
590 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
592 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
593 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
594 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
595 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
597 shadowMapSet.Clear();
598 Property::Map shadowDisabledMapGet;
599 shadowDisabledMapGet.Insert( "color", Color::BLUE );
600 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
601 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
603 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
605 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
606 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
609 // Check the emboss property
610 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
611 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
613 // Check the outline property
615 // Test string type first
616 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
617 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
618 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
620 // Then test the property map type
621 Property::Map outlineMapSet;
622 Property::Map outlineMapGet;
624 outlineMapSet["color"] = Color::RED;
625 outlineMapSet["width"] = 2.0f;
626 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
628 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
629 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
630 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
632 outlineMapSet.Clear();
633 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
634 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
635 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
637 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
638 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
639 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
640 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
642 // Check the background property
643 Property::Map backgroundMapSet;
644 Property::Map backgroundMapGet;
646 backgroundMapSet["enable"] = true;
647 backgroundMapSet["color"] = Color::RED;
648 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
650 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
651 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
652 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
654 backgroundMapSet.Clear();
655 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
656 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
657 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
659 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
660 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
661 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
662 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
664 // Check the pixel size of font
665 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
666 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 // Check the ellipsis property
669 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
670 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
671 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
673 // Check the layout direction property
674 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
675 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
677 // Check the line size property
678 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
679 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
680 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 application.SendNotification();
683 application.Render();
688 int UtcDaliToolkitTextlabelAtlasRenderP(void)
690 ToolkitTestApplication application;
691 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
692 TextLabel label = TextLabel::New("Test Text");
693 DALI_TEST_CHECK( label );
695 // Avoid a crash when core load gl resources.
696 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
698 application.GetScene().Add( label );
700 // Turn on all the effects
701 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
702 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
704 Property::Map underlineMap;
705 underlineMap.Insert( "enable", true );
706 underlineMap.Insert( "color", Color::RED );
707 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
709 Property::Map shadowMap;
710 shadowMap.Insert( "color", Color::BLUE );
711 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
712 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
716 // Render some text with the shared atlas backend
717 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
718 application.SendNotification();
719 application.Render();
723 tet_result(TET_FAIL);
728 // Render some text with the shared atlas backend
729 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
730 application.SendNotification();
731 application.Render();
735 tet_result(TET_FAIL);
740 int UtcDaliToolkitTextLabelLanguagesP(void)
742 ToolkitTestApplication application;
743 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
744 TextLabel label = TextLabel::New();
745 DALI_TEST_CHECK( label );
747 application.GetScene().Add( label );
749 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
750 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
751 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
752 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
753 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
754 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
756 label.SetProperty( TextLabel::Property::TEXT, scripts );
757 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
759 application.SendNotification();
760 application.Render();
765 int UtcDaliToolkitTextLabelEmojisP(void)
767 ToolkitTestApplication application;
768 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
769 TextLabel label = TextLabel::New();
770 DALI_TEST_CHECK( label );
772 application.GetScene().Add( label );
774 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
776 char* pathNamePtr = get_current_dir_name();
777 const std::string pathName( pathNamePtr );
780 TextAbstraction::FontDescription fontDescription;
781 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
782 fontDescription.family = "BreezeColorEmoji";
783 fontDescription.width = TextAbstraction::FontWidth::NONE;
784 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
785 fontDescription.slant = TextAbstraction::FontSlant::NONE;
787 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
789 const std::string emojis = "<font family='BreezeColorEmoji' size='60'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
790 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
791 label.SetProperty( TextLabel::Property::TEXT, emojis );
793 Property::Map shadowMap;
794 shadowMap.Insert( "color", "green" );
795 shadowMap.Insert( "offset", "2 2" );
796 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
798 application.SendNotification();
799 application.Render();
804 int UtcDaliToolkitTextlabelScrollingP(void)
806 ToolkitTestApplication application;
807 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
808 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
809 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
811 DALI_TEST_CHECK( labelImmediate );
812 DALI_TEST_CHECK( labelFinished );
813 // Avoid a crash when core load gl resources.
814 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
815 application.GetScene().Add( labelImmediate );
816 // Turn on all the effects
817 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
818 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
819 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
820 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
821 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
823 application.GetScene().Add( labelFinished );
824 // Turn on all the effects
825 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
826 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
827 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
828 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
829 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
835 // Render some text with the shared atlas backend
836 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
837 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
839 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
840 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
842 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
843 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
844 application.SendNotification();
845 application.Render();
847 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
848 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
849 application.SendNotification();
850 application.Render();
855 tet_result(TET_FAIL);
861 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
863 ToolkitTestApplication application;
864 TextLabel labelShort = TextLabel::New("Some text to scroll");
865 TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
867 DALI_TEST_CHECK( labelShort );
868 DALI_TEST_CHECK( labelLong );
869 // Avoid a crash when core load gl resources.
870 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
871 application.GetScene().Add( labelShort );
872 // Turn on all the effects
873 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
874 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
875 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
876 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
877 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
878 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
880 application.GetScene().Add( labelLong );
881 // Turn on all the effects
882 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
883 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
884 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
885 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
886 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
887 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
891 // Render some text with the shared atlas backend
892 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
893 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
894 application.SendNotification();
895 application.Render();
897 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
898 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
899 application.SendNotification();
900 application.Render();
905 tet_result(TET_FAIL);
911 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
913 ToolkitTestApplication application;
914 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
915 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
917 DALI_TEST_CHECK( labelShort );
918 DALI_TEST_CHECK( labelLong );
919 // Avoid a crash when core load gl resources.
920 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
921 application.GetScene().Add( labelShort );
922 // Turn on all the effects
923 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
924 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
925 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
926 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
927 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
928 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
930 application.GetScene().Add( labelLong );
931 // Turn on all the effects
932 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
933 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
934 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
935 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
936 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
937 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
941 // Render some text with the shared atlas backend
942 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
943 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
944 application.SendNotification();
945 application.Render();
947 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
948 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
949 application.SendNotification();
950 application.Render();
955 tet_result(TET_FAIL);
961 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
963 ToolkitTestApplication application;
964 TextLabel labelShort = TextLabel::New("Some text to scroll");
965 TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
967 DALI_TEST_CHECK( labelShort );
968 DALI_TEST_CHECK( labelLong );
969 // Avoid a crash when core load gl resources.
970 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
971 application.GetScene().Add( labelShort );
972 // Turn on all the effects
973 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
974 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
975 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
976 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
977 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
978 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
980 application.GetScene().Add( labelLong );
981 // Turn on all the effects
982 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
983 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
984 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
985 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
986 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
987 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
991 // Render some text with the shared atlas backend
992 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
993 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
994 application.SendNotification();
995 application.Render();
997 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
998 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
999 application.SendNotification();
1000 application.Render();
1005 tet_result(TET_FAIL);
1011 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1013 ToolkitTestApplication application;
1014 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1015 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1017 DALI_TEST_CHECK( labelShort );
1018 DALI_TEST_CHECK( labelLong );
1019 // Avoid a crash when core load gl resources.
1020 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1021 application.GetScene().Add( labelShort );
1022 // Turn on all the effects
1023 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1024 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1025 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1026 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1027 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1028 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1030 application.GetScene().Add( labelLong );
1031 // Turn on all the effects
1032 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1033 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1034 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1035 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1036 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1037 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1041 // Render some text with the shared atlas backend
1042 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1043 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1044 application.SendNotification();
1045 application.Render();
1047 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1048 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1049 application.SendNotification();
1050 application.Render();
1055 tet_result(TET_FAIL);
1061 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1063 ToolkitTestApplication application;
1064 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1065 TextLabel label = TextLabel::New("Some text to scroll");
1066 DALI_TEST_CHECK( label );
1067 // Avoid a crash when core load gl resources.
1068 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1069 application.GetScene().Add( label );
1070 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1071 // Turn on all the effects
1072 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1073 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1074 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1075 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1078 application.SendNotification();
1079 application.Render();
1081 unsigned int actorCount1 = label.GetChildCount();
1082 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1086 // Render some text with the shared atlas backend
1087 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1088 application.SendNotification();
1089 application.Render(2000);
1091 unsigned int actorCount1 = label.GetChildCount();
1092 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1094 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1097 application.SendNotification();
1098 application.Render();
1100 unsigned int actorCount2 = label.GetChildCount();
1101 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1103 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1108 tet_result(TET_FAIL);
1114 int UtcDaliToolkitTextlabelScrollingN(void)
1116 ToolkitTestApplication application;
1117 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1119 TextLabel label = TextLabel::New("Some text to scroll");
1120 DALI_TEST_CHECK( label );
1122 application.GetScene().Add( label );
1124 // Avoid a crash when core load gl resources.
1125 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1127 // The text scrolling works only on single line text.
1128 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1130 // Turn on all the effects.
1131 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1132 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1133 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1135 // Enable the auto scrolling effect.
1136 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1138 // The auto scrolling shouldn't be enabled.
1139 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1140 DALI_TEST_CHECK( !enabled );
1145 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1147 ToolkitTestApplication application;
1148 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1150 TextLabel label = TextLabel::New("Some text to scroll");
1151 DALI_TEST_CHECK( label );
1153 application.GetScene().Add( label );
1155 // Avoid a crash when core load gl resources.
1156 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1158 // Turn on all the effects.
1159 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1160 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1161 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1165 // Enable the auto scrolling effect.
1166 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1167 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1169 // Disable the ellipsis
1170 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1173 application.SendNotification();
1174 application.Render();
1176 // Stop auto scrolling
1177 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1179 // Check the ellipsis property
1180 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1184 tet_result(TET_FAIL);
1190 int UtcDaliToolkitTextlabelEllipsis(void)
1192 ToolkitTestApplication application;
1193 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1195 TextLabel label = TextLabel::New("Hello world");
1196 DALI_TEST_CHECK( label );
1198 // Avoid a crash when core load gl resources.
1199 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1201 application.GetScene().Add( label );
1203 // Turn on all the effects
1204 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1205 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1206 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1211 application.SendNotification();
1212 application.Render();
1216 tet_result(TET_FAIL);
1219 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1220 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1221 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1226 application.SendNotification();
1227 application.Render();
1231 tet_result(TET_FAIL);
1235 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1236 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1237 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1242 application.SendNotification();
1243 application.Render();
1247 tet_result(TET_FAIL);
1253 int UtcDaliToolkitTextlabelTextWrapMode(void)
1255 ToolkitTestApplication application;
1256 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1260 TextLabel label = TextLabel::New();
1261 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1262 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1263 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1267 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1268 application.GetScene().Add( label );
1270 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1271 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1273 application.SendNotification();
1274 application.Render();
1276 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1277 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1279 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1280 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1282 application.SendNotification();
1283 application.Render();
1285 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1286 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1288 application.SendNotification();
1289 application.Render();
1291 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1292 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1294 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1295 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1297 application.SendNotification();
1298 application.Render();
1300 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1301 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1303 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1304 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1305 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1310 int UtcDaliToolkitTextLabelColorComponents(void)
1312 ToolkitTestApplication application;
1314 TextLabel label = TextLabel::New();
1315 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1316 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1317 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1318 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1319 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1321 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1322 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1323 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1324 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1325 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1327 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1328 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1329 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1330 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1331 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1333 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1334 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1335 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1337 // Test a transparent text - Rendering should be skipped.
1338 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1339 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1341 application.GetScene().Add( label );
1343 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1344 drawTrace.Enable( true );
1346 application.SendNotification();
1347 application.Render();
1349 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1351 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1355 application.SendNotification();
1356 application.Render();
1358 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1360 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1372 int UtcDaliToolkitTextlabelTextStyle01(void)
1374 ToolkitTestApplication application;
1375 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1377 TextLabel label = TextLabel::New();
1378 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1379 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1380 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1381 application.GetScene().Add( label );
1383 Property::Map outlineMapSet;
1384 Property::Map outlineMapGet;
1386 outlineMapSet["color"] = Color::BLUE;
1387 outlineMapSet["width"] = 2.0f;
1388 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1390 application.SendNotification();
1391 application.Render();
1393 Property::Map shadowMapSet;
1394 shadowMapSet.Insert( "color", "green" );
1395 shadowMapSet.Insert( "offset", "2 2" );
1396 shadowMapSet.Insert( "blurRadius", "3" );
1397 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1399 outlineMapSet["color"] = Color::RED;
1400 outlineMapSet["width"] = 0.0f;
1401 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1403 application.SendNotification();
1404 application.Render();
1406 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1408 Property::Value* colorValue = outlineMapGet.Find("color");
1410 bool colorMatched( false );
1414 Property::Type valueType = colorValue->GetType();
1416 if ( Property::STRING == valueType )
1418 std::string stringValue;
1419 colorValue->Get( stringValue );
1420 if ( stringValue == "red" )
1422 colorMatched = true;
1425 else if ( Property::VECTOR4 == valueType )
1427 Vector4 colorVector4;
1428 colorValue->Get( colorVector4 );
1429 if ( colorVector4 == Color::RED )
1431 colorMatched = true;
1436 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1441 int UtcDaliToolkitTextlabelMultiline(void)
1443 ToolkitTestApplication application;
1444 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1446 TextLabel label = TextLabel::New();
1447 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1448 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1449 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1450 application.GetScene().Add( label );
1452 application.SendNotification();
1453 application.Render();
1455 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1456 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1458 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1460 application.SendNotification();
1461 application.Render();
1463 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1464 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1470 int UtcDaliToolkitTextlabelTextDirection(void)
1472 ToolkitTestApplication application;
1473 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1475 TextLabel label = TextLabel::New();
1476 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1478 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1479 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1480 application.GetScene().Add( label );
1483 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1486 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1487 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1489 // Test RTL text starting with weak character
1490 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1491 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1493 // Test RTL text string with emoji and weak character
1494 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1495 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1500 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1502 ToolkitTestApplication application;
1503 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1505 TextLabel label = TextLabel::New();
1507 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1508 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1509 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1510 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1511 application.GetScene().Add( label );
1512 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1514 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1515 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1517 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1518 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1523 int UtcDaliToolkitTextLabelBitmapFont(void)
1525 ToolkitTestApplication application;
1526 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1528 DevelText::BitmapFontDescription fontDescription;
1529 fontDescription.name = "Digits";
1530 fontDescription.underlinePosition = 0.f;
1531 fontDescription.underlineThickness = 0.f;
1533 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1534 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1535 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1536 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1537 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1538 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1539 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1540 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1541 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1542 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1543 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1545 TextAbstraction::BitmapFont bitmapFont;
1546 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1548 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1549 fontClient.GetFontId( bitmapFont );
1551 TextLabel label = TextLabel::New();
1553 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1554 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1556 // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1557 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1559 application.GetScene().Add( label );
1561 application.SendNotification();
1562 application.Render();
1564 // The text has been rendered if the height of the text-label is the height of the line.
1565 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1570 int ConvertPointToPixel( float point )
1572 unsigned int horizontalDpi = 0u;
1573 unsigned int verticalDpi = 0u;
1574 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1575 fontClient.GetDpi( horizontalDpi, verticalDpi );
1577 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1580 int UtcDaliToolkitTextlabelTextFit(void)
1582 ToolkitTestApplication application;
1583 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1584 TextLabel label = TextLabel::New();
1585 Vector2 size( 460.0f, 100.0f );
1586 label.SetProperty( Actor::Property::SIZE, size );
1587 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1590 Property::Map textFitMapSet;
1591 textFitMapSet["enable"] = true;
1592 textFitMapSet["minSize"] = 10.f;
1593 textFitMapSet["maxSize"] = 100.f;
1594 textFitMapSet["stepSize"] = -1.f;
1595 textFitMapSet["fontSizeType"] = "pointSize";
1597 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1598 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1600 application.GetScene().Add( label );
1602 application.SendNotification();
1603 application.Render();
1605 const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1606 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1609 textFitMapSet.Clear();
1610 textFitMapSet["enable"] = true;
1611 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1612 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1613 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1614 textFitMapSet["fontSizeType"] = "pixelSize";
1616 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1618 application.SendNotification();
1619 application.Render();
1621 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1626 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1628 ToolkitTestApplication application;
1629 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1631 DevelText::BitmapFontDescription fontDescription;
1632 fontDescription.name = "Digits";
1633 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1635 TextAbstraction::BitmapFont bitmapFont;
1636 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1638 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1639 fontClient.GetFontId( bitmapFont );
1641 TextLabel label = TextLabel::New();
1642 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1643 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1644 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1645 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1646 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1648 Property::Map underlineMapSet;
1649 underlineMapSet.Clear();
1650 underlineMapSet.Insert( "enable", true );
1651 underlineMapSet.Insert( "color", Color::RED );
1652 underlineMapSet.Insert( "height", 1 );
1653 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1654 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1656 application.GetScene().Add( label );
1658 application.SendNotification();
1659 application.Render();
1661 const int maxTextureSize = Dali::GetMaxTextureSize();
1662 // Whether the rendered text is greater than maxTextureSize
1663 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1665 // Check if the number of renderers is greater than 1.
1666 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1671 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1673 ToolkitTestApplication application;
1674 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1676 Vector2 size( 300.0f, 100.0f );
1678 Dali::Toolkit::DevelText::RendererParameters textParameters;
1679 textParameters.text = "This is a sample text to get the last index.";
1680 textParameters.layout = "multiLine";
1681 textParameters.fontSize = 20.f;
1682 textParameters.textWidth = 300u;
1683 textParameters.textHeight = 100u;
1684 textParameters.ellipsisEnabled = true;
1685 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1687 DALI_TEST_CHECK( !indexArray.Empty() );
1688 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );