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";
77 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
81 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
82 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
84 static bool gAnchorClickedCallBackCalled;
85 static bool gAnchorClickedCallBackNotCalled;
87 static bool gTextFitChangedCallBackCalled;
89 struct CallbackFunctor
91 CallbackFunctor(bool* callbackFlag)
92 : mCallbackFlag( callbackFlag )
98 *mCallbackFlag = true;
103 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
105 tet_infoline(" TestAnchorClickedCallback");
107 gAnchorClickedCallBackNotCalled = false;
109 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
111 gAnchorClickedCallBackCalled = true;
115 static void TestTextFitChangedCallback(TextLabel control)
117 tet_infoline(" TestTextFitChangedCallback");
118 gTextFitChangedCallBackCalled = true;
121 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
123 const Property::Map::SizeType size = mapGet.Count();
125 if( size == mapSet.Count() )
127 for( unsigned int index = 0u; index < size; ++index )
129 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
131 // Find the keys of the 'get' map
132 Property::Index indexKey = valueGet.first.indexKey;
133 std::string stringKey = valueGet.first.stringKey;
135 if( !indexConversionTable.empty() )
137 if( stringKey.empty() )
139 stringKey = indexConversionTable[ indexKey ];
142 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
144 Property::Index index = 0u;
145 for( auto key : indexConversionTable )
147 if( key == stringKey )
157 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
159 if( nullptr != valueSet )
161 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
163 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
166 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
168 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
171 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
173 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
176 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
178 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
181 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
183 Vector2 vector2Get = valueGet.second.Get<Vector2>();
184 Vector2 vector2Set = valueSet->Get<Vector2>();
185 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
188 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
190 Vector4 vector4Get = valueGet.second.Get<Vector4>();
191 Vector4 vector4Set = valueSet->Get<Vector4>();
192 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 );
198 if ( valueGet.first.type == Property::Key::INDEX )
200 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
204 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
216 int UtcDaliToolkitTextLabelConstructorP(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
221 DALI_TEST_CHECK( !textLabel );
225 int UtcDaliToolkitTextLabelNewP(void)
227 ToolkitTestApplication application;
228 tet_infoline(" UtcDaliToolkitTextLabelNewP");
229 TextLabel textLabel = TextLabel::New( "Test Text" );
230 DALI_TEST_CHECK( textLabel );
234 int UtcDaliToolkitTextLabelDownCastP(void)
236 ToolkitTestApplication application;
237 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
238 TextLabel textLabel1 = TextLabel::New();
239 BaseHandle object( textLabel1 );
241 TextLabel textLabel2 = TextLabel::DownCast( object );
242 DALI_TEST_CHECK( textLabel2 );
244 TextLabel textLabel3 = DownCast< TextLabel >( object );
245 DALI_TEST_CHECK( textLabel3 );
249 int UtcDaliToolkitTextLabelDownCastN(void)
251 ToolkitTestApplication application;
252 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
253 BaseHandle uninitializedObject;
254 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
255 DALI_TEST_CHECK( !textLabel1 );
257 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
258 DALI_TEST_CHECK( !textLabel2 );
262 int UtcDaliToolkitTextLabelCopyConstructorP(void)
264 ToolkitTestApplication application;
265 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
266 TextLabel textLabel = TextLabel::New();
267 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
269 TextLabel copy( textLabel );
270 DALI_TEST_CHECK( copy );
271 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
275 int UtcDaliTextLabelMoveConstructor(void)
277 ToolkitTestApplication application;
279 TextLabel textLabel = TextLabel::New();
280 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
281 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
283 TextLabel moved = std::move( textLabel );
284 DALI_TEST_CHECK( moved );
285 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
286 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
287 DALI_TEST_CHECK( !textLabel );
292 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
294 ToolkitTestApplication application;
295 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
296 TextLabel textLabel = TextLabel::New();
297 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
299 TextLabel copy = textLabel;
300 DALI_TEST_CHECK( copy );
301 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
305 int UtcDaliTextLabelMoveAssignment(void)
307 ToolkitTestApplication application;
309 TextLabel textLabel = TextLabel::New();
310 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
311 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
314 moved = std::move( textLabel );
315 DALI_TEST_CHECK( moved );
316 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
317 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
318 DALI_TEST_CHECK( !textLabel );
323 // Positive test case for a method
324 int UtcDaliToolkitTextLabelGetPropertyP(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
328 TextLabel label = TextLabel::New("Test Text");
329 DALI_TEST_CHECK( label );
331 // Check Property Indices are correct
332 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
333 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
334 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
335 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
336 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
337 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
338 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
339 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
340 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
341 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
342 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
343 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
344 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
345 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
346 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
347 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
348 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
349 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
350 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
351 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
352 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
353 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
354 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
355 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
356 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE );
357 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
362 int UtcDaliToolkitTextLabelSetPropertyP(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
366 TextLabel label = TextLabel::New();
367 DALI_TEST_CHECK( label );
369 application.GetScene().Add( label );
371 // Note - we can't check the defaults since the stylesheets are platform-specific
372 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
373 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
375 // Check that text can be correctly reset
376 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
377 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
379 // Check font properties.
380 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
381 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
383 Property::Map fontStyleMapSet;
384 Property::Map fontStyleMapGet;
386 fontStyleMapSet.Insert( "weight", "bold" );
387 fontStyleMapSet.Insert( "width", "condensed" );
388 fontStyleMapSet.Insert( "slant", "italic" );
389 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
391 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
392 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
393 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
395 // Check the old font style format.
396 fontStyleMapSet.Clear();
397 fontStyleMapSet.Insert( "weight", "thin" );
398 fontStyleMapSet.Insert( "width", "expanded" );
399 fontStyleMapSet.Insert( "slant", "oblique" );
400 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
402 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
403 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
404 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
406 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
407 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
409 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
410 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
411 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
413 label.SetProperty( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false );
414 DALI_TEST_EQUALS( label.GetProperty<bool>( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
415 label.SetProperty( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true );
418 fontStyleMapSet.Clear();
419 fontStyleMapSet.Insert( "weight", "normal" );
420 fontStyleMapSet.Insert( "slant", "oblique" );
422 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
423 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
424 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
425 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
427 fontStyleMapSet.Clear();
428 fontStyleMapSet.Insert( "slant", "roman" );
430 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
431 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
432 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
434 // Replace 'roman' for 'normal'.
435 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
436 if( NULL != slantValue )
438 if( "normal" == slantValue->Get<std::string>() )
440 fontStyleMapGet["slant"] = "roman";
443 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
445 fontStyleMapSet.Clear();
447 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
448 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
449 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
450 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
453 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
454 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
456 // Check that the Alignment properties can be correctly set
457 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
458 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
459 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
460 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
462 // Check that text color can be properly set
463 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
464 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
466 Property::Map underlineMapSet;
467 Property::Map underlineMapGet;
469 underlineMapSet.Insert( "enable", false );
470 underlineMapSet.Insert( "color", Color::BLUE );
471 underlineMapSet.Insert( "height", 0 );
473 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
474 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
475 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
477 TextLabel label2 = TextLabel::New( "New text" );
478 DALI_TEST_CHECK( label2 );
479 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
481 // Check the enable markup property.
482 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
483 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
484 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
486 // Check the text property when markup is enabled
487 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
488 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
490 // Check for incomplete marks.
491 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
492 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
495 application.SendNotification();
496 application.Render();
500 tet_result(TET_FAIL);
503 // Check autoscroll properties
504 const int SCROLL_SPEED = 80;
505 const int SCROLL_LOOPS = 4;
506 const float SCROLL_GAP = 50.0f;
507 const float SCROLL_LOOP_DELAY = 0.3f;
508 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
509 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
511 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
512 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
513 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
514 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
515 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
516 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
517 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
518 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
519 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
520 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
521 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
522 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
524 //Check autoscroll stop type property
525 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
526 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
528 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
529 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
531 // test natural size with multi-line and line spacing
533 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
534 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
535 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
536 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
537 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
539 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
540 // The height of the text when multi-line is enabled will be larger
541 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
542 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
544 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
545 // Everything else will remain the same
546 int lineSpacing = 20;
547 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
548 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
549 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
550 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
553 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
555 TextLabel label3 = TextLabel::New("Some text here end there end here");
556 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
557 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
558 Vector3 textNaturalSize = label3.GetNaturalSize();
559 int lineSpacing = 20;
560 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
561 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
562 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
563 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
565 // Check the line spacing property
566 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
567 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
568 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
570 // Check the underline property
571 underlineMapSet.Clear();
572 underlineMapSet.Insert( "enable", true );
573 underlineMapSet.Insert( "color", Color::RED );
574 underlineMapSet.Insert( "height", 1 );
576 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
578 application.SendNotification();
579 application.Render();
581 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
582 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
583 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
585 underlineMapSet.Clear();
586 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
587 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
588 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
590 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
592 application.SendNotification();
593 application.Render();
595 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
596 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
597 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
598 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
600 underlineMapSet.Clear();
602 Property::Map underlineDisabledMapGet;
603 underlineDisabledMapGet.Insert( "enable", false );
604 underlineDisabledMapGet.Insert( "color", Color::GREEN );
605 underlineDisabledMapGet.Insert( "height", 2 );
607 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
609 application.SendNotification();
610 application.Render();
612 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
613 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
616 // Check the shadow property
618 Property::Map shadowMapSet;
619 Property::Map shadowMapGet;
621 shadowMapSet.Insert( "color", Color::GREEN );
622 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
623 shadowMapSet.Insert( "blurRadius", 5.0f );
625 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
627 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
628 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
631 shadowMapSet.Clear();
633 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
634 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
635 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
637 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
639 // Replace the offset (string) by a vector2
640 shadowMapSet.Clear();
641 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
642 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
643 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
645 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
646 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
647 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
648 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
650 shadowMapSet.Clear();
651 Property::Map shadowDisabledMapGet;
652 shadowDisabledMapGet.Insert( "color", Color::BLUE );
653 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
654 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
656 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
658 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
659 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
660 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
662 // Check the emboss property
663 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
664 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
666 // Check the outline property
668 // Test string type first
669 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
670 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
671 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
673 // Then test the property map type
674 Property::Map outlineMapSet;
675 Property::Map outlineMapGet;
677 outlineMapSet["color"] = Color::RED;
678 outlineMapSet["width"] = 2.0f;
679 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
681 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
682 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
683 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
685 outlineMapSet.Clear();
686 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
687 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
688 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
690 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
691 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
692 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
693 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
695 // Check the background property
696 Property::Map backgroundMapSet;
697 Property::Map backgroundMapGet;
699 backgroundMapSet["enable"] = true;
700 backgroundMapSet["color"] = Color::RED;
701 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
703 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
704 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
705 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
707 backgroundMapSet.Clear();
708 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
709 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
710 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
712 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
713 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
714 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
715 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
717 // Check the pixel size of font
718 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
719 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
721 // Check the ellipsis property
722 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
723 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
724 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
726 // Check the layout direction property
727 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
728 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
730 // Check the line size property
731 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
732 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
733 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
735 application.SendNotification();
736 application.Render();
741 int UtcDaliToolkitTextlabelAtlasRenderP(void)
743 ToolkitTestApplication application;
744 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
745 TextLabel label = TextLabel::New("Test Text");
746 DALI_TEST_CHECK( label );
748 // Avoid a crash when core load gl resources.
749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
751 application.GetScene().Add( label );
753 // Turn on all the effects
754 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
755 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
757 Property::Map underlineMap;
758 underlineMap.Insert( "enable", true );
759 underlineMap.Insert( "color", Color::RED );
760 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
762 Property::Map shadowMap;
763 shadowMap.Insert( "color", Color::BLUE );
764 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
765 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
769 // Render some text with the shared atlas backend
770 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
771 application.SendNotification();
772 application.Render();
776 tet_result(TET_FAIL);
781 // Render some text with the shared atlas backend
782 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
783 application.SendNotification();
784 application.Render();
788 tet_result(TET_FAIL);
793 int UtcDaliToolkitTextLabelLanguagesP(void)
795 ToolkitTestApplication application;
796 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
797 TextLabel label = TextLabel::New();
798 DALI_TEST_CHECK( label );
800 application.GetScene().Add( label );
802 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
803 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
804 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
805 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
806 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
807 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
809 label.SetProperty( TextLabel::Property::TEXT, scripts );
810 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
812 application.SendNotification();
813 application.Render();
818 int UtcDaliToolkitTextLabelEmojisP(void)
820 ToolkitTestApplication application;
821 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
822 TextLabel label = TextLabel::New();
823 DALI_TEST_CHECK( label );
825 application.GetScene().Add( label );
827 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
829 char* pathNamePtr = get_current_dir_name();
830 const std::string pathName( pathNamePtr );
833 TextAbstraction::FontDescription fontDescription;
834 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
835 fontDescription.family = "BreezeColorEmoji";
836 fontDescription.width = TextAbstraction::FontWidth::NONE;
837 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
838 fontDescription.slant = TextAbstraction::FontSlant::NONE;
840 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
842 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>";
843 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
844 label.SetProperty( TextLabel::Property::TEXT, emojis );
846 Property::Map shadowMap;
847 shadowMap.Insert( "color", "green" );
848 shadowMap.Insert( "offset", "2 2" );
849 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
851 application.SendNotification();
852 application.Render();
854 // EMOJI + ZWJ + EMOJI case for coverage.
855 const std::string emojiWithZWJ = "👩‍🔬";
856 label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
858 application.SendNotification();
859 application.Render();
861 // EMOJI Sequences case for coverage.
862 std::string emojiSequences =
863 "Text VS15 ☪︎\n" //text presentation sequence and selector
864 "Color VS16 ☪️\n" //emoji presentation sequence and selector
865 "Default ☪ \n" //default presentation
866 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
867 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
868 "WomanScientistLightSkinTone👩🏻‍🔬 \n" //emoji modifier sequence: skin tone & JWZ
869 "LeftRightArrowText↔︎\n" //text presentation sequence and selector
870 "LeftRightArrowEmoji↔️\n" //emoji presentation sequence and selector
871 "SouthKoreaFlag🇰🇷\n" //emoji flag sequence
872 "JordanFlag🇯🇴\n" // emoji flag sequence
873 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" //emoji tag sequence like England flag
874 "Runner 🏃‍➡️ \n"
875 "VictoryHandMediumLightSkinTone:✌️🏼\n" //emoji modifier sequence: skin tone
876 "RainbowFlag:🏳️‍🌈 \n" //emoji zwj sequence: Rainbow Flag
877 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
878 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
879 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
880 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
881 "two adjacent glyphs ☪️️️☪️\n" //This line should be rendered as two adjacent glyphs
882 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
883 "Surfing Medium Skin Female: 🏄🏼‍♀️"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
885 label.SetProperty( TextLabel::Property::TEXT, emojiSequences );
886 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
887 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
888 label.SetProperty( TextLabel::Property::ELLIPSIS, false);
890 application.SendNotification();
891 application.Render();
895 int UtcDaliToolkitTextlabelScrollingP(void)
897 ToolkitTestApplication application;
898 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
899 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
900 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
902 DALI_TEST_CHECK( labelImmediate );
903 DALI_TEST_CHECK( labelFinished );
904 // Avoid a crash when core load gl resources.
905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
906 application.GetScene().Add( labelImmediate );
907 // Turn on all the effects
908 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
909 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
910 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
911 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
912 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
914 application.GetScene().Add( labelFinished );
915 // Turn on all the effects
916 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
917 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
918 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
919 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
920 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
926 // Render some text with the shared atlas backend
927 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
928 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
930 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
931 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
933 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
934 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
935 application.SendNotification();
936 application.Render();
938 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
939 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
940 application.SendNotification();
941 application.Render();
946 tet_result(TET_FAIL);
952 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
954 ToolkitTestApplication application;
955 TextLabel labelShort = TextLabel::New("Some text to scroll");
956 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!");
958 DALI_TEST_CHECK( labelShort );
959 DALI_TEST_CHECK( labelLong );
960 // Avoid a crash when core load gl resources.
961 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
962 application.GetScene().Add( labelShort );
963 // Turn on all the effects
964 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
965 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
966 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
967 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
968 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
969 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
971 application.GetScene().Add( labelLong );
972 // Turn on all the effects
973 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
974 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
975 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
976 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
977 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
978 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
982 // Render some text with the shared atlas backend
983 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
984 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
985 application.SendNotification();
986 application.Render();
988 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
989 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
990 application.SendNotification();
991 application.Render();
996 tet_result(TET_FAIL);
1002 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1004 ToolkitTestApplication application;
1005 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1006 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1008 DALI_TEST_CHECK( labelShort );
1009 DALI_TEST_CHECK( labelLong );
1010 // Avoid a crash when core load gl resources.
1011 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1012 application.GetScene().Add( labelShort );
1013 // Turn on all the effects
1014 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1015 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1016 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1017 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1018 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1019 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1021 application.GetScene().Add( labelLong );
1022 // Turn on all the effects
1023 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1024 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1025 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1026 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1027 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1028 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1032 // Render some text with the shared atlas backend
1033 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1034 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1035 application.SendNotification();
1036 application.Render();
1038 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1039 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1040 application.SendNotification();
1041 application.Render();
1046 tet_result(TET_FAIL);
1052 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1054 ToolkitTestApplication application;
1055 TextLabel labelShort = TextLabel::New("Some text to scroll");
1056 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!");
1058 DALI_TEST_CHECK( labelShort );
1059 DALI_TEST_CHECK( labelLong );
1060 // Avoid a crash when core load gl resources.
1061 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1062 application.GetScene().Add( labelShort );
1063 // Turn on all the effects
1064 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1065 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1066 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1067 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1068 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1069 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1071 application.GetScene().Add( labelLong );
1072 // Turn on all the effects
1073 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1074 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1075 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1076 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1077 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1078 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1082 // Render some text with the shared atlas backend
1083 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1084 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1085 application.SendNotification();
1086 application.Render();
1088 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1089 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1090 application.SendNotification();
1091 application.Render();
1096 tet_result(TET_FAIL);
1102 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1104 ToolkitTestApplication application;
1105 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1106 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1108 DALI_TEST_CHECK( labelShort );
1109 DALI_TEST_CHECK( labelLong );
1110 // Avoid a crash when core load gl resources.
1111 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1112 application.GetScene().Add( labelShort );
1113 // Turn on all the effects
1114 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1115 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1116 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1117 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1118 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1119 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1121 application.GetScene().Add( labelLong );
1122 // Turn on all the effects
1123 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1124 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1125 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1126 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1127 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1128 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1132 // Render some text with the shared atlas backend
1133 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1134 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1135 application.SendNotification();
1136 application.Render();
1138 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1139 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1140 application.SendNotification();
1141 application.Render();
1146 tet_result(TET_FAIL);
1152 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1154 ToolkitTestApplication application;
1155 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1156 TextLabel label = TextLabel::New("Some text to scroll");
1157 DALI_TEST_CHECK( label );
1158 // Avoid a crash when core load gl resources.
1159 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1160 application.GetScene().Add( label );
1161 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1162 // Turn on all the effects
1163 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1164 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1165 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1166 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1169 application.SendNotification();
1170 application.Render();
1172 unsigned int actorCount1 = label.GetChildCount();
1173 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1177 // Render some text with the shared atlas backend
1178 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1179 application.SendNotification();
1180 application.Render(2000);
1182 unsigned int actorCount1 = label.GetChildCount();
1183 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1185 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1188 application.SendNotification();
1189 application.Render();
1191 unsigned int actorCount2 = label.GetChildCount();
1192 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1194 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1199 tet_result(TET_FAIL);
1205 int UtcDaliToolkitTextlabelScrollingN(void)
1207 ToolkitTestApplication application;
1208 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1210 TextLabel label = TextLabel::New("Some text to scroll");
1211 DALI_TEST_CHECK( label );
1213 application.GetScene().Add( label );
1215 // Avoid a crash when core load gl resources.
1216 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1218 // The text scrolling works only on single line text.
1219 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1221 // Turn on all the effects.
1222 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1223 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1224 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1226 // Enable the auto scrolling effect.
1227 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1229 // The auto scrolling shouldn't be enabled.
1230 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1231 DALI_TEST_CHECK( !enabled );
1236 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1238 ToolkitTestApplication application;
1239 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1241 TextLabel label = TextLabel::New("Some text to scroll");
1242 DALI_TEST_CHECK( label );
1244 application.GetScene().Add( label );
1246 // Avoid a crash when core load gl resources.
1247 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1249 // Turn on all the effects.
1250 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1251 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1252 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1256 // Enable the auto scrolling effect.
1257 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1258 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1260 // Disable the ellipsis
1261 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1264 application.SendNotification();
1265 application.Render();
1267 // Stop auto scrolling
1268 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1270 // Check the ellipsis property
1271 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1275 tet_result(TET_FAIL);
1281 int UtcDaliToolkitTextlabelEllipsis(void)
1283 ToolkitTestApplication application;
1284 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1286 TextLabel label = TextLabel::New("Hello world");
1287 DALI_TEST_CHECK( label );
1289 // Avoid a crash when core load gl resources.
1290 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1292 application.GetScene().Add( label );
1294 // Turn on all the effects
1295 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1296 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1297 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1302 application.SendNotification();
1303 application.Render();
1307 tet_result(TET_FAIL);
1310 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1311 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1312 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1317 application.SendNotification();
1318 application.Render();
1322 tet_result(TET_FAIL);
1326 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1327 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1328 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1333 application.SendNotification();
1334 application.Render();
1338 tet_result(TET_FAIL);
1344 int UtcDaliToolkitTextlabelTextWrapMode(void)
1346 ToolkitTestApplication application;
1347 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1351 TextLabel label = TextLabel::New();
1352 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1353 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1354 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1358 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1359 application.GetScene().Add( label );
1361 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1362 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1364 application.SendNotification();
1365 application.Render();
1367 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1368 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1370 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1371 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1373 application.SendNotification();
1374 application.Render();
1376 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1377 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1379 application.SendNotification();
1380 application.Render();
1382 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1383 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1385 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1386 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1388 application.SendNotification();
1389 application.Render();
1391 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1392 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1394 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1395 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1396 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1401 int UtcDaliToolkitTextLabelColorComponents(void)
1403 ToolkitTestApplication application;
1405 TextLabel label = TextLabel::New();
1406 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1407 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.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::GREEN );
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 ), 1.0f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.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, Color::BLUE );
1419 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1420 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1421 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1422 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1424 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1425 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1426 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1428 // Test a transparent text - Rendering should be skipped.
1429 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1430 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1432 application.GetScene().Add( label );
1434 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1435 drawTrace.Enable( true );
1437 application.SendNotification();
1438 application.Render();
1440 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1442 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1451 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1455 application.SendNotification();
1456 application.Render();
1458 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1463 int UtcDaliToolkitTextlabelTextStyle01(void)
1465 ToolkitTestApplication application;
1466 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1468 TextLabel label = TextLabel::New();
1469 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1470 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1471 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1472 application.GetScene().Add( label );
1474 Property::Map outlineMapSet;
1475 Property::Map outlineMapGet;
1477 outlineMapSet["color"] = Color::BLUE;
1478 outlineMapSet["width"] = 2.0f;
1479 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1481 application.SendNotification();
1482 application.Render();
1484 Property::Map shadowMapSet;
1485 shadowMapSet.Insert( "color", "green" );
1486 shadowMapSet.Insert( "offset", "2 2" );
1487 shadowMapSet.Insert( "blurRadius", "3" );
1488 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1490 outlineMapSet["color"] = Color::RED;
1491 outlineMapSet["width"] = 0.0f;
1492 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1494 application.SendNotification();
1495 application.Render();
1497 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1499 Property::Value* colorValue = outlineMapGet.Find("color");
1501 bool colorMatched( false );
1505 Property::Type valueType = colorValue->GetType();
1507 if ( Property::STRING == valueType )
1509 std::string stringValue;
1510 colorValue->Get( stringValue );
1511 if ( stringValue == "red" )
1513 colorMatched = true;
1516 else if ( Property::VECTOR4 == valueType )
1518 Vector4 colorVector4;
1519 colorValue->Get( colorVector4 );
1520 if ( colorVector4 == Color::RED )
1522 colorMatched = true;
1527 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1532 int UtcDaliToolkitTextlabelMultiline(void)
1534 ToolkitTestApplication application;
1535 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1537 TextLabel label = TextLabel::New();
1538 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1539 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1540 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1541 application.GetScene().Add( label );
1543 application.SendNotification();
1544 application.Render();
1546 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1547 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1549 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1551 application.SendNotification();
1552 application.Render();
1554 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1555 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1561 int UtcDaliToolkitTextlabelTextDirection(void)
1563 ToolkitTestApplication application;
1564 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1566 TextLabel label = TextLabel::New();
1567 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1569 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1570 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1571 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1572 application.GetScene().Add( label );
1575 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1578 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1579 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1581 // Test RTL text starting with weak character
1582 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1583 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1585 // Test RTL text string with emoji and weak character
1586 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1587 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1592 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1594 ToolkitTestApplication application;
1595 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1597 TextLabel label = TextLabel::New();
1599 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1600 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1601 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1602 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1603 application.GetScene().Add( label );
1604 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1606 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1607 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1609 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1610 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1615 int UtcDaliToolkitTextLabelBitmapFont(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1620 DevelText::BitmapFontDescription fontDescription;
1621 fontDescription.name = "Digits";
1622 fontDescription.underlinePosition = 0.f;
1623 fontDescription.underlineThickness = 0.f;
1625 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1626 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1627 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1628 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1629 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1630 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1631 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1632 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1633 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1634 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1635 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1637 TextAbstraction::BitmapFont bitmapFont;
1638 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1640 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1641 fontClient.GetFontId( bitmapFont );
1643 TextLabel label = TextLabel::New();
1645 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1646 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1648 // 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.
1649 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1651 application.GetScene().Add( label );
1653 application.SendNotification();
1654 application.Render();
1656 // The text has been rendered if the height of the text-label is the height of the line.
1657 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1662 int ConvertPointToPixel( float point )
1664 unsigned int horizontalDpi = 0u;
1665 unsigned int verticalDpi = 0u;
1666 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1667 fontClient.GetDpi( horizontalDpi, verticalDpi );
1669 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1672 int UtcDaliToolkitTextlabelTextFit(void)
1674 ToolkitTestApplication application;
1675 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1676 TextLabel label = TextLabel::New();
1677 Vector2 size( 460.0f, 100.0f );
1678 label.SetProperty( Actor::Property::SIZE, size );
1679 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1681 // connect to the text git changed signal.
1682 ConnectionTracker* testTracker = new ConnectionTracker();
1683 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1684 bool textFitChangedSignal = false;
1685 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1686 gTextFitChangedCallBackCalled = false;
1689 Property::Map textFitMapSet;
1690 textFitMapSet["enable"] = true;
1691 textFitMapSet["minSize"] = 10.f;
1692 textFitMapSet["maxSize"] = 100.f;
1693 textFitMapSet["stepSize"] = -1.f;
1694 textFitMapSet["fontSizeType"] = "pointSize";
1696 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1697 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1699 application.GetScene().Add( label );
1701 application.SendNotification();
1702 application.Render();
1704 const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1705 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1707 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1708 DALI_TEST_CHECK(textFitChangedSignal);
1711 textFitMapSet.Clear();
1712 textFitMapSet["enable"] = true;
1713 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1714 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1715 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1716 textFitMapSet["fontSizeType"] = "pixelSize";
1718 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1720 application.SendNotification();
1721 application.Render();
1723 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1728 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1730 ToolkitTestApplication application;
1731 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1733 DevelText::BitmapFontDescription fontDescription;
1734 fontDescription.name = "Digits";
1735 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1737 TextAbstraction::BitmapFont bitmapFont;
1738 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1740 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1741 fontClient.GetFontId( bitmapFont );
1743 TextLabel label = TextLabel::New();
1744 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1745 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1746 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1747 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1748 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1750 Property::Map underlineMapSet;
1751 underlineMapSet.Clear();
1752 underlineMapSet.Insert( "enable", true );
1753 underlineMapSet.Insert( "color", Color::RED );
1754 underlineMapSet.Insert( "height", 1 );
1755 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1756 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1758 application.GetScene().Add( label );
1760 application.SendNotification();
1761 application.Render();
1763 const int maxTextureSize = Dali::GetMaxTextureSize();
1764 // Whether the rendered text is greater than maxTextureSize
1765 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1767 // Check if the number of renderers is greater than 1.
1768 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1773 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1775 ToolkitTestApplication application;
1776 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1778 Vector2 size( 300.0f, 100.0f );
1780 Dali::Toolkit::DevelText::RendererParameters textParameters;
1781 textParameters.text = "This is a sample text to get the last index.";
1782 textParameters.layout = "multiLine";
1783 textParameters.fontSize = 20.f;
1784 textParameters.textWidth = 300u;
1785 textParameters.textHeight = 100u;
1786 textParameters.ellipsisEnabled = true;
1787 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1789 DALI_TEST_CHECK( !indexArray.Empty() );
1790 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1795 int UtcDaliToolkitTextlabelFontSizeScale(void)
1797 ToolkitTestApplication application;
1798 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1800 TextLabel label = TextLabel::New();
1801 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1802 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1803 Vector3 nonScaledSize = label.GetNaturalSize();
1805 TextLabel labelScaled = TextLabel::New();
1806 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1807 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1808 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1809 Vector3 scaledSize = labelScaled.GetNaturalSize();
1811 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1813 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1814 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1815 nonScaledSize = label.GetNaturalSize();
1817 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1818 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1819 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1820 scaledSize = labelScaled.GetNaturalSize();
1822 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1827 // Positive test for the anchorClicked signal.
1828 int UtcDaliToolkitTextlabelAnchorClicked(void)
1830 ToolkitTestApplication application;
1831 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1832 TextLabel label = TextLabel::New();
1833 DALI_TEST_CHECK(label);
1835 application.GetScene().Add(label);
1837 // connect to the anchor clicked signal.
1838 ConnectionTracker* testTracker = new ConnectionTracker();
1839 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1840 bool anchorClickedSignal = false;
1841 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1843 gAnchorClickedCallBackCalled = false;
1844 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1845 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1846 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1847 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1848 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1850 application.SendNotification();
1851 application.Render();
1853 // Create a tap event to touch the text label.
1854 TestGenerateTap(application, 5.0f, 25.0f, 100);
1855 application.SendNotification();
1856 application.Render();
1858 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1859 DALI_TEST_CHECK(anchorClickedSignal);
1862 gAnchorClickedCallBackCalled = false;
1863 anchorClickedSignal = false;
1864 label.SetProperty(TextLabel::Property::TEXT, "");
1865 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1867 application.SendNotification();
1868 application.Render();
1871 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1872 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1873 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1874 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1875 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1877 application.SendNotification();
1878 application.Render();
1880 // Create a tap event to touch the text label.
1881 TestGenerateTap(application, 5.0f, 25.0f, 200);
1882 application.SendNotification();
1883 application.Render();
1885 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1886 DALI_TEST_CHECK(anchorClickedSignal);
1889 gAnchorClickedCallBackNotCalled = true;
1890 // Tap the outside of anchor, callback should not be called.
1891 TestGenerateTap(application, 150.f, 100.f, 300);
1892 application.SendNotification();
1893 application.Render();
1895 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1900 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1902 ToolkitTestApplication application;
1903 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1905 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1907 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1908 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1909 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1911 // Create a text editor
1912 TextLabel textLabel = TextLabel::New();
1913 //Set size to avoid automatic eliding
1914 textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1915 //Set very large font-size using point-size
1916 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1917 //Specify font-family
1918 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1919 //Set text to check if appear or not
1920 textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1922 application.GetScene().Add( textLabel );
1924 application.SendNotification();
1925 application.Render();
1926 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1927 Vector3 naturalSize = textLabel.GetNaturalSize();
1929 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1930 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1935 int UtcDaliTextLabelHyphenWrapMode(void)
1937 ToolkitTestApplication application;
1938 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1941 TextLabel label = TextLabel::New();
1942 label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1943 label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1944 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1945 application.GetScene().Add( label );
1946 application.SendNotification();
1947 application.Render();
1949 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1950 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1951 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1953 application.SendNotification();
1954 application.Render();
1956 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1962 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1964 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1965 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1966 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1968 application.SendNotification();
1969 application.Render();
1971 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1978 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1984 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1986 ToolkitTestApplication application;
1988 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1990 int lineCountBefore =0 ;
1991 int lineCountAfter =0 ;
1993 // Create a text editor
1994 TextLabel textLabel = TextLabel::New();
1995 //Set very large font-size using point-size
1996 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1997 //Specify font-family
1998 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2000 textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
2001 //Set text longer than width of textLabel
2002 textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
2003 //Set line wrap mode Character
2004 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2005 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2007 application.GetScene().Add( textLabel );
2009 application.SendNotification();
2010 application.Render();
2013 lineCountBefore = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2015 textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2016 lineCountAfter = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2018 // When the text changed, the Line-count should be updated according to new text.
2019 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2020 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
2021 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
2027 int utcDaliTextLabelGeometryRTL(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" utcDaliTextLabelGeometryRTL");
2032 TextLabel label = TextLabel::New();
2033 DALI_TEST_CHECK( label );
2035 application.GetScene().Add( label );
2037 label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2038 label.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 100.f ) );
2039 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2040 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2041 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2042 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
2043 label.SetProperty( TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
2045 // Avoid a crash when core load gl resources.
2046 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 unsigned int expectedCount = 4;
2053 unsigned int startIndex = 3;
2054 unsigned int endIndex = 24;
2056 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2057 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2059 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2060 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2062 Vector<Vector2> expectedSizes;
2063 Vector<Vector2> expectedPositions;
2065 expectedPositions.PushBack(Vector2(24, 0));
2066 expectedSizes.PushBack(Vector2(33, 25));
2068 expectedPositions.PushBack(Vector2(-1, 25));
2069 expectedSizes.PushBack(Vector2(52, 25));
2071 expectedPositions.PushBack(Vector2(-1, 50));
2072 expectedSizes.PushBack(Vector2(59, 25));
2074 expectedPositions.PushBack(Vector2(73, 75));
2075 expectedSizes.PushBack(Vector2(37, 25));
2077 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2082 int utcDaliTextLabelGeometryGlyphMiddle(void)
2084 ToolkitTestApplication application;
2085 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2087 TextLabel label = TextLabel::New();
2088 DALI_TEST_CHECK( label );
2090 application.GetScene().Add( label );
2092 label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2093 label.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2094 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2095 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2096 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2097 label.SetProperty( TextLabel::Property::TEXT, "لا تحتوي على لا" );
2099 // Avoid a crash when core load gl resources.
2100 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 unsigned int expectedCount = 1;
2107 unsigned int startIndex = 1;
2108 unsigned int endIndex = 13;
2110 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2111 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2113 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2114 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2116 Vector<Vector2> expectedSizes;
2117 Vector<Vector2> expectedPositions;
2119 expectedPositions.PushBack(Vector2(12, 0));
2120 expectedSizes.PushBack(Vector2(118, 25));
2122 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2127 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2129 ToolkitTestApplication application;
2130 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2131 TextLabel textLabel = TextLabel::New();
2133 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2134 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2136 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2137 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2138 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2140 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2141 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2142 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2144 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2145 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2146 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2148 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2149 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2150 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2152 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2153 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2154 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2156 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2157 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2158 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2160 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2161 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2162 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2164 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2165 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2166 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2168 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2169 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2170 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2172 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2173 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2174 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2176 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2177 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2178 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2180 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2181 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2182 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );