2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
35 using namespace Toolkit;
37 void dali_textlabel_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_textlabel_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
65 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE = "underline";
67 const char* const PROPERTY_NAME_SHADOW = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
72 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
73 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
74 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
75 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
77 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
79 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
80 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
82 static bool gAnchorClickedCallBackCalled;
83 static bool gAnchorClickedCallBackNotCalled;
85 static bool gTextFitChangedCallBackCalled;
87 struct CallbackFunctor
89 CallbackFunctor(bool* callbackFlag)
90 : mCallbackFlag( callbackFlag )
96 *mCallbackFlag = true;
101 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
103 tet_infoline(" TestAnchorClickedCallback");
105 gAnchorClickedCallBackNotCalled = false;
107 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
109 gAnchorClickedCallBackCalled = true;
113 static void TestTextFitChangedCallback(TextLabel control)
115 tet_infoline(" TestTextFitChangedCallback");
116 gTextFitChangedCallBackCalled = true;
119 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
121 const Property::Map::SizeType size = mapGet.Count();
123 if( size == mapSet.Count() )
125 for( unsigned int index = 0u; index < size; ++index )
127 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
129 // Find the keys of the 'get' map
130 Property::Index indexKey = valueGet.first.indexKey;
131 std::string stringKey = valueGet.first.stringKey;
133 if( !indexConversionTable.empty() )
135 if( stringKey.empty() )
137 stringKey = indexConversionTable[ indexKey ];
140 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
142 Property::Index index = 0u;
143 for( auto key : indexConversionTable )
145 if( key == stringKey )
155 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
157 if( nullptr != valueSet )
159 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
161 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
164 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
166 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
169 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
171 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
174 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
176 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
179 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
181 Vector2 vector2Get = valueGet.second.Get<Vector2>();
182 Vector2 vector2Set = valueSet->Get<Vector2>();
183 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
186 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
188 Vector4 vector4Get = valueGet.second.Get<Vector4>();
189 Vector4 vector4Set = valueSet->Get<Vector4>();
190 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
196 if ( valueGet.first.type == Property::Key::INDEX )
198 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
202 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
214 int UtcDaliToolkitTextLabelConstructorP(void)
216 ToolkitTestApplication application;
217 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
219 DALI_TEST_CHECK( !textLabel );
223 int UtcDaliToolkitTextLabelNewP(void)
225 ToolkitTestApplication application;
226 tet_infoline(" UtcDaliToolkitTextLabelNewP");
227 TextLabel textLabel = TextLabel::New( "Test Text" );
228 DALI_TEST_CHECK( textLabel );
232 int UtcDaliToolkitTextLabelDownCastP(void)
234 ToolkitTestApplication application;
235 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
236 TextLabel textLabel1 = TextLabel::New();
237 BaseHandle object( textLabel1 );
239 TextLabel textLabel2 = TextLabel::DownCast( object );
240 DALI_TEST_CHECK( textLabel2 );
242 TextLabel textLabel3 = DownCast< TextLabel >( object );
243 DALI_TEST_CHECK( textLabel3 );
247 int UtcDaliToolkitTextLabelDownCastN(void)
249 ToolkitTestApplication application;
250 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
251 BaseHandle uninitializedObject;
252 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
253 DALI_TEST_CHECK( !textLabel1 );
255 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
256 DALI_TEST_CHECK( !textLabel2 );
260 int UtcDaliToolkitTextLabelCopyConstructorP(void)
262 ToolkitTestApplication application;
263 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
264 TextLabel textLabel = TextLabel::New();
265 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
267 TextLabel copy( textLabel );
268 DALI_TEST_CHECK( copy );
269 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
273 int UtcDaliTextLabelMoveConstructor(void)
275 ToolkitTestApplication application;
277 TextLabel textLabel = TextLabel::New();
278 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
279 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
281 TextLabel moved = std::move( textLabel );
282 DALI_TEST_CHECK( moved );
283 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
284 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
285 DALI_TEST_CHECK( !textLabel );
290 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
292 ToolkitTestApplication application;
293 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
294 TextLabel textLabel = TextLabel::New();
295 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
297 TextLabel copy = textLabel;
298 DALI_TEST_CHECK( copy );
299 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
303 int UtcDaliTextLabelMoveAssignment(void)
305 ToolkitTestApplication application;
307 TextLabel textLabel = TextLabel::New();
308 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
309 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
312 moved = std::move( textLabel );
313 DALI_TEST_CHECK( moved );
314 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
315 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
316 DALI_TEST_CHECK( !textLabel );
321 // Positive test case for a method
322 int UtcDaliToolkitTextLabelGetPropertyP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
326 TextLabel label = TextLabel::New("Test Text");
327 DALI_TEST_CHECK( label );
329 // Check Property Indices are correct
330 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
331 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
332 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
333 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
334 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
335 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
336 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
337 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
338 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
339 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
340 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
341 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
342 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
343 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
344 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
345 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
346 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
347 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
348 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
349 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
350 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
351 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
352 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
353 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
354 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
359 int UtcDaliToolkitTextLabelSetPropertyP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
363 TextLabel label = TextLabel::New();
364 DALI_TEST_CHECK( label );
366 application.GetScene().Add( label );
368 // Note - we can't check the defaults since the stylesheets are platform-specific
369 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
370 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
372 // Check that text can be correctly reset
373 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
374 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
376 // Check font properties.
377 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
378 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
380 Property::Map fontStyleMapSet;
381 Property::Map fontStyleMapGet;
383 fontStyleMapSet.Insert( "weight", "bold" );
384 fontStyleMapSet.Insert( "width", "condensed" );
385 fontStyleMapSet.Insert( "slant", "italic" );
386 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
388 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
389 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
390 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
392 // Check the old font style format.
393 fontStyleMapSet.Clear();
394 fontStyleMapSet.Insert( "weight", "thin" );
395 fontStyleMapSet.Insert( "width", "expanded" );
396 fontStyleMapSet.Insert( "slant", "oblique" );
397 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
399 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
400 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
401 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
403 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
404 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
406 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
407 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
408 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
411 fontStyleMapSet.Clear();
412 fontStyleMapSet.Insert( "weight", "normal" );
413 fontStyleMapSet.Insert( "slant", "oblique" );
415 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
416 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
417 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
418 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
420 fontStyleMapSet.Clear();
421 fontStyleMapSet.Insert( "slant", "roman" );
423 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
424 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
425 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
427 // Replace 'roman' for 'normal'.
428 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
429 if( NULL != slantValue )
431 if( "normal" == slantValue->Get<std::string>() )
433 fontStyleMapGet["slant"] = "roman";
436 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
438 fontStyleMapSet.Clear();
440 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
441 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
442 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
443 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
446 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
447 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
449 // Check that the Alignment properties can be correctly set
450 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
451 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
452 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
453 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
455 // Check that text color can be properly set
456 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
457 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
459 Property::Map underlineMapSet;
460 Property::Map underlineMapGet;
462 underlineMapSet.Insert( "enable", false );
463 underlineMapSet.Insert( "color", Color::BLUE );
464 underlineMapSet.Insert( "height", 0 );
466 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
467 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
468 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
470 TextLabel label2 = TextLabel::New( "New text" );
471 DALI_TEST_CHECK( label2 );
472 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
474 // Check the enable markup property.
475 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
476 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
477 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
479 // Check the text property when markup is enabled
480 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
481 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
483 // Check for incomplete marks.
484 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
485 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
488 application.SendNotification();
489 application.Render();
493 tet_result(TET_FAIL);
496 // Check autoscroll properties
497 const int SCROLL_SPEED = 80;
498 const int SCROLL_LOOPS = 4;
499 const float SCROLL_GAP = 50.0f;
500 const float SCROLL_LOOP_DELAY = 0.3f;
501 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
502 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
504 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
505 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
506 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
507 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
508 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
509 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
510 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
511 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
512 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
513 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
514 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
515 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
517 //Check autoscroll stop type property
518 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
519 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
521 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
522 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
524 // test natural size with multi-line and line spacing
526 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
527 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
528 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
529 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
530 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
532 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
533 // The height of the text when multi-line is enabled will be larger
534 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
535 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
537 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
538 // Everything else will remain the same
539 int lineSpacing = 20;
540 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
541 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
542 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
543 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
546 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
548 TextLabel label3 = TextLabel::New("Some text here end there end here");
549 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
550 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
551 Vector3 textNaturalSize = label3.GetNaturalSize();
552 int lineSpacing = 20;
553 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
554 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
555 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
556 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
558 // Check the line spacing property
559 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
560 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
561 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
563 // Check the underline property
564 underlineMapSet.Clear();
565 underlineMapSet.Insert( "enable", true );
566 underlineMapSet.Insert( "color", Color::RED );
567 underlineMapSet.Insert( "height", 1 );
569 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
571 application.SendNotification();
572 application.Render();
574 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
575 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
576 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
578 underlineMapSet.Clear();
579 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
580 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
581 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
583 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
585 application.SendNotification();
586 application.Render();
588 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
589 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
590 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
591 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
593 underlineMapSet.Clear();
595 Property::Map underlineDisabledMapGet;
596 underlineDisabledMapGet.Insert( "enable", false );
597 underlineDisabledMapGet.Insert( "color", Color::GREEN );
598 underlineDisabledMapGet.Insert( "height", 2 );
600 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
602 application.SendNotification();
603 application.Render();
605 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
606 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
607 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
609 // Check the shadow property
611 Property::Map shadowMapSet;
612 Property::Map shadowMapGet;
614 shadowMapSet.Insert( "color", Color::GREEN );
615 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
616 shadowMapSet.Insert( "blurRadius", 5.0f );
618 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
620 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
621 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
622 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
624 shadowMapSet.Clear();
626 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
627 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
628 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
630 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
632 // Replace the offset (string) by a vector2
633 shadowMapSet.Clear();
634 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
635 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
636 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
638 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
639 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
640 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
641 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
643 shadowMapSet.Clear();
644 Property::Map shadowDisabledMapGet;
645 shadowDisabledMapGet.Insert( "color", Color::BLUE );
646 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
647 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
649 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
651 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
652 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
653 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
655 // Check the emboss property
656 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
657 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
659 // Check the outline property
661 // Test string type first
662 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
663 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
664 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
666 // Then test the property map type
667 Property::Map outlineMapSet;
668 Property::Map outlineMapGet;
670 outlineMapSet["color"] = Color::RED;
671 outlineMapSet["width"] = 2.0f;
672 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
674 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
675 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
676 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
678 outlineMapSet.Clear();
679 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
680 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
681 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
683 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
684 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
685 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
686 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
688 // Check the background property
689 Property::Map backgroundMapSet;
690 Property::Map backgroundMapGet;
692 backgroundMapSet["enable"] = true;
693 backgroundMapSet["color"] = Color::RED;
694 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
696 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
697 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
698 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
700 backgroundMapSet.Clear();
701 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
702 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
703 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
705 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
706 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
707 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
708 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
710 // Check the pixel size of font
711 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
712 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 // Check the ellipsis property
715 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
716 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
717 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
719 // Check the layout direction property
720 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
721 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
723 // Check the line size property
724 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
725 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
726 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
728 application.SendNotification();
729 application.Render();
734 int UtcDaliToolkitTextlabelAtlasRenderP(void)
736 ToolkitTestApplication application;
737 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
738 TextLabel label = TextLabel::New("Test Text");
739 DALI_TEST_CHECK( label );
741 // Avoid a crash when core load gl resources.
742 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
744 application.GetScene().Add( label );
746 // Turn on all the effects
747 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
748 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
750 Property::Map underlineMap;
751 underlineMap.Insert( "enable", true );
752 underlineMap.Insert( "color", Color::RED );
753 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
755 Property::Map shadowMap;
756 shadowMap.Insert( "color", Color::BLUE );
757 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
758 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
762 // Render some text with the shared atlas backend
763 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
764 application.SendNotification();
765 application.Render();
769 tet_result(TET_FAIL);
774 // Render some text with the shared atlas backend
775 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
776 application.SendNotification();
777 application.Render();
781 tet_result(TET_FAIL);
786 int UtcDaliToolkitTextLabelLanguagesP(void)
788 ToolkitTestApplication application;
789 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
790 TextLabel label = TextLabel::New();
791 DALI_TEST_CHECK( label );
793 application.GetScene().Add( label );
795 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
796 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
797 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
798 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
799 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
800 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
802 label.SetProperty( TextLabel::Property::TEXT, scripts );
803 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
805 application.SendNotification();
806 application.Render();
811 int UtcDaliToolkitTextLabelEmojisP(void)
813 ToolkitTestApplication application;
814 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
815 TextLabel label = TextLabel::New();
816 DALI_TEST_CHECK( label );
818 application.GetScene().Add( label );
820 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
822 char* pathNamePtr = get_current_dir_name();
823 const std::string pathName( pathNamePtr );
826 TextAbstraction::FontDescription fontDescription;
827 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
828 fontDescription.family = "BreezeColorEmoji";
829 fontDescription.width = TextAbstraction::FontWidth::NONE;
830 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
831 fontDescription.slant = TextAbstraction::FontSlant::NONE;
833 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
835 const std::string emojis = "<font family='BreezeColorEmoji' size='60'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
836 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
837 label.SetProperty( TextLabel::Property::TEXT, emojis );
839 Property::Map shadowMap;
840 shadowMap.Insert( "color", "green" );
841 shadowMap.Insert( "offset", "2 2" );
842 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
844 application.SendNotification();
845 application.Render();
847 // EMOJI + ZWJ + EMOJI case for coverage.
848 const std::string emojiWithZWJ = "👩‍🔬";
849 label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
851 application.SendNotification();
852 application.Render();
857 int UtcDaliToolkitTextlabelScrollingP(void)
859 ToolkitTestApplication application;
860 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
861 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
862 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
864 DALI_TEST_CHECK( labelImmediate );
865 DALI_TEST_CHECK( labelFinished );
866 // Avoid a crash when core load gl resources.
867 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
868 application.GetScene().Add( labelImmediate );
869 // Turn on all the effects
870 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
871 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
872 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
873 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
874 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
876 application.GetScene().Add( labelFinished );
877 // Turn on all the effects
878 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
879 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
880 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
881 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
882 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
888 // Render some text with the shared atlas backend
889 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
890 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
892 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
893 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
895 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
896 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
897 application.SendNotification();
898 application.Render();
900 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
901 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
902 application.SendNotification();
903 application.Render();
908 tet_result(TET_FAIL);
914 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
916 ToolkitTestApplication application;
917 TextLabel labelShort = TextLabel::New("Some text to scroll");
918 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!");
920 DALI_TEST_CHECK( labelShort );
921 DALI_TEST_CHECK( labelLong );
922 // Avoid a crash when core load gl resources.
923 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
924 application.GetScene().Add( labelShort );
925 // Turn on all the effects
926 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
927 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
928 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
929 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
930 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
931 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
933 application.GetScene().Add( labelLong );
934 // Turn on all the effects
935 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
936 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
937 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
938 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
939 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
940 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
944 // Render some text with the shared atlas backend
945 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
946 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
947 application.SendNotification();
948 application.Render();
950 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
951 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
952 application.SendNotification();
953 application.Render();
958 tet_result(TET_FAIL);
964 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
966 ToolkitTestApplication application;
967 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
968 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
970 DALI_TEST_CHECK( labelShort );
971 DALI_TEST_CHECK( labelLong );
972 // Avoid a crash when core load gl resources.
973 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
974 application.GetScene().Add( labelShort );
975 // Turn on all the effects
976 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
977 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
978 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
979 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
980 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
981 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
983 application.GetScene().Add( labelLong );
984 // Turn on all the effects
985 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
986 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
987 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
988 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
989 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
990 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
994 // Render some text with the shared atlas backend
995 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
996 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
997 application.SendNotification();
998 application.Render();
1000 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1001 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1002 application.SendNotification();
1003 application.Render();
1008 tet_result(TET_FAIL);
1014 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1016 ToolkitTestApplication application;
1017 TextLabel labelShort = TextLabel::New("Some text to scroll");
1018 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!");
1020 DALI_TEST_CHECK( labelShort );
1021 DALI_TEST_CHECK( labelLong );
1022 // Avoid a crash when core load gl resources.
1023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1024 application.GetScene().Add( labelShort );
1025 // Turn on all the effects
1026 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1027 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1028 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1029 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1030 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1031 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1033 application.GetScene().Add( labelLong );
1034 // Turn on all the effects
1035 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1036 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1037 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1038 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1039 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1040 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1044 // Render some text with the shared atlas backend
1045 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1046 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1047 application.SendNotification();
1048 application.Render();
1050 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1051 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1052 application.SendNotification();
1053 application.Render();
1058 tet_result(TET_FAIL);
1064 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1066 ToolkitTestApplication application;
1067 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1068 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1070 DALI_TEST_CHECK( labelShort );
1071 DALI_TEST_CHECK( labelLong );
1072 // Avoid a crash when core load gl resources.
1073 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1074 application.GetScene().Add( labelShort );
1075 // Turn on all the effects
1076 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1077 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1078 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1079 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1080 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1081 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1083 application.GetScene().Add( labelLong );
1084 // Turn on all the effects
1085 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1086 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1087 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1088 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1089 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1090 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1094 // Render some text with the shared atlas backend
1095 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1096 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1097 application.SendNotification();
1098 application.Render();
1100 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1101 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1102 application.SendNotification();
1103 application.Render();
1108 tet_result(TET_FAIL);
1114 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1116 ToolkitTestApplication application;
1117 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1118 TextLabel label = TextLabel::New("Some text to scroll");
1119 DALI_TEST_CHECK( label );
1120 // Avoid a crash when core load gl resources.
1121 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1122 application.GetScene().Add( label );
1123 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1124 // Turn on all the effects
1125 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1126 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1127 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1128 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1131 application.SendNotification();
1132 application.Render();
1134 unsigned int actorCount1 = label.GetChildCount();
1135 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1139 // Render some text with the shared atlas backend
1140 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1141 application.SendNotification();
1142 application.Render(2000);
1144 unsigned int actorCount1 = label.GetChildCount();
1145 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1147 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1150 application.SendNotification();
1151 application.Render();
1153 unsigned int actorCount2 = label.GetChildCount();
1154 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1156 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1161 tet_result(TET_FAIL);
1167 int UtcDaliToolkitTextlabelScrollingN(void)
1169 ToolkitTestApplication application;
1170 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1172 TextLabel label = TextLabel::New("Some text to scroll");
1173 DALI_TEST_CHECK( label );
1175 application.GetScene().Add( label );
1177 // Avoid a crash when core load gl resources.
1178 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1180 // The text scrolling works only on single line text.
1181 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1183 // Turn on all the effects.
1184 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1185 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1186 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1188 // Enable the auto scrolling effect.
1189 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1191 // The auto scrolling shouldn't be enabled.
1192 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1193 DALI_TEST_CHECK( !enabled );
1198 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1200 ToolkitTestApplication application;
1201 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1203 TextLabel label = TextLabel::New("Some text to scroll");
1204 DALI_TEST_CHECK( label );
1206 application.GetScene().Add( label );
1208 // Avoid a crash when core load gl resources.
1209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1211 // Turn on all the effects.
1212 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1213 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1214 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1218 // Enable the auto scrolling effect.
1219 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1220 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1222 // Disable the ellipsis
1223 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1226 application.SendNotification();
1227 application.Render();
1229 // Stop auto scrolling
1230 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1232 // Check the ellipsis property
1233 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1237 tet_result(TET_FAIL);
1243 int UtcDaliToolkitTextlabelEllipsis(void)
1245 ToolkitTestApplication application;
1246 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1248 TextLabel label = TextLabel::New("Hello world");
1249 DALI_TEST_CHECK( label );
1251 // Avoid a crash when core load gl resources.
1252 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1254 application.GetScene().Add( label );
1256 // Turn on all the effects
1257 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1258 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1259 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1264 application.SendNotification();
1265 application.Render();
1269 tet_result(TET_FAIL);
1272 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1273 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1274 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1279 application.SendNotification();
1280 application.Render();
1284 tet_result(TET_FAIL);
1288 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1289 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1290 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1295 application.SendNotification();
1296 application.Render();
1300 tet_result(TET_FAIL);
1306 int UtcDaliToolkitTextlabelTextWrapMode(void)
1308 ToolkitTestApplication application;
1309 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1313 TextLabel label = TextLabel::New();
1314 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1315 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1316 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1320 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1321 application.GetScene().Add( label );
1323 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1324 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1326 application.SendNotification();
1327 application.Render();
1329 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1330 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1332 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1333 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1335 application.SendNotification();
1336 application.Render();
1338 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1339 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1341 application.SendNotification();
1342 application.Render();
1344 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1345 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1347 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1348 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1350 application.SendNotification();
1351 application.Render();
1353 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1354 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1356 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1357 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1358 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1363 int UtcDaliToolkitTextLabelColorComponents(void)
1365 ToolkitTestApplication application;
1367 TextLabel label = TextLabel::New();
1368 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1369 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1370 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1371 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1372 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1374 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1375 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1376 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1377 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1378 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1380 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1381 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1382 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1383 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1384 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1386 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1387 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1388 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1390 // Test a transparent text - Rendering should be skipped.
1391 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1392 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1394 application.GetScene().Add( label );
1396 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1397 drawTrace.Enable( true );
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1404 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1413 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1417 application.SendNotification();
1418 application.Render();
1420 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1425 int UtcDaliToolkitTextlabelTextStyle01(void)
1427 ToolkitTestApplication application;
1428 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1430 TextLabel label = TextLabel::New();
1431 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1432 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1433 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1434 application.GetScene().Add( label );
1436 Property::Map outlineMapSet;
1437 Property::Map outlineMapGet;
1439 outlineMapSet["color"] = Color::BLUE;
1440 outlineMapSet["width"] = 2.0f;
1441 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1443 application.SendNotification();
1444 application.Render();
1446 Property::Map shadowMapSet;
1447 shadowMapSet.Insert( "color", "green" );
1448 shadowMapSet.Insert( "offset", "2 2" );
1449 shadowMapSet.Insert( "blurRadius", "3" );
1450 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1452 outlineMapSet["color"] = Color::RED;
1453 outlineMapSet["width"] = 0.0f;
1454 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1456 application.SendNotification();
1457 application.Render();
1459 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1461 Property::Value* colorValue = outlineMapGet.Find("color");
1463 bool colorMatched( false );
1467 Property::Type valueType = colorValue->GetType();
1469 if ( Property::STRING == valueType )
1471 std::string stringValue;
1472 colorValue->Get( stringValue );
1473 if ( stringValue == "red" )
1475 colorMatched = true;
1478 else if ( Property::VECTOR4 == valueType )
1480 Vector4 colorVector4;
1481 colorValue->Get( colorVector4 );
1482 if ( colorVector4 == Color::RED )
1484 colorMatched = true;
1489 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1494 int UtcDaliToolkitTextlabelMultiline(void)
1496 ToolkitTestApplication application;
1497 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1499 TextLabel label = TextLabel::New();
1500 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1501 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1502 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1503 application.GetScene().Add( label );
1505 application.SendNotification();
1506 application.Render();
1508 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1509 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1511 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1513 application.SendNotification();
1514 application.Render();
1516 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1517 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1523 int UtcDaliToolkitTextlabelTextDirection(void)
1525 ToolkitTestApplication application;
1526 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1528 TextLabel label = TextLabel::New();
1529 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1531 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1532 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1533 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1534 application.GetScene().Add( label );
1537 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1540 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1541 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1543 // Test RTL text starting with weak character
1544 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1545 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1547 // Test RTL text string with emoji and weak character
1548 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1549 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1554 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1556 ToolkitTestApplication application;
1557 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1559 TextLabel label = TextLabel::New();
1561 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1562 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1563 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1564 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1565 application.GetScene().Add( label );
1566 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1568 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1569 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1571 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1572 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1577 int UtcDaliToolkitTextLabelBitmapFont(void)
1579 ToolkitTestApplication application;
1580 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1582 DevelText::BitmapFontDescription fontDescription;
1583 fontDescription.name = "Digits";
1584 fontDescription.underlinePosition = 0.f;
1585 fontDescription.underlineThickness = 0.f;
1587 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1588 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1589 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1590 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1591 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1592 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1593 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1594 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1595 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1596 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1597 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1599 TextAbstraction::BitmapFont bitmapFont;
1600 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1602 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1603 fontClient.GetFontId( bitmapFont );
1605 TextLabel label = TextLabel::New();
1607 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1608 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1610 // 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.
1611 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1613 application.GetScene().Add( label );
1615 application.SendNotification();
1616 application.Render();
1618 // The text has been rendered if the height of the text-label is the height of the line.
1619 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1624 int ConvertPointToPixel( float point )
1626 unsigned int horizontalDpi = 0u;
1627 unsigned int verticalDpi = 0u;
1628 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1629 fontClient.GetDpi( horizontalDpi, verticalDpi );
1631 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1634 int UtcDaliToolkitTextlabelTextFit(void)
1636 ToolkitTestApplication application;
1637 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1638 TextLabel label = TextLabel::New();
1639 Vector2 size( 460.0f, 100.0f );
1640 label.SetProperty( Actor::Property::SIZE, size );
1641 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1643 // connect to the text git changed signal.
1644 ConnectionTracker* testTracker = new ConnectionTracker();
1645 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1646 bool textFitChangedSignal = false;
1647 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1648 gTextFitChangedCallBackCalled = false;
1651 Property::Map textFitMapSet;
1652 textFitMapSet["enable"] = true;
1653 textFitMapSet["minSize"] = 10.f;
1654 textFitMapSet["maxSize"] = 100.f;
1655 textFitMapSet["stepSize"] = -1.f;
1656 textFitMapSet["fontSizeType"] = "pointSize";
1658 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1659 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1661 application.GetScene().Add( label );
1663 application.SendNotification();
1664 application.Render();
1666 const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1667 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1669 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1670 DALI_TEST_CHECK(textFitChangedSignal);
1673 textFitMapSet.Clear();
1674 textFitMapSet["enable"] = true;
1675 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1676 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1677 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1678 textFitMapSet["fontSizeType"] = "pixelSize";
1680 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1682 application.SendNotification();
1683 application.Render();
1685 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1690 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1692 ToolkitTestApplication application;
1693 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1695 DevelText::BitmapFontDescription fontDescription;
1696 fontDescription.name = "Digits";
1697 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1699 TextAbstraction::BitmapFont bitmapFont;
1700 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1702 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1703 fontClient.GetFontId( bitmapFont );
1705 TextLabel label = TextLabel::New();
1706 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1707 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1708 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1709 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1710 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1712 Property::Map underlineMapSet;
1713 underlineMapSet.Clear();
1714 underlineMapSet.Insert( "enable", true );
1715 underlineMapSet.Insert( "color", Color::RED );
1716 underlineMapSet.Insert( "height", 1 );
1717 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1718 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1720 application.GetScene().Add( label );
1722 application.SendNotification();
1723 application.Render();
1725 const int maxTextureSize = Dali::GetMaxTextureSize();
1726 // Whether the rendered text is greater than maxTextureSize
1727 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1729 // Check if the number of renderers is greater than 1.
1730 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1735 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1737 ToolkitTestApplication application;
1738 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1740 Vector2 size( 300.0f, 100.0f );
1742 Dali::Toolkit::DevelText::RendererParameters textParameters;
1743 textParameters.text = "This is a sample text to get the last index.";
1744 textParameters.layout = "multiLine";
1745 textParameters.fontSize = 20.f;
1746 textParameters.textWidth = 300u;
1747 textParameters.textHeight = 100u;
1748 textParameters.ellipsisEnabled = true;
1749 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1751 DALI_TEST_CHECK( !indexArray.Empty() );
1752 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1757 int UtcDaliToolkitTextlabelFontSizeScale(void)
1759 ToolkitTestApplication application;
1760 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1762 TextLabel label = TextLabel::New();
1763 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1764 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1765 Vector3 nonScaledSize = label.GetNaturalSize();
1767 TextLabel labelScaled = TextLabel::New();
1768 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1769 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1770 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1771 Vector3 scaledSize = labelScaled.GetNaturalSize();
1773 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1775 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1776 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1777 nonScaledSize = label.GetNaturalSize();
1779 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1780 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1781 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1782 scaledSize = labelScaled.GetNaturalSize();
1784 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1789 // Positive test for the anchorClicked signal.
1790 int UtcDaliToolkitTextlabelAnchorClicked(void)
1792 ToolkitTestApplication application;
1793 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1794 TextLabel label = TextLabel::New();
1795 DALI_TEST_CHECK(label);
1797 application.GetScene().Add(label);
1799 // connect to the anchor clicked signal.
1800 ConnectionTracker* testTracker = new ConnectionTracker();
1801 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1802 bool anchorClickedSignal = false;
1803 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1805 gAnchorClickedCallBackCalled = false;
1806 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1807 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1808 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1809 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1810 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1812 application.SendNotification();
1813 application.Render();
1815 // Create a tap event to touch the text label.
1816 TestGenerateTap(application, 5.0f, 25.0f, 100);
1817 application.SendNotification();
1818 application.Render();
1820 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1821 DALI_TEST_CHECK(anchorClickedSignal);
1824 gAnchorClickedCallBackCalled = false;
1825 anchorClickedSignal = false;
1826 label.SetProperty(TextLabel::Property::TEXT, "");
1827 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1829 application.SendNotification();
1830 application.Render();
1833 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1834 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1835 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1836 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1837 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1839 application.SendNotification();
1840 application.Render();
1842 // Create a tap event to touch the text label.
1843 TestGenerateTap(application, 5.0f, 25.0f, 200);
1844 application.SendNotification();
1845 application.Render();
1847 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1848 DALI_TEST_CHECK(anchorClickedSignal);
1851 gAnchorClickedCallBackNotCalled = true;
1852 // Tap the outside of anchor, callback should not be called.
1853 TestGenerateTap(application, 150.f, 100.f, 300);
1854 application.SendNotification();
1855 application.Render();
1857 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1862 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1864 ToolkitTestApplication application;
1865 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1867 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1869 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1870 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1871 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1873 // Create a text editor
1874 TextLabel textLabel = TextLabel::New();
1875 //Set size to avoid automatic eliding
1876 textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1877 //Set very large font-size using point-size
1878 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1879 //Specify font-family
1880 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1881 //Set text to check if appear or not
1882 textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1884 application.GetScene().Add( textLabel );
1886 application.SendNotification();
1887 application.Render();
1888 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1889 Vector3 naturalSize = textLabel.GetNaturalSize();
1891 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1892 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1897 int UtcDaliTextLabelHyphenWrapMode(void)
1899 ToolkitTestApplication application;
1900 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1903 TextLabel label = TextLabel::New();
1904 label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1905 label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1906 label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1907 application.GetScene().Add( label );
1908 application.SendNotification();
1909 application.Render();
1911 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1912 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1913 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1915 application.SendNotification();
1916 application.Render();
1918 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1924 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1926 label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1927 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1928 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1930 application.SendNotification();
1931 application.Render();
1933 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1940 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1946 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1948 ToolkitTestApplication application;
1950 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1952 int lineCountBefore =0 ;
1953 int lineCountAfter =0 ;
1955 // Create a text editor
1956 TextLabel textLabel = TextLabel::New();
1957 //Set very large font-size using point-size
1958 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1959 //Specify font-family
1960 textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1962 textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
1963 //Set text longer than width of textLabel
1964 textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
1965 //Set line wrap mode Character
1966 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1967 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1969 application.GetScene().Add( textLabel );
1971 application.SendNotification();
1972 application.Render();
1975 lineCountBefore = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1977 textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
1978 lineCountAfter = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1980 // When the text changed, the Line-count should be updated according to new text.
1981 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
1982 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
1983 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
1989 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
1991 ToolkitTestApplication application;
1992 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
1993 TextLabel textLabel = TextLabel::New();
1995 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
1996 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
1998 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
1999 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2000 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2002 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2003 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2004 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2006 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2007 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2008 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2010 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2011 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2012 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2014 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2015 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2016 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2018 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2019 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2020 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2022 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2023 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2024 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2026 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2027 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2028 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2030 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2031 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2032 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2034 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2035 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2036 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2038 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2039 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2040 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2042 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2043 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2044 DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );