2 * Copyright (c) 2021 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>
33 #include "test-text-geometry-utils.h"
36 using namespace Toolkit;
38 void dali_textlabel_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textlabel_cleanup(void)
45 test_return_value = TET_PASS;
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
64 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
66 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
67 const char* const PROPERTY_NAME_UNDERLINE = "underline";
68 const char* const PROPERTY_NAME_SHADOW = "shadow";
69 const char* const PROPERTY_NAME_EMBOSS = "emboss";
70 const char* const PROPERTY_NAME_OUTLINE = "outline";
71 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
73 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
74 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
75 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
78 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
80 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
81 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
83 static bool gAnchorClickedCallBackCalled;
84 static bool gAnchorClickedCallBackNotCalled;
86 static bool gTextFitChangedCallBackCalled;
88 struct CallbackFunctor
90 CallbackFunctor(bool* callbackFlag)
91 : mCallbackFlag( callbackFlag )
97 *mCallbackFlag = true;
102 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
104 tet_infoline(" TestAnchorClickedCallback");
106 gAnchorClickedCallBackNotCalled = false;
108 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
110 gAnchorClickedCallBackCalled = true;
114 static void TestTextFitChangedCallback(TextLabel control)
116 tet_infoline(" TestTextFitChangedCallback");
117 gTextFitChangedCallBackCalled = true;
120 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
122 const Property::Map::SizeType size = mapGet.Count();
124 if( size == mapSet.Count() )
126 for( unsigned int index = 0u; index < size; ++index )
128 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
130 // Find the keys of the 'get' map
131 Property::Index indexKey = valueGet.first.indexKey;
132 std::string stringKey = valueGet.first.stringKey;
134 if( !indexConversionTable.empty() )
136 if( stringKey.empty() )
138 stringKey = indexConversionTable[ indexKey ];
141 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
143 Property::Index index = 0u;
144 for( auto key : indexConversionTable )
146 if( key == stringKey )
156 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
158 if( nullptr != valueSet )
160 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
162 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
165 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
167 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
170 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
172 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
175 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
177 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
180 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
182 Vector2 vector2Get = valueGet.second.Get<Vector2>();
183 Vector2 vector2Set = valueSet->Get<Vector2>();
184 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
187 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
189 Vector4 vector4Get = valueGet.second.Get<Vector4>();
190 Vector4 vector4Set = valueSet->Get<Vector4>();
191 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 );
197 if ( valueGet.first.type == Property::Key::INDEX )
199 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
203 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
215 int UtcDaliToolkitTextLabelConstructorP(void)
217 ToolkitTestApplication application;
218 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
220 DALI_TEST_CHECK( !textLabel );
224 int UtcDaliToolkitTextLabelNewP(void)
226 ToolkitTestApplication application;
227 tet_infoline(" UtcDaliToolkitTextLabelNewP");
228 TextLabel textLabel = TextLabel::New( "Test Text" );
229 DALI_TEST_CHECK( textLabel );
233 int UtcDaliToolkitTextLabelDownCastP(void)
235 ToolkitTestApplication application;
236 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
237 TextLabel textLabel1 = TextLabel::New();
238 BaseHandle object( textLabel1 );
240 TextLabel textLabel2 = TextLabel::DownCast( object );
241 DALI_TEST_CHECK( textLabel2 );
243 TextLabel textLabel3 = DownCast< TextLabel >( object );
244 DALI_TEST_CHECK( textLabel3 );
248 int UtcDaliToolkitTextLabelDownCastN(void)
250 ToolkitTestApplication application;
251 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
252 BaseHandle uninitializedObject;
253 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
254 DALI_TEST_CHECK( !textLabel1 );
256 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
257 DALI_TEST_CHECK( !textLabel2 );
261 int UtcDaliToolkitTextLabelCopyConstructorP(void)
263 ToolkitTestApplication application;
264 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
265 TextLabel textLabel = TextLabel::New();
266 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
268 TextLabel copy( textLabel );
269 DALI_TEST_CHECK( copy );
270 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
274 int UtcDaliTextLabelMoveConstructor(void)
276 ToolkitTestApplication application;
278 TextLabel textLabel = TextLabel::New();
279 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
280 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
282 TextLabel moved = std::move( textLabel );
283 DALI_TEST_CHECK( moved );
284 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
285 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
286 DALI_TEST_CHECK( !textLabel );
291 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
293 ToolkitTestApplication application;
294 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
295 TextLabel textLabel = TextLabel::New();
296 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
298 TextLabel copy = textLabel;
299 DALI_TEST_CHECK( copy );
300 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
304 int UtcDaliTextLabelMoveAssignment(void)
306 ToolkitTestApplication application;
308 TextLabel textLabel = TextLabel::New();
309 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
310 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
313 moved = std::move( textLabel );
314 DALI_TEST_CHECK( moved );
315 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
316 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
317 DALI_TEST_CHECK( !textLabel );
322 // Positive test case for a method
323 int UtcDaliToolkitTextLabelGetPropertyP(void)
325 ToolkitTestApplication application;
326 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
327 TextLabel label = TextLabel::New("Test Text");
328 DALI_TEST_CHECK( label );
330 // Check Property Indices are correct
331 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
332 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
333 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
334 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
335 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
336 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
337 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
338 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
339 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
340 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
341 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
342 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
343 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
344 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
345 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
346 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
347 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
348 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
349 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
350 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
351 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
352 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
353 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
354 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
355 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
360 int UtcDaliToolkitTextLabelSetPropertyP(void)
362 ToolkitTestApplication application;
363 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
364 TextLabel label = TextLabel::New();
365 DALI_TEST_CHECK( label );
367 application.GetScene().Add( label );
369 // Note - we can't check the defaults since the stylesheets are platform-specific
370 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
371 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
373 // Check that text can be correctly reset
374 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
375 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
377 // Check font properties.
378 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
379 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
381 Property::Map fontStyleMapSet;
382 Property::Map fontStyleMapGet;
384 fontStyleMapSet.Insert( "weight", "bold" );
385 fontStyleMapSet.Insert( "width", "condensed" );
386 fontStyleMapSet.Insert( "slant", "italic" );
387 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
389 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
390 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
391 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
393 // Check the old font style format.
394 fontStyleMapSet.Clear();
395 fontStyleMapSet.Insert( "weight", "thin" );
396 fontStyleMapSet.Insert( "width", "expanded" );
397 fontStyleMapSet.Insert( "slant", "oblique" );
398 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
400 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
401 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
402 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
404 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
405 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
407 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
408 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
409 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
412 fontStyleMapSet.Clear();
413 fontStyleMapSet.Insert( "weight", "normal" );
414 fontStyleMapSet.Insert( "slant", "oblique" );
416 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
417 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
418 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
419 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
421 fontStyleMapSet.Clear();
422 fontStyleMapSet.Insert( "slant", "roman" );
424 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
425 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
426 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
428 // Replace 'roman' for 'normal'.
429 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
430 if( NULL != slantValue )
432 if( "normal" == slantValue->Get<std::string>() )
434 fontStyleMapGet["slant"] = "roman";
437 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
439 fontStyleMapSet.Clear();
441 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
442 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
443 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
444 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
447 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
448 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
450 // Check that the Alignment properties can be correctly set
451 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
452 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
453 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
454 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
456 // Check that text color can be properly set
457 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
458 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
460 Property::Map underlineMapSet;
461 Property::Map underlineMapGet;
463 underlineMapSet.Insert( "enable", false );
464 underlineMapSet.Insert( "color", Color::BLUE );
465 underlineMapSet.Insert( "height", 0 );
467 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
468 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
469 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
471 TextLabel label2 = TextLabel::New( "New text" );
472 DALI_TEST_CHECK( label2 );
473 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
475 // Check the enable markup property.
476 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
477 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
478 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
480 // Check the text property when markup is enabled
481 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
482 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
484 // Check for incomplete marks.
485 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
486 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
489 application.SendNotification();
490 application.Render();
494 tet_result(TET_FAIL);
497 // Check autoscroll properties
498 const int SCROLL_SPEED = 80;
499 const int SCROLL_LOOPS = 4;
500 const float SCROLL_GAP = 50.0f;
501 const float SCROLL_LOOP_DELAY = 0.3f;
502 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
503 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
505 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
506 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
507 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
508 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
509 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
510 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
511 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
512 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
513 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
514 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
515 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
516 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
518 //Check autoscroll stop type property
519 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
520 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
522 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
523 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
525 // test natural size with multi-line and line spacing
527 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
528 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
529 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
530 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
531 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
533 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
534 // The height of the text when multi-line is enabled will be larger
535 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
536 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
538 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
539 // Everything else will remain the same
540 int lineSpacing = 20;
541 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
542 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
543 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
544 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
547 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
549 TextLabel label3 = TextLabel::New("Some text here end there end here");
550 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
551 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
552 Vector3 textNaturalSize = label3.GetNaturalSize();
553 int lineSpacing = 20;
554 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
555 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
556 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
557 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
559 // Check the line spacing property
560 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
561 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
562 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
564 // Check the underline property
565 underlineMapSet.Clear();
566 underlineMapSet.Insert( "enable", true );
567 underlineMapSet.Insert( "color", Color::RED );
568 underlineMapSet.Insert( "height", 1 );
570 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
572 application.SendNotification();
573 application.Render();
575 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
576 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
577 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
579 underlineMapSet.Clear();
580 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
581 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
582 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
584 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
586 application.SendNotification();
587 application.Render();
589 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
590 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
591 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
592 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
594 underlineMapSet.Clear();
596 Property::Map underlineDisabledMapGet;
597 underlineDisabledMapGet.Insert( "enable", false );
598 underlineDisabledMapGet.Insert( "color", Color::GREEN );
599 underlineDisabledMapGet.Insert( "height", 2 );
601 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
603 application.SendNotification();
604 application.Render();
606 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
607 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
610 // Check the shadow property
612 Property::Map shadowMapSet;
613 Property::Map shadowMapGet;
615 shadowMapSet.Insert( "color", Color::GREEN );
616 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
617 shadowMapSet.Insert( "blurRadius", 5.0f );
619 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
621 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
622 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
623 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
625 shadowMapSet.Clear();
627 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
628 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
629 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
631 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
633 // Replace the offset (string) by a vector2
634 shadowMapSet.Clear();
635 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
636 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
637 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
639 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
640 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
641 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
642 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
644 shadowMapSet.Clear();
645 Property::Map shadowDisabledMapGet;
646 shadowDisabledMapGet.Insert( "color", Color::BLUE );
647 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
648 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
650 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
652 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
653 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
654 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
656 // Check the emboss property
657 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
658 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
660 // Check the outline property
662 // Test string type first
663 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
664 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
665 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
667 // Then test the property map type
668 Property::Map outlineMapSet;
669 Property::Map outlineMapGet;
671 outlineMapSet["color"] = Color::RED;
672 outlineMapSet["width"] = 2.0f;
673 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
675 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
676 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
677 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
679 outlineMapSet.Clear();
680 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
681 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
682 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
684 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
685 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
686 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
687 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
689 // Check the background property
690 Property::Map backgroundMapSet;
691 Property::Map backgroundMapGet;
693 backgroundMapSet["enable"] = true;
694 backgroundMapSet["color"] = Color::RED;
695 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
697 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
698 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
699 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
701 backgroundMapSet.Clear();
702 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
703 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
704 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
706 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
707 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
708 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
709 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
711 // Check the pixel size of font
712 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
713 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Check the ellipsis property
716 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
717 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
718 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
720 // Check the layout direction property
721 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
722 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
724 // Check the line size property
725 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
726 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
727 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
729 application.SendNotification();
730 application.Render();
735 int UtcDaliToolkitTextlabelAtlasRenderP(void)
737 ToolkitTestApplication application;
738 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
739 TextLabel label = TextLabel::New("Test Text");
740 DALI_TEST_CHECK( label );
742 // Avoid a crash when core load gl resources.
743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
745 application.GetScene().Add( label );
747 // Turn on all the effects
748 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
749 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
751 Property::Map underlineMap;
752 underlineMap.Insert( "enable", true );
753 underlineMap.Insert( "color", Color::RED );
754 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
756 Property::Map shadowMap;
757 shadowMap.Insert( "color", Color::BLUE );
758 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
759 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
763 // Render some text with the shared atlas backend
764 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
765 application.SendNotification();
766 application.Render();
770 tet_result(TET_FAIL);
775 // Render some text with the shared atlas backend
776 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
777 application.SendNotification();
778 application.Render();
782 tet_result(TET_FAIL);
787 int UtcDaliToolkitTextLabelLanguagesP(void)
789 ToolkitTestApplication application;
790 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
791 TextLabel label = TextLabel::New();
792 DALI_TEST_CHECK( label );
794 application.GetScene().Add( label );
796 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
797 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
798 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
799 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
800 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
801 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
803 label.SetProperty( TextLabel::Property::TEXT, scripts );
804 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
806 application.SendNotification();
807 application.Render();
812 int UtcDaliToolkitTextLabelEmojisP(void)
814 ToolkitTestApplication application;
815 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
816 TextLabel label = TextLabel::New();
817 DALI_TEST_CHECK( label );
819 application.GetScene().Add( label );
821 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
823 char* pathNamePtr = get_current_dir_name();
824 const std::string pathName( pathNamePtr );
827 TextAbstraction::FontDescription fontDescription;
828 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
829 fontDescription.family = "BreezeColorEmoji";
830 fontDescription.width = TextAbstraction::FontWidth::NONE;
831 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
832 fontDescription.slant = TextAbstraction::FontSlant::NONE;
834 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
836 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>";
837 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
838 label.SetProperty( TextLabel::Property::TEXT, emojis );
840 Property::Map shadowMap;
841 shadowMap.Insert( "color", "green" );
842 shadowMap.Insert( "offset", "2 2" );
843 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
845 application.SendNotification();
846 application.Render();
848 // EMOJI + ZWJ + EMOJI case for coverage.
849 const std::string emojiWithZWJ = "👩‍🔬";
850 label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
852 application.SendNotification();
853 application.Render();
855 // EMOJI Sequences case for coverage.
856 std::string emojiSequences =
857 "Text VS15 ☪︎\n" //text presentation sequence and selector
858 "Color VS16 ☪️\n" //emoji presentation sequence and selector
859 "Default ☪ \n" //default presentation
860 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
861 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
862 "WomanScientistLightSkinTone👩🏻‍🔬 \n" //emoji modifier sequence: skin tone & JWZ
863 "LeftRightArrowText↔︎\n" //text presentation sequence and selector
864 "LeftRightArrowEmoji↔️\n" //emoji presentation sequence and selector
865 "SouthKoreaFlag🇰🇷\n" //emoji flag sequence
866 "JordanFlag🇯🇴\n" // emoji flag sequence
867 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" //emoji tag sequence like England flag
868 "Runner 🏃‍➡️ \n"
869 "VictoryHandMediumLightSkinTone:✌️🏼\n" //emoji modifier sequence: skin tone
870 "RainbowFlag:🏳️‍🌈 \n" //emoji zwj sequence: Rainbow Flag
871 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
872 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
873 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
874 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
875 "two adjacent glyphs ☪️️️☪️\n" //This line should be rendered as two adjacent glyphs
876 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
877 "Surfing Medium Skin Female: 🏄🏼‍♀️"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
879 label.SetProperty( TextLabel::Property::TEXT, emojiSequences );
880 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
881 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
882 label.SetProperty( TextLabel::Property::ELLIPSIS, false);
884 application.SendNotification();
885 application.Render();
889 int UtcDaliToolkitTextlabelScrollingP(void)
891 ToolkitTestApplication application;
892 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
893 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
894 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
896 DALI_TEST_CHECK( labelImmediate );
897 DALI_TEST_CHECK( labelFinished );
898 // Avoid a crash when core load gl resources.
899 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
900 application.GetScene().Add( labelImmediate );
901 // Turn on all the effects
902 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
903 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
904 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
905 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
906 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
908 application.GetScene().Add( labelFinished );
909 // Turn on all the effects
910 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
911 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
912 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
913 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
914 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
920 // Render some text with the shared atlas backend
921 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
922 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
924 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
925 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
927 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
928 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
929 application.SendNotification();
930 application.Render();
932 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
933 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
934 application.SendNotification();
935 application.Render();
940 tet_result(TET_FAIL);
946 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
948 ToolkitTestApplication application;
949 TextLabel labelShort = TextLabel::New("Some text to scroll");
950 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!");
952 DALI_TEST_CHECK( labelShort );
953 DALI_TEST_CHECK( labelLong );
954 // Avoid a crash when core load gl resources.
955 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
956 application.GetScene().Add( labelShort );
957 // Turn on all the effects
958 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
959 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
960 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
961 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
962 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
963 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
965 application.GetScene().Add( labelLong );
966 // Turn on all the effects
967 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
968 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
969 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
970 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
971 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
972 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
976 // Render some text with the shared atlas backend
977 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
978 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
979 application.SendNotification();
980 application.Render();
982 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
983 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
984 application.SendNotification();
985 application.Render();
990 tet_result(TET_FAIL);
996 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
998 ToolkitTestApplication application;
999 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1000 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1002 DALI_TEST_CHECK( labelShort );
1003 DALI_TEST_CHECK( labelLong );
1004 // Avoid a crash when core load gl resources.
1005 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1006 application.GetScene().Add( labelShort );
1007 // Turn on all the effects
1008 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1009 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1010 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1011 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1012 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1013 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1015 application.GetScene().Add( labelLong );
1016 // Turn on all the effects
1017 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1018 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1019 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1020 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1021 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1022 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1026 // Render some text with the shared atlas backend
1027 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1028 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1029 application.SendNotification();
1030 application.Render();
1032 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1033 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1034 application.SendNotification();
1035 application.Render();
1040 tet_result(TET_FAIL);
1046 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1048 ToolkitTestApplication application;
1049 TextLabel labelShort = TextLabel::New("Some text to scroll");
1050 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!");
1052 DALI_TEST_CHECK( labelShort );
1053 DALI_TEST_CHECK( labelLong );
1054 // Avoid a crash when core load gl resources.
1055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1056 application.GetScene().Add( labelShort );
1057 // Turn on all the effects
1058 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1059 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1060 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1061 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1062 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1063 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1065 application.GetScene().Add( labelLong );
1066 // Turn on all the effects
1067 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1068 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1069 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1070 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1071 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1072 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1076 // Render some text with the shared atlas backend
1077 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1078 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1079 application.SendNotification();
1080 application.Render();
1082 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1083 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1084 application.SendNotification();
1085 application.Render();
1090 tet_result(TET_FAIL);
1096 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1098 ToolkitTestApplication application;
1099 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1100 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1102 DALI_TEST_CHECK( labelShort );
1103 DALI_TEST_CHECK( labelLong );
1104 // Avoid a crash when core load gl resources.
1105 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1106 application.GetScene().Add( labelShort );
1107 // Turn on all the effects
1108 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1109 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1110 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1111 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1112 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1113 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1115 application.GetScene().Add( labelLong );
1116 // Turn on all the effects
1117 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1118 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1119 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1120 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1121 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1122 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1126 // Render some text with the shared atlas backend
1127 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1128 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1129 application.SendNotification();
1130 application.Render();
1132 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1133 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1134 application.SendNotification();
1135 application.Render();
1140 tet_result(TET_FAIL);
1146 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1148 ToolkitTestApplication application;
1149 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1150 TextLabel label = TextLabel::New("Some text to scroll");
1151 DALI_TEST_CHECK( label );
1152 // Avoid a crash when core load gl resources.
1153 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1154 application.GetScene().Add( label );
1155 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1156 // Turn on all the effects
1157 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1158 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1159 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1160 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1163 application.SendNotification();
1164 application.Render();
1166 unsigned int actorCount1 = label.GetChildCount();
1167 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1171 // Render some text with the shared atlas backend
1172 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1173 application.SendNotification();
1174 application.Render(2000);
1176 unsigned int actorCount1 = label.GetChildCount();
1177 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1179 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1182 application.SendNotification();
1183 application.Render();
1185 unsigned int actorCount2 = label.GetChildCount();
1186 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1188 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1193 tet_result(TET_FAIL);
1199 int UtcDaliToolkitTextlabelScrollingN(void)
1201 ToolkitTestApplication application;
1202 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1204 TextLabel label = TextLabel::New("Some text to scroll");
1205 DALI_TEST_CHECK( label );
1207 application.GetScene().Add( label );
1209 // Avoid a crash when core load gl resources.
1210 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1212 // The text scrolling works only on single line text.
1213 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1215 // Turn on all the effects.
1216 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1217 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1218 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1220 // Enable the auto scrolling effect.
1221 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1223 // The auto scrolling shouldn't be enabled.
1224 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1225 DALI_TEST_CHECK( !enabled );
1230 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1232 ToolkitTestApplication application;
1233 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1235 TextLabel label = TextLabel::New("Some text to scroll");
1236 DALI_TEST_CHECK( label );
1238 application.GetScene().Add( label );
1240 // Avoid a crash when core load gl resources.
1241 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1243 // Turn on all the effects.
1244 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1245 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1246 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1250 // Enable the auto scrolling effect.
1251 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1252 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1254 // Disable the ellipsis
1255 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1258 application.SendNotification();
1259 application.Render();
1261 // Stop auto scrolling
1262 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1264 // Check the ellipsis property
1265 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1269 tet_result(TET_FAIL);
1275 int UtcDaliToolkitTextlabelEllipsis(void)
1277 ToolkitTestApplication application;
1278 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1280 TextLabel label = TextLabel::New("Hello world");
1281 DALI_TEST_CHECK( label );
1283 // Avoid a crash when core load gl resources.
1284 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1286 application.GetScene().Add( label );
1288 // Turn on all the effects
1289 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1290 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1291 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1296 application.SendNotification();
1297 application.Render();
1301 tet_result(TET_FAIL);
1304 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1305 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1306 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1311 application.SendNotification();
1312 application.Render();
1316 tet_result(TET_FAIL);
1320 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1321 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1322 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1327 application.SendNotification();
1328 application.Render();
1332 tet_result(TET_FAIL);
1338 int UtcDaliToolkitTextlabelTextWrapMode(void)
1340 ToolkitTestApplication application;
1341 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1345 TextLabel label = TextLabel::New();
1346 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1347 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1348 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1352 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1353 application.GetScene().Add( label );
1355 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1356 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1358 application.SendNotification();
1359 application.Render();
1361 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1362 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1364 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1365 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1367 application.SendNotification();
1368 application.Render();
1370 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1371 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1373 application.SendNotification();
1374 application.Render();
1376 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1377 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1379 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1380 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1382 application.SendNotification();
1383 application.Render();
1385 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1386 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1388 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1389 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1390 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1395 int UtcDaliToolkitTextLabelColorComponents(void)
1397 ToolkitTestApplication application;
1399 TextLabel label = TextLabel::New();
1400 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1401 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1402 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1403 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1404 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1406 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1407 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1409 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1410 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1412 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1413 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1416 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1418 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1419 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1420 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1422 // Test a transparent text - Rendering should be skipped.
1423 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1424 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1426 application.GetScene().Add( label );
1428 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1429 drawTrace.Enable( true );
1431 application.SendNotification();
1432 application.Render();
1434 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1436 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1445 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1449 application.SendNotification();
1450 application.Render();
1452 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1457 int UtcDaliToolkitTextlabelTextStyle01(void)
1459 ToolkitTestApplication application;
1460 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1462 TextLabel label = TextLabel::New();
1463 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1464 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1465 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1466 application.GetScene().Add( label );
1468 Property::Map outlineMapSet;
1469 Property::Map outlineMapGet;
1471 outlineMapSet["color"] = Color::BLUE;
1472 outlineMapSet["width"] = 2.0f;
1473 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1475 application.SendNotification();
1476 application.Render();
1478 Property::Map shadowMapSet;
1479 shadowMapSet.Insert( "color", "green" );
1480 shadowMapSet.Insert( "offset", "2 2" );
1481 shadowMapSet.Insert( "blurRadius", "3" );
1482 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1484 outlineMapSet["color"] = Color::RED;
1485 outlineMapSet["width"] = 0.0f;
1486 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1488 application.SendNotification();
1489 application.Render();
1491 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1493 Property::Value* colorValue = outlineMapGet.Find("color");
1495 bool colorMatched( false );
1499 Property::Type valueType = colorValue->GetType();
1501 if ( Property::STRING == valueType )
1503 std::string stringValue;
1504 colorValue->Get( stringValue );
1505 if ( stringValue == "red" )
1507 colorMatched = true;
1510 else if ( Property::VECTOR4 == valueType )
1512 Vector4 colorVector4;
1513 colorValue->Get( colorVector4 );
1514 if ( colorVector4 == Color::RED )
1516 colorMatched = true;
1521 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1526 int UtcDaliToolkitTextlabelMultiline(void)
1528 ToolkitTestApplication application;
1529 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1531 TextLabel label = TextLabel::New();
1532 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1533 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1534 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1535 application.GetScene().Add( label );
1537 application.SendNotification();
1538 application.Render();
1540 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1541 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1543 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1545 application.SendNotification();
1546 application.Render();
1548 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1549 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1555 int UtcDaliToolkitTextlabelTextDirection(void)
1557 ToolkitTestApplication application;
1558 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1560 TextLabel label = TextLabel::New();
1561 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1563 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1564 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1565 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1566 application.GetScene().Add( label );
1569 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1572 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1573 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1575 // Test RTL text starting with weak character
1576 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1577 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1579 // Test RTL text string with emoji and weak character
1580 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1581 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1586 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1588 ToolkitTestApplication application;
1589 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1591 TextLabel label = TextLabel::New();
1593 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1594 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1595 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1596 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1597 application.GetScene().Add( label );
1598 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1600 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1601 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1603 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1604 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1609 int UtcDaliToolkitTextLabelBitmapFont(void)
1611 ToolkitTestApplication application;
1612 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1614 DevelText::BitmapFontDescription fontDescription;
1615 fontDescription.name = "Digits";
1616 fontDescription.underlinePosition = 0.f;
1617 fontDescription.underlineThickness = 0.f;
1619 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1620 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1621 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1622 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1623 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1624 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1625 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1626 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1627 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1628 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1629 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1631 TextAbstraction::BitmapFont bitmapFont;
1632 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1634 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1635 fontClient.GetFontId( bitmapFont );
1637 TextLabel label = TextLabel::New();
1639 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1640 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1642 // 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.
1643 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1645 application.GetScene().Add( label );
1647 application.SendNotification();
1648 application.Render();
1650 // The text has been rendered if the height of the text-label is the height of the line.
1651 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1656 int ConvertPointToPixel( float point )
1658 unsigned int horizontalDpi = 0u;
1659 unsigned int verticalDpi = 0u;
1660 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1661 fontClient.GetDpi( horizontalDpi, verticalDpi );
1663 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1666 int UtcDaliToolkitTextlabelTextFit(void)
1668 ToolkitTestApplication application;
1669 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1670 TextLabel label = TextLabel::New();
1671 Vector2 size( 460.0f, 100.0f );
1672 label.SetProperty( Actor::Property::SIZE, size );
1673 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1675 // connect to the text git changed signal.
1676 ConnectionTracker* testTracker = new ConnectionTracker();
1677 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1678 bool textFitChangedSignal = false;
1679 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1680 gTextFitChangedCallBackCalled = false;
1683 Property::Map textFitMapSet;
1684 textFitMapSet["enable"] = true;
1685 textFitMapSet["minSize"] = 10.f;
1686 textFitMapSet["maxSize"] = 100.f;
1687 textFitMapSet["stepSize"] = -1.f;
1688 textFitMapSet["fontSizeType"] = "pointSize";
1690 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1691 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1693 application.GetScene().Add( label );
1695 application.SendNotification();
1696 application.Render();
1698 const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1699 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1701 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1702 DALI_TEST_CHECK(textFitChangedSignal);
1705 textFitMapSet.Clear();
1706 textFitMapSet["enable"] = true;
1707 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1708 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1709 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1710 textFitMapSet["fontSizeType"] = "pixelSize";
1712 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1714 application.SendNotification();
1715 application.Render();
1717 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1722 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1724 ToolkitTestApplication application;
1725 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1727 DevelText::BitmapFontDescription fontDescription;
1728 fontDescription.name = "Digits";
1729 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1731 TextAbstraction::BitmapFont bitmapFont;
1732 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1734 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1735 fontClient.GetFontId( bitmapFont );
1737 TextLabel label = TextLabel::New();
1738 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1739 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1740 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1741 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1742 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1744 Property::Map underlineMapSet;
1745 underlineMapSet.Clear();
1746 underlineMapSet.Insert( "enable", true );
1747 underlineMapSet.Insert( "color", Color::RED );
1748 underlineMapSet.Insert( "height", 1 );
1749 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1750 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1752 application.GetScene().Add( label );
1754 application.SendNotification();
1755 application.Render();
1757 const int maxTextureSize = Dali::GetMaxTextureSize();
1758 // Whether the rendered text is greater than maxTextureSize
1759 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1761 // Check if the number of renderers is greater than 1.
1762 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1767 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1769 ToolkitTestApplication application;
1770 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1772 Vector2 size( 300.0f, 100.0f );
1774 Dali::Toolkit::DevelText::RendererParameters textParameters;
1775 textParameters.text = "This is a sample text to get the last index.";
1776 textParameters.layout = "multiLine";
1777 textParameters.fontSize = 20.f;
1778 textParameters.textWidth = 300u;
1779 textParameters.textHeight = 100u;
1780 textParameters.ellipsisEnabled = true;
1781 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1783 DALI_TEST_CHECK( !indexArray.Empty() );
1784 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1789 int UtcDaliToolkitTextlabelFontSizeScale(void)
1791 ToolkitTestApplication application;
1792 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1794 TextLabel label = TextLabel::New();
1795 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1796 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1797 Vector3 nonScaledSize = label.GetNaturalSize();
1799 TextLabel labelScaled = TextLabel::New();
1800 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1801 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1802 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1803 Vector3 scaledSize = labelScaled.GetNaturalSize();
1805 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1807 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1808 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1809 nonScaledSize = label.GetNaturalSize();
1811 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1812 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1813 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1814 scaledSize = labelScaled.GetNaturalSize();
1816 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1821 // Positive test for the anchorClicked signal.
1822 int UtcDaliToolkitTextlabelAnchorClicked(void)
1824 ToolkitTestApplication application;
1825 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1826 TextLabel label = TextLabel::New();
1827 DALI_TEST_CHECK(label);
1829 application.GetScene().Add(label);
1831 // connect to the anchor clicked signal.
1832 ConnectionTracker* testTracker = new ConnectionTracker();
1833 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1834 bool anchorClickedSignal = false;
1835 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1837 gAnchorClickedCallBackCalled = false;
1838 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1839 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1840 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1841 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1842 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1844 application.SendNotification();
1845 application.Render();
1847 // Create a tap event to touch the text label.
1848 TestGenerateTap(application, 5.0f, 25.0f, 100);
1849 application.SendNotification();
1850 application.Render();
1852 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1853 DALI_TEST_CHECK(anchorClickedSignal);
1856 gAnchorClickedCallBackCalled = false;
1857 anchorClickedSignal = false;
1858 label.SetProperty(TextLabel::Property::TEXT, "");
1859 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1861 application.SendNotification();
1862 application.Render();
1865 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1866 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1867 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1868 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1869 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1871 application.SendNotification();
1872 application.Render();
1874 // Create a tap event to touch the text label.
1875 TestGenerateTap(application, 5.0f, 25.0f, 200);
1876 application.SendNotification();
1877 application.Render();
1879 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1880 DALI_TEST_CHECK(anchorClickedSignal);
1883 gAnchorClickedCallBackNotCalled = true;
1884 // Tap the outside of anchor, callback should not be called.
1885 TestGenerateTap(application, 150.f, 100.f, 300);
1886 application.SendNotification();
1887 application.Render();
1889 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1894 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1896 ToolkitTestApplication application;
1897 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1899 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1901 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1902 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1903 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1905 // Create a text editor
1906 TextLabel textLabel = TextLabel::New();
1907 //Set size to avoid automatic eliding
1908 textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1909 //Set very large font-size using point-size
1910 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1911 //Specify font-family
1912 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1913 //Set text to check if appear or not
1914 textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1916 application.GetScene().Add( textLabel );
1918 application.SendNotification();
1919 application.Render();
1920 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1921 Vector3 naturalSize = textLabel.GetNaturalSize();
1923 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1924 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1929 int UtcDaliTextLabelHyphenWrapMode(void)
1931 ToolkitTestApplication application;
1932 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1935 TextLabel label = TextLabel::New();
1936 label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1937 label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1938 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1939 application.GetScene().Add( label );
1940 application.SendNotification();
1941 application.Render();
1943 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1944 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1945 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1947 application.SendNotification();
1948 application.Render();
1950 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1956 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1958 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1959 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1960 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1962 application.SendNotification();
1963 application.Render();
1965 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1972 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1978 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1980 ToolkitTestApplication application;
1982 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1984 int lineCountBefore =0 ;
1985 int lineCountAfter =0 ;
1987 // Create a text editor
1988 TextLabel textLabel = TextLabel::New();
1989 //Set very large font-size using point-size
1990 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1991 //Specify font-family
1992 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1994 textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
1995 //Set text longer than width of textLabel
1996 textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
1997 //Set line wrap mode Character
1998 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1999 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2001 application.GetScene().Add( textLabel );
2003 application.SendNotification();
2004 application.Render();
2007 lineCountBefore = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2009 textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2010 lineCountAfter = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2012 // When the text changed, the Line-count should be updated according to new text.
2013 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2014 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
2015 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
2021 int utcDaliTextLabelGeometryRTL(void)
2023 ToolkitTestApplication application;
2024 tet_infoline(" utcDaliTextLabelGeometryRTL");
2026 TextLabel label = TextLabel::New();
2027 DALI_TEST_CHECK( label );
2029 application.GetScene().Add( label );
2031 label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2032 label.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 100.f ) );
2033 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2034 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2035 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2036 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
2037 label.SetProperty( TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
2039 // Avoid a crash when core load gl resources.
2040 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 unsigned int expectedCount = 4;
2047 unsigned int startIndex = 3;
2048 unsigned int endIndex = 24;
2050 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2051 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2053 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2054 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2056 Vector<Vector2> expectedSizes;
2057 Vector<Vector2> expectedPositions;
2059 expectedPositions.PushBack(Vector2(24, 0));
2060 expectedSizes.PushBack(Vector2(33, 25));
2062 expectedPositions.PushBack(Vector2(-1, 25));
2063 expectedSizes.PushBack(Vector2(52, 25));
2065 expectedPositions.PushBack(Vector2(-1, 50));
2066 expectedSizes.PushBack(Vector2(59, 25));
2068 expectedPositions.PushBack(Vector2(73, 75));
2069 expectedSizes.PushBack(Vector2(37, 25));
2071 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2076 int utcDaliTextLabelGeometryGlyphMiddle(void)
2078 ToolkitTestApplication application;
2079 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2081 TextLabel label = TextLabel::New();
2082 DALI_TEST_CHECK( label );
2084 application.GetScene().Add( label );
2086 label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2087 label.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2088 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2089 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2090 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2091 label.SetProperty( TextLabel::Property::TEXT, "لا تحتوي على لا" );
2093 // Avoid a crash when core load gl resources.
2094 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2096 // Render and notify
2097 application.SendNotification();
2098 application.Render();
2100 unsigned int expectedCount = 1;
2101 unsigned int startIndex = 1;
2102 unsigned int endIndex = 13;
2104 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2105 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2107 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2108 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2110 Vector<Vector2> expectedSizes;
2111 Vector<Vector2> expectedPositions;
2113 expectedPositions.PushBack(Vector2(12, 0));
2114 expectedSizes.PushBack(Vector2(118, 25));
2116 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2121 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2123 ToolkitTestApplication application;
2124 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2125 TextLabel textLabel = TextLabel::New();
2127 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2128 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2130 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2131 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2132 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2134 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2135 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2136 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2138 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2139 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2140 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2142 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2143 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2144 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2146 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2147 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2148 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2150 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2151 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2152 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2154 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2155 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2156 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2158 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2159 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2160 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2162 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2163 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2164 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2166 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2167 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2168 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2170 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2171 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2172 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2174 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2175 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2176 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );