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>
35 using namespace Toolkit;
37 void dali_textlabel_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textlabel_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
65 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE = "underline";
67 const char* const PROPERTY_NAME_SHADOW = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
72 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
73 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
74 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
75 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
77 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
79 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
80 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
82 static bool gAnchorClickedCallBackCalled;
83 static bool gAnchorClickedCallBackNotCalled;
85 static bool gTextFitChangedCallBackCalled;
87 struct CallbackFunctor
89 CallbackFunctor(bool* callbackFlag)
90 : mCallbackFlag( callbackFlag )
96 *mCallbackFlag = true;
101 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
103 tet_infoline(" TestAnchorClickedCallback");
105 gAnchorClickedCallBackNotCalled = false;
107 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
109 gAnchorClickedCallBackCalled = true;
113 static void TestTextFitChangedCallback(TextLabel control)
115 tet_infoline(" TestTextFitChangedCallback");
116 gTextFitChangedCallBackCalled = true;
119 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
121 const Property::Map::SizeType size = mapGet.Count();
123 if( size == mapSet.Count() )
125 for( unsigned int index = 0u; index < size; ++index )
127 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
129 // Find the keys of the 'get' map
130 Property::Index indexKey = valueGet.first.indexKey;
131 std::string stringKey = valueGet.first.stringKey;
133 if( !indexConversionTable.empty() )
135 if( stringKey.empty() )
137 stringKey = indexConversionTable[ indexKey ];
140 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
142 Property::Index index = 0u;
143 for( auto key : indexConversionTable )
145 if( key == stringKey )
155 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
157 if( nullptr != valueSet )
159 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
161 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
164 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
166 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
169 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
171 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
174 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
176 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
179 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
181 Vector2 vector2Get = valueGet.second.Get<Vector2>();
182 Vector2 vector2Set = valueSet->Get<Vector2>();
183 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
186 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
188 Vector4 vector4Get = valueGet.second.Get<Vector4>();
189 Vector4 vector4Set = valueSet->Get<Vector4>();
190 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 );
196 if ( valueGet.first.type == Property::Key::INDEX )
198 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
202 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
214 int UtcDaliToolkitTextLabelConstructorP(void)
216 ToolkitTestApplication application;
217 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
219 DALI_TEST_CHECK( !textLabel );
223 int UtcDaliToolkitTextLabelNewP(void)
225 ToolkitTestApplication application;
226 tet_infoline(" UtcDaliToolkitTextLabelNewP");
227 TextLabel textLabel = TextLabel::New( "Test Text" );
228 DALI_TEST_CHECK( textLabel );
232 int UtcDaliToolkitTextLabelDownCastP(void)
234 ToolkitTestApplication application;
235 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
236 TextLabel textLabel1 = TextLabel::New();
237 BaseHandle object( textLabel1 );
239 TextLabel textLabel2 = TextLabel::DownCast( object );
240 DALI_TEST_CHECK( textLabel2 );
242 TextLabel textLabel3 = DownCast< TextLabel >( object );
243 DALI_TEST_CHECK( textLabel3 );
247 int UtcDaliToolkitTextLabelDownCastN(void)
249 ToolkitTestApplication application;
250 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
251 BaseHandle uninitializedObject;
252 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
253 DALI_TEST_CHECK( !textLabel1 );
255 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
256 DALI_TEST_CHECK( !textLabel2 );
260 int UtcDaliToolkitTextLabelCopyConstructorP(void)
262 ToolkitTestApplication application;
263 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
264 TextLabel textLabel = TextLabel::New();
265 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
267 TextLabel copy( textLabel );
268 DALI_TEST_CHECK( copy );
269 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
273 int UtcDaliTextLabelMoveConstructor(void)
275 ToolkitTestApplication application;
277 TextLabel textLabel = TextLabel::New();
278 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
279 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
281 TextLabel moved = std::move( textLabel );
282 DALI_TEST_CHECK( moved );
283 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
284 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
285 DALI_TEST_CHECK( !textLabel );
290 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
292 ToolkitTestApplication application;
293 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
294 TextLabel textLabel = TextLabel::New();
295 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
297 TextLabel copy = textLabel;
298 DALI_TEST_CHECK( copy );
299 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
303 int UtcDaliTextLabelMoveAssignment(void)
305 ToolkitTestApplication application;
307 TextLabel textLabel = TextLabel::New();
308 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
309 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
312 moved = std::move( textLabel );
313 DALI_TEST_CHECK( moved );
314 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
315 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
316 DALI_TEST_CHECK( !textLabel );
321 // Positive test case for a method
322 int UtcDaliToolkitTextLabelGetPropertyP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
326 TextLabel label = TextLabel::New("Test Text");
327 DALI_TEST_CHECK( label );
329 // Check Property Indices are correct
330 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
331 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
332 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
333 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
334 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
335 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
336 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
337 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
338 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
339 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
340 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
341 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
342 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
343 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
344 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
345 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
346 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
347 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
348 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
349 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
350 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
351 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
352 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
353 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
354 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
359 int UtcDaliToolkitTextLabelSetPropertyP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
363 TextLabel label = TextLabel::New();
364 DALI_TEST_CHECK( label );
366 application.GetScene().Add( label );
368 // Note - we can't check the defaults since the stylesheets are platform-specific
369 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
370 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
372 // Check that text can be correctly reset
373 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
374 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
376 // Check font properties.
377 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
378 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
380 Property::Map fontStyleMapSet;
381 Property::Map fontStyleMapGet;
383 fontStyleMapSet.Insert( "weight", "bold" );
384 fontStyleMapSet.Insert( "width", "condensed" );
385 fontStyleMapSet.Insert( "slant", "italic" );
386 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
388 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
389 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
390 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
392 // Check the old font style format.
393 fontStyleMapSet.Clear();
394 fontStyleMapSet.Insert( "weight", "thin" );
395 fontStyleMapSet.Insert( "width", "expanded" );
396 fontStyleMapSet.Insert( "slant", "oblique" );
397 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
399 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
400 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
401 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
403 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
404 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
406 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
407 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
408 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
411 fontStyleMapSet.Clear();
412 fontStyleMapSet.Insert( "weight", "normal" );
413 fontStyleMapSet.Insert( "slant", "oblique" );
415 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
416 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
417 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
418 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
420 fontStyleMapSet.Clear();
421 fontStyleMapSet.Insert( "slant", "roman" );
423 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
424 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
425 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
427 // Replace 'roman' for 'normal'.
428 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
429 if( NULL != slantValue )
431 if( "normal" == slantValue->Get<std::string>() )
433 fontStyleMapGet["slant"] = "roman";
436 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
438 fontStyleMapSet.Clear();
440 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
441 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
442 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
443 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
446 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
447 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
449 // Check that the Alignment properties can be correctly set
450 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
451 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
452 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
453 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
455 // Check that text color can be properly set
456 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
457 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
459 Property::Map underlineMapSet;
460 Property::Map underlineMapGet;
462 underlineMapSet.Insert( "enable", false );
463 underlineMapSet.Insert( "color", Color::BLUE );
464 underlineMapSet.Insert( "height", 0 );
466 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
467 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
468 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
470 TextLabel label2 = TextLabel::New( "New text" );
471 DALI_TEST_CHECK( label2 );
472 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
474 // Check the enable markup property.
475 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
476 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
477 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
479 // Check the text property when markup is enabled
480 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
481 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
483 // Check for incomplete marks.
484 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
485 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
488 application.SendNotification();
489 application.Render();
493 tet_result(TET_FAIL);
496 // Check autoscroll properties
497 const int SCROLL_SPEED = 80;
498 const int SCROLL_LOOPS = 4;
499 const float SCROLL_GAP = 50.0f;
500 const float SCROLL_LOOP_DELAY = 0.3f;
501 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
502 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
504 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
505 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
506 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
507 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
508 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
509 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
510 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
511 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
512 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
513 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
514 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
515 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
517 //Check autoscroll stop type property
518 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
519 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
521 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
522 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
524 // test natural size with multi-line and line spacing
526 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
527 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
528 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
529 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
530 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
532 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
533 // The height of the text when multi-line is enabled will be larger
534 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
535 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
537 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
538 // Everything else will remain the same
539 int lineSpacing = 20;
540 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
541 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
542 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
543 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
546 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
548 TextLabel label3 = TextLabel::New("Some text here end there end here");
549 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
550 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
551 Vector3 textNaturalSize = label3.GetNaturalSize();
552 int lineSpacing = 20;
553 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
554 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
555 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
556 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
558 // Check the line spacing property
559 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
560 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
561 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
563 // Check the underline property
564 underlineMapSet.Clear();
565 underlineMapSet.Insert( "enable", true );
566 underlineMapSet.Insert( "color", Color::RED );
567 underlineMapSet.Insert( "height", 1 );
569 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
571 application.SendNotification();
572 application.Render();
574 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
575 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
576 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
578 underlineMapSet.Clear();
579 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
580 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
581 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
583 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
585 application.SendNotification();
586 application.Render();
588 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
589 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
590 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
591 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
593 underlineMapSet.Clear();
595 Property::Map underlineDisabledMapGet;
596 underlineDisabledMapGet.Insert( "enable", false );
597 underlineDisabledMapGet.Insert( "color", Color::GREEN );
598 underlineDisabledMapGet.Insert( "height", 2 );
600 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
602 application.SendNotification();
603 application.Render();
605 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
606 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
609 // Check the shadow property
611 Property::Map shadowMapSet;
612 Property::Map shadowMapGet;
614 shadowMapSet.Insert( "color", Color::GREEN );
615 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
616 shadowMapSet.Insert( "blurRadius", 5.0f );
618 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
620 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
621 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
622 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
624 shadowMapSet.Clear();
626 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
627 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
628 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
630 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
632 // Replace the offset (string) by a vector2
633 shadowMapSet.Clear();
634 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
635 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
636 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
638 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
639 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
640 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
641 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
643 shadowMapSet.Clear();
644 Property::Map shadowDisabledMapGet;
645 shadowDisabledMapGet.Insert( "color", Color::BLUE );
646 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
647 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
649 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
651 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
652 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
653 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
655 // Check the emboss property
656 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
657 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
659 // Check the outline property
661 // Test string type first
662 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
663 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
664 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
666 // Then test the property map type
667 Property::Map outlineMapSet;
668 Property::Map outlineMapGet;
670 outlineMapSet["color"] = Color::RED;
671 outlineMapSet["width"] = 2.0f;
672 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
674 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
675 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
676 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
678 outlineMapSet.Clear();
679 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
680 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
681 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
683 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
684 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
685 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
686 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
688 // Check the background property
689 Property::Map backgroundMapSet;
690 Property::Map backgroundMapGet;
692 backgroundMapSet["enable"] = true;
693 backgroundMapSet["color"] = Color::RED;
694 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
696 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
697 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
698 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
700 backgroundMapSet.Clear();
701 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
702 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
703 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
705 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
706 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
707 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
708 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
710 // Check the pixel size of font
711 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
712 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 // Check the ellipsis property
715 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
716 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
717 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
719 // Check the layout direction property
720 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
721 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
723 // Check the line size property
724 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
725 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
726 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
728 application.SendNotification();
729 application.Render();
734 int UtcDaliToolkitTextlabelAtlasRenderP(void)
736 ToolkitTestApplication application;
737 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
738 TextLabel label = TextLabel::New("Test Text");
739 DALI_TEST_CHECK( label );
741 // Avoid a crash when core load gl resources.
742 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
744 application.GetScene().Add( label );
746 // Turn on all the effects
747 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
748 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
750 Property::Map underlineMap;
751 underlineMap.Insert( "enable", true );
752 underlineMap.Insert( "color", Color::RED );
753 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
755 Property::Map shadowMap;
756 shadowMap.Insert( "color", Color::BLUE );
757 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
758 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
762 // Render some text with the shared atlas backend
763 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
764 application.SendNotification();
765 application.Render();
769 tet_result(TET_FAIL);
774 // Render some text with the shared atlas backend
775 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
776 application.SendNotification();
777 application.Render();
781 tet_result(TET_FAIL);
786 int UtcDaliToolkitTextLabelLanguagesP(void)
788 ToolkitTestApplication application;
789 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
790 TextLabel label = TextLabel::New();
791 DALI_TEST_CHECK( label );
793 application.GetScene().Add( label );
795 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
796 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
797 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
798 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
799 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
800 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
802 label.SetProperty( TextLabel::Property::TEXT, scripts );
803 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
805 application.SendNotification();
806 application.Render();
811 int UtcDaliToolkitTextLabelEmojisP(void)
813 ToolkitTestApplication application;
814 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
815 TextLabel label = TextLabel::New();
816 DALI_TEST_CHECK( label );
818 application.GetScene().Add( label );
820 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
822 char* pathNamePtr = get_current_dir_name();
823 const std::string pathName( pathNamePtr );
826 TextAbstraction::FontDescription fontDescription;
827 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
828 fontDescription.family = "BreezeColorEmoji";
829 fontDescription.width = TextAbstraction::FontWidth::NONE;
830 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
831 fontDescription.slant = TextAbstraction::FontSlant::NONE;
833 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
835 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>";
836 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
837 label.SetProperty( TextLabel::Property::TEXT, emojis );
839 Property::Map shadowMap;
840 shadowMap.Insert( "color", "green" );
841 shadowMap.Insert( "offset", "2 2" );
842 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
844 application.SendNotification();
845 application.Render();
847 // EMOJI + ZWJ + EMOJI case for coverage.
848 const std::string emojiWithZWJ = "👩‍🔬";
849 label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
851 application.SendNotification();
852 application.Render();
854 // EMOJI Sequences case for coverage.
855 std::string emojiSequences =
856 "Text VS15 ☪︎\n" //text presentation sequence and selector
857 "Color VS16 ☪️\n" //emoji presentation sequence and selector
858 "Default ☪ \n" //default presentation
859 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
860 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
861 "WomanScientistLightSkinTone👩🏻‍🔬 \n" //emoji modifier sequence: skin tone & JWZ
862 "LeftRightArrowText↔︎\n" //text presentation sequence and selector
863 "LeftRightArrowEmoji↔️\n" //emoji presentation sequence and selector
864 "SouthKoreaFlag🇰🇷\n" //emoji flag sequence
865 "JordanFlag🇯🇴\n" // emoji flag sequence
866 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" //emoji tag sequence like England flag
867 "Runner 🏃‍➡️ \n"
868 "VictoryHandMediumLightSkinTone:✌️🏼\n" //emoji modifier sequence: skin tone
869 "RainbowFlag:🏳️‍🌈 \n" //emoji zwj sequence: Rainbow Flag
870 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
871 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
872 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
873 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
874 "two adjacent glyphs ☪️️️☪️\n" //This line should be rendered as two adjacent glyphs
875 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
876 "Surfing Medium Skin Female: 🏄🏼‍♀️"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
878 label.SetProperty( TextLabel::Property::TEXT, emojiSequences );
879 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
880 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
881 label.SetProperty( TextLabel::Property::ELLIPSIS, false);
883 application.SendNotification();
884 application.Render();
888 int UtcDaliToolkitTextlabelScrollingP(void)
890 ToolkitTestApplication application;
891 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
892 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
893 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
895 DALI_TEST_CHECK( labelImmediate );
896 DALI_TEST_CHECK( labelFinished );
897 // Avoid a crash when core load gl resources.
898 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
899 application.GetScene().Add( labelImmediate );
900 // Turn on all the effects
901 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
902 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
903 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
904 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
905 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
907 application.GetScene().Add( labelFinished );
908 // Turn on all the effects
909 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
910 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
911 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
912 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
913 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
919 // Render some text with the shared atlas backend
920 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
921 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
923 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
924 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
926 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
927 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
928 application.SendNotification();
929 application.Render();
931 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
932 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
933 application.SendNotification();
934 application.Render();
939 tet_result(TET_FAIL);
945 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
947 ToolkitTestApplication application;
948 TextLabel labelShort = TextLabel::New("Some text to scroll");
949 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!");
951 DALI_TEST_CHECK( labelShort );
952 DALI_TEST_CHECK( labelLong );
953 // Avoid a crash when core load gl resources.
954 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
955 application.GetScene().Add( labelShort );
956 // Turn on all the effects
957 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
958 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
959 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
960 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
961 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
962 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
964 application.GetScene().Add( labelLong );
965 // Turn on all the effects
966 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
967 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
968 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
969 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
970 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
971 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
975 // Render some text with the shared atlas backend
976 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
977 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
978 application.SendNotification();
979 application.Render();
981 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
982 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
983 application.SendNotification();
984 application.Render();
989 tet_result(TET_FAIL);
995 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
997 ToolkitTestApplication application;
998 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
999 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1001 DALI_TEST_CHECK( labelShort );
1002 DALI_TEST_CHECK( labelLong );
1003 // Avoid a crash when core load gl resources.
1004 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1005 application.GetScene().Add( labelShort );
1006 // Turn on all the effects
1007 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1008 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1009 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1010 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1011 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1012 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1014 application.GetScene().Add( labelLong );
1015 // Turn on all the effects
1016 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1017 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1018 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1019 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1020 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1021 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1025 // Render some text with the shared atlas backend
1026 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1027 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1028 application.SendNotification();
1029 application.Render();
1031 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1032 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1033 application.SendNotification();
1034 application.Render();
1039 tet_result(TET_FAIL);
1045 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1047 ToolkitTestApplication application;
1048 TextLabel labelShort = TextLabel::New("Some text to scroll");
1049 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!");
1051 DALI_TEST_CHECK( labelShort );
1052 DALI_TEST_CHECK( labelLong );
1053 // Avoid a crash when core load gl resources.
1054 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1055 application.GetScene().Add( labelShort );
1056 // Turn on all the effects
1057 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1058 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1059 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1060 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1061 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1062 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1064 application.GetScene().Add( labelLong );
1065 // Turn on all the effects
1066 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1067 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1068 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1069 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1070 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1071 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1075 // Render some text with the shared atlas backend
1076 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1077 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1078 application.SendNotification();
1079 application.Render();
1081 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1082 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1083 application.SendNotification();
1084 application.Render();
1089 tet_result(TET_FAIL);
1095 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1097 ToolkitTestApplication application;
1098 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1099 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1101 DALI_TEST_CHECK( labelShort );
1102 DALI_TEST_CHECK( labelLong );
1103 // Avoid a crash when core load gl resources.
1104 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1105 application.GetScene().Add( labelShort );
1106 // Turn on all the effects
1107 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1108 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1109 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1110 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1111 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1112 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1114 application.GetScene().Add( labelLong );
1115 // Turn on all the effects
1116 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1117 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1118 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1119 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1120 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1121 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1125 // Render some text with the shared atlas backend
1126 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1127 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1128 application.SendNotification();
1129 application.Render();
1131 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1132 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1133 application.SendNotification();
1134 application.Render();
1139 tet_result(TET_FAIL);
1145 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1147 ToolkitTestApplication application;
1148 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1149 TextLabel label = TextLabel::New("Some text to scroll");
1150 DALI_TEST_CHECK( label );
1151 // Avoid a crash when core load gl resources.
1152 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1153 application.GetScene().Add( label );
1154 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1155 // Turn on all the effects
1156 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1157 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1158 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1159 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1162 application.SendNotification();
1163 application.Render();
1165 unsigned int actorCount1 = label.GetChildCount();
1166 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1170 // Render some text with the shared atlas backend
1171 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1172 application.SendNotification();
1173 application.Render(2000);
1175 unsigned int actorCount1 = label.GetChildCount();
1176 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1178 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1181 application.SendNotification();
1182 application.Render();
1184 unsigned int actorCount2 = label.GetChildCount();
1185 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1187 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1192 tet_result(TET_FAIL);
1198 int UtcDaliToolkitTextlabelScrollingN(void)
1200 ToolkitTestApplication application;
1201 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1203 TextLabel label = TextLabel::New("Some text to scroll");
1204 DALI_TEST_CHECK( label );
1206 application.GetScene().Add( label );
1208 // Avoid a crash when core load gl resources.
1209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1211 // The text scrolling works only on single line text.
1212 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1214 // Turn on all the effects.
1215 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1216 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1217 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1219 // Enable the auto scrolling effect.
1220 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1222 // The auto scrolling shouldn't be enabled.
1223 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1224 DALI_TEST_CHECK( !enabled );
1229 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1231 ToolkitTestApplication application;
1232 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1234 TextLabel label = TextLabel::New("Some text to scroll");
1235 DALI_TEST_CHECK( label );
1237 application.GetScene().Add( label );
1239 // Avoid a crash when core load gl resources.
1240 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1242 // Turn on all the effects.
1243 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1244 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1245 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1249 // Enable the auto scrolling effect.
1250 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1251 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1253 // Disable the ellipsis
1254 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1257 application.SendNotification();
1258 application.Render();
1260 // Stop auto scrolling
1261 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1263 // Check the ellipsis property
1264 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1268 tet_result(TET_FAIL);
1274 int UtcDaliToolkitTextlabelEllipsis(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1279 TextLabel label = TextLabel::New("Hello world");
1280 DALI_TEST_CHECK( label );
1282 // Avoid a crash when core load gl resources.
1283 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1285 application.GetScene().Add( label );
1287 // Turn on all the effects
1288 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1289 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1290 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1295 application.SendNotification();
1296 application.Render();
1300 tet_result(TET_FAIL);
1303 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1304 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1305 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1310 application.SendNotification();
1311 application.Render();
1315 tet_result(TET_FAIL);
1319 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1320 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1321 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1326 application.SendNotification();
1327 application.Render();
1331 tet_result(TET_FAIL);
1337 int UtcDaliToolkitTextlabelTextWrapMode(void)
1339 ToolkitTestApplication application;
1340 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1344 TextLabel label = TextLabel::New();
1345 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1346 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1347 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1351 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1352 application.GetScene().Add( label );
1354 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1355 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1357 application.SendNotification();
1358 application.Render();
1360 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1361 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1363 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1364 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1366 application.SendNotification();
1367 application.Render();
1369 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1370 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1372 application.SendNotification();
1373 application.Render();
1375 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1376 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1378 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1379 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1381 application.SendNotification();
1382 application.Render();
1384 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1385 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1387 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1388 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1389 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1394 int UtcDaliToolkitTextLabelColorComponents(void)
1396 ToolkitTestApplication application;
1398 TextLabel label = TextLabel::New();
1399 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1400 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1401 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1402 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1403 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1405 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1406 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1407 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1409 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1411 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1412 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1413 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1417 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1418 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1419 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1421 // Test a transparent text - Rendering should be skipped.
1422 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1423 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1425 application.GetScene().Add( label );
1427 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1428 drawTrace.Enable( true );
1430 application.SendNotification();
1431 application.Render();
1433 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1435 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1444 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1448 application.SendNotification();
1449 application.Render();
1451 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1456 int UtcDaliToolkitTextlabelTextStyle01(void)
1458 ToolkitTestApplication application;
1459 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1461 TextLabel label = TextLabel::New();
1462 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1463 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1464 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1465 application.GetScene().Add( label );
1467 Property::Map outlineMapSet;
1468 Property::Map outlineMapGet;
1470 outlineMapSet["color"] = Color::BLUE;
1471 outlineMapSet["width"] = 2.0f;
1472 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1474 application.SendNotification();
1475 application.Render();
1477 Property::Map shadowMapSet;
1478 shadowMapSet.Insert( "color", "green" );
1479 shadowMapSet.Insert( "offset", "2 2" );
1480 shadowMapSet.Insert( "blurRadius", "3" );
1481 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1483 outlineMapSet["color"] = Color::RED;
1484 outlineMapSet["width"] = 0.0f;
1485 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1487 application.SendNotification();
1488 application.Render();
1490 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1492 Property::Value* colorValue = outlineMapGet.Find("color");
1494 bool colorMatched( false );
1498 Property::Type valueType = colorValue->GetType();
1500 if ( Property::STRING == valueType )
1502 std::string stringValue;
1503 colorValue->Get( stringValue );
1504 if ( stringValue == "red" )
1506 colorMatched = true;
1509 else if ( Property::VECTOR4 == valueType )
1511 Vector4 colorVector4;
1512 colorValue->Get( colorVector4 );
1513 if ( colorVector4 == Color::RED )
1515 colorMatched = true;
1520 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1525 int UtcDaliToolkitTextlabelMultiline(void)
1527 ToolkitTestApplication application;
1528 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1530 TextLabel label = TextLabel::New();
1531 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1532 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1533 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1534 application.GetScene().Add( label );
1536 application.SendNotification();
1537 application.Render();
1539 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1540 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1542 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1544 application.SendNotification();
1545 application.Render();
1547 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1548 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1554 int UtcDaliToolkitTextlabelTextDirection(void)
1556 ToolkitTestApplication application;
1557 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1559 TextLabel label = TextLabel::New();
1560 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1562 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1563 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1564 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1565 application.GetScene().Add( label );
1568 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1571 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1572 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1574 // Test RTL text starting with weak character
1575 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1576 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1578 // Test RTL text string with emoji and weak character
1579 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1580 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1585 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1587 ToolkitTestApplication application;
1588 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1590 TextLabel label = TextLabel::New();
1592 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1593 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1594 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1595 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1596 application.GetScene().Add( label );
1597 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1599 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1600 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1602 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1603 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1608 int UtcDaliToolkitTextLabelBitmapFont(void)
1610 ToolkitTestApplication application;
1611 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1613 DevelText::BitmapFontDescription fontDescription;
1614 fontDescription.name = "Digits";
1615 fontDescription.underlinePosition = 0.f;
1616 fontDescription.underlineThickness = 0.f;
1618 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1619 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1620 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1621 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1622 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1623 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1624 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1625 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1626 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1627 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1628 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1630 TextAbstraction::BitmapFont bitmapFont;
1631 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1633 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1634 fontClient.GetFontId( bitmapFont );
1636 TextLabel label = TextLabel::New();
1638 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1639 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1641 // 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.
1642 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1644 application.GetScene().Add( label );
1646 application.SendNotification();
1647 application.Render();
1649 // The text has been rendered if the height of the text-label is the height of the line.
1650 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1655 int ConvertPointToPixel( float point )
1657 unsigned int horizontalDpi = 0u;
1658 unsigned int verticalDpi = 0u;
1659 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1660 fontClient.GetDpi( horizontalDpi, verticalDpi );
1662 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1665 int UtcDaliToolkitTextlabelTextFit(void)
1667 ToolkitTestApplication application;
1668 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1669 TextLabel label = TextLabel::New();
1670 Vector2 size( 460.0f, 100.0f );
1671 label.SetProperty( Actor::Property::SIZE, size );
1672 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1674 // connect to the text git changed signal.
1675 ConnectionTracker* testTracker = new ConnectionTracker();
1676 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1677 bool textFitChangedSignal = false;
1678 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1679 gTextFitChangedCallBackCalled = false;
1682 Property::Map textFitMapSet;
1683 textFitMapSet["enable"] = true;
1684 textFitMapSet["minSize"] = 10.f;
1685 textFitMapSet["maxSize"] = 100.f;
1686 textFitMapSet["stepSize"] = -1.f;
1687 textFitMapSet["fontSizeType"] = "pointSize";
1689 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1690 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1692 application.GetScene().Add( label );
1694 application.SendNotification();
1695 application.Render();
1697 const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1698 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1700 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1701 DALI_TEST_CHECK(textFitChangedSignal);
1704 textFitMapSet.Clear();
1705 textFitMapSet["enable"] = true;
1706 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1707 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1708 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1709 textFitMapSet["fontSizeType"] = "pixelSize";
1711 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1713 application.SendNotification();
1714 application.Render();
1716 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1721 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1723 ToolkitTestApplication application;
1724 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1726 DevelText::BitmapFontDescription fontDescription;
1727 fontDescription.name = "Digits";
1728 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1730 TextAbstraction::BitmapFont bitmapFont;
1731 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1733 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1734 fontClient.GetFontId( bitmapFont );
1736 TextLabel label = TextLabel::New();
1737 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1738 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1739 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1740 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1741 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1743 Property::Map underlineMapSet;
1744 underlineMapSet.Clear();
1745 underlineMapSet.Insert( "enable", true );
1746 underlineMapSet.Insert( "color", Color::RED );
1747 underlineMapSet.Insert( "height", 1 );
1748 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1749 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1751 application.GetScene().Add( label );
1753 application.SendNotification();
1754 application.Render();
1756 const int maxTextureSize = Dali::GetMaxTextureSize();
1757 // Whether the rendered text is greater than maxTextureSize
1758 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1760 // Check if the number of renderers is greater than 1.
1761 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1766 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1768 ToolkitTestApplication application;
1769 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1771 Vector2 size( 300.0f, 100.0f );
1773 Dali::Toolkit::DevelText::RendererParameters textParameters;
1774 textParameters.text = "This is a sample text to get the last index.";
1775 textParameters.layout = "multiLine";
1776 textParameters.fontSize = 20.f;
1777 textParameters.textWidth = 300u;
1778 textParameters.textHeight = 100u;
1779 textParameters.ellipsisEnabled = true;
1780 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1782 DALI_TEST_CHECK( !indexArray.Empty() );
1783 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1788 int UtcDaliToolkitTextlabelFontSizeScale(void)
1790 ToolkitTestApplication application;
1791 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1793 TextLabel label = TextLabel::New();
1794 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1795 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1796 Vector3 nonScaledSize = label.GetNaturalSize();
1798 TextLabel labelScaled = TextLabel::New();
1799 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1800 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1801 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1802 Vector3 scaledSize = labelScaled.GetNaturalSize();
1804 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1806 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1807 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1808 nonScaledSize = label.GetNaturalSize();
1810 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1811 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1812 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1813 scaledSize = labelScaled.GetNaturalSize();
1815 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1820 // Positive test for the anchorClicked signal.
1821 int UtcDaliToolkitTextlabelAnchorClicked(void)
1823 ToolkitTestApplication application;
1824 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1825 TextLabel label = TextLabel::New();
1826 DALI_TEST_CHECK(label);
1828 application.GetScene().Add(label);
1830 // connect to the anchor clicked signal.
1831 ConnectionTracker* testTracker = new ConnectionTracker();
1832 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1833 bool anchorClickedSignal = false;
1834 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1836 gAnchorClickedCallBackCalled = false;
1837 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1838 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1839 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1840 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1841 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1843 application.SendNotification();
1844 application.Render();
1846 // Create a tap event to touch the text label.
1847 TestGenerateTap(application, 5.0f, 25.0f, 100);
1848 application.SendNotification();
1849 application.Render();
1851 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1852 DALI_TEST_CHECK(anchorClickedSignal);
1855 gAnchorClickedCallBackCalled = false;
1856 anchorClickedSignal = false;
1857 label.SetProperty(TextLabel::Property::TEXT, "");
1858 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1860 application.SendNotification();
1861 application.Render();
1864 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1865 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1866 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1867 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1868 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1870 application.SendNotification();
1871 application.Render();
1873 // Create a tap event to touch the text label.
1874 TestGenerateTap(application, 5.0f, 25.0f, 200);
1875 application.SendNotification();
1876 application.Render();
1878 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1879 DALI_TEST_CHECK(anchorClickedSignal);
1882 gAnchorClickedCallBackNotCalled = true;
1883 // Tap the outside of anchor, callback should not be called.
1884 TestGenerateTap(application, 150.f, 100.f, 300);
1885 application.SendNotification();
1886 application.Render();
1888 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1893 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1895 ToolkitTestApplication application;
1896 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1898 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1900 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1901 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1902 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1904 // Create a text editor
1905 TextLabel textLabel = TextLabel::New();
1906 //Set size to avoid automatic eliding
1907 textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1908 //Set very large font-size using point-size
1909 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1910 //Specify font-family
1911 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1912 //Set text to check if appear or not
1913 textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1915 application.GetScene().Add( textLabel );
1917 application.SendNotification();
1918 application.Render();
1919 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1920 Vector3 naturalSize = textLabel.GetNaturalSize();
1922 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1923 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1928 int UtcDaliTextLabelHyphenWrapMode(void)
1930 ToolkitTestApplication application;
1931 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1934 TextLabel label = TextLabel::New();
1935 label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1936 label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1937 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1938 application.GetScene().Add( label );
1939 application.SendNotification();
1940 application.Render();
1942 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1943 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1944 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1946 application.SendNotification();
1947 application.Render();
1949 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1955 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1957 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1958 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1959 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1961 application.SendNotification();
1962 application.Render();
1964 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1971 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1977 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1979 ToolkitTestApplication application;
1981 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1983 int lineCountBefore =0 ;
1984 int lineCountAfter =0 ;
1986 // Create a text editor
1987 TextLabel textLabel = TextLabel::New();
1988 //Set very large font-size using point-size
1989 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1990 //Specify font-family
1991 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1993 textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
1994 //Set text longer than width of textLabel
1995 textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
1996 //Set line wrap mode Character
1997 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1998 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2000 application.GetScene().Add( textLabel );
2002 application.SendNotification();
2003 application.Render();
2006 lineCountBefore = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2008 textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2009 lineCountAfter = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2011 // When the text changed, the Line-count should be updated according to new text.
2012 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2013 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
2014 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
2020 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2022 ToolkitTestApplication application;
2023 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2024 TextLabel textLabel = TextLabel::New();
2026 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2027 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2029 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2030 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2031 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2033 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2034 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2035 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2037 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2038 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2039 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2041 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2042 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2043 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2045 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2046 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2047 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2049 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2050 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2051 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2053 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2054 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2055 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2057 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2058 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2059 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2061 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2062 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2063 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2065 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2066 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2067 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2069 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2070 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2071 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2073 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2074 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2075 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );