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 std::string DEFAULT_FONT_DIR( "/resources/fonts" );
78 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
80 static bool gAnchorClickedCallBackCalled;
81 static bool gAnchorClickedCallBackNotCalled;
83 struct CallbackFunctor
85 CallbackFunctor(bool* callbackFlag)
86 : mCallbackFlag( callbackFlag )
92 *mCallbackFlag = true;
97 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
99 tet_infoline(" TestAnchorClickedCallback");
101 gAnchorClickedCallBackNotCalled = false;
103 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
105 gAnchorClickedCallBackCalled = true;
109 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
111 const Property::Map::SizeType size = mapGet.Count();
113 if( size == mapSet.Count() )
115 for( unsigned int index = 0u; index < size; ++index )
117 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
119 // Find the keys of the 'get' map
120 Property::Index indexKey = valueGet.first.indexKey;
121 std::string stringKey = valueGet.first.stringKey;
123 if( !indexConversionTable.empty() )
125 if( stringKey.empty() )
127 stringKey = indexConversionTable[ indexKey ];
130 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
132 Property::Index index = 0u;
133 for( auto key : indexConversionTable )
135 if( key == stringKey )
145 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
147 if( nullptr != valueSet )
149 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
151 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
154 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
156 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
159 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
161 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
164 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
166 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
169 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
171 Vector2 vector2Get = valueGet.second.Get<Vector2>();
172 Vector2 vector2Set = valueSet->Get<Vector2>();
173 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
176 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
178 Vector4 vector4Get = valueGet.second.Get<Vector4>();
179 Vector4 vector4Set = valueSet->Get<Vector4>();
180 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 );
186 if ( valueGet.first.type == Property::Key::INDEX )
188 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
192 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
204 int UtcDaliToolkitTextLabelConstructorP(void)
206 ToolkitTestApplication application;
207 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
209 DALI_TEST_CHECK( !textLabel );
213 int UtcDaliToolkitTextLabelNewP(void)
215 ToolkitTestApplication application;
216 tet_infoline(" UtcDaliToolkitTextLabelNewP");
217 TextLabel textLabel = TextLabel::New( "Test Text" );
218 DALI_TEST_CHECK( textLabel );
222 int UtcDaliToolkitTextLabelDownCastP(void)
224 ToolkitTestApplication application;
225 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
226 TextLabel textLabel1 = TextLabel::New();
227 BaseHandle object( textLabel1 );
229 TextLabel textLabel2 = TextLabel::DownCast( object );
230 DALI_TEST_CHECK( textLabel2 );
232 TextLabel textLabel3 = DownCast< TextLabel >( object );
233 DALI_TEST_CHECK( textLabel3 );
237 int UtcDaliToolkitTextLabelDownCastN(void)
239 ToolkitTestApplication application;
240 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
241 BaseHandle uninitializedObject;
242 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
243 DALI_TEST_CHECK( !textLabel1 );
245 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
246 DALI_TEST_CHECK( !textLabel2 );
250 int UtcDaliToolkitTextLabelCopyConstructorP(void)
252 ToolkitTestApplication application;
253 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
254 TextLabel textLabel = TextLabel::New();
255 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
257 TextLabel copy( textLabel );
258 DALI_TEST_CHECK( copy );
259 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
263 int UtcDaliTextLabelMoveConstructor(void)
265 ToolkitTestApplication application;
267 TextLabel textLabel = TextLabel::New();
268 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
269 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
271 TextLabel moved = std::move( textLabel );
272 DALI_TEST_CHECK( moved );
273 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
274 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
275 DALI_TEST_CHECK( !textLabel );
280 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
282 ToolkitTestApplication application;
283 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
284 TextLabel textLabel = TextLabel::New();
285 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
287 TextLabel copy = textLabel;
288 DALI_TEST_CHECK( copy );
289 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
293 int UtcDaliTextLabelMoveAssignment(void)
295 ToolkitTestApplication application;
297 TextLabel textLabel = TextLabel::New();
298 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
299 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
302 moved = std::move( textLabel );
303 DALI_TEST_CHECK( moved );
304 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
305 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
306 DALI_TEST_CHECK( !textLabel );
311 // Positive test case for a method
312 int UtcDaliToolkitTextLabelGetPropertyP(void)
314 ToolkitTestApplication application;
315 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
316 TextLabel label = TextLabel::New("Test Text");
317 DALI_TEST_CHECK( label );
319 // Check Property Indices are correct
320 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
321 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
322 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
323 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
324 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
325 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
326 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
327 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
328 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
329 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
330 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
331 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
332 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
333 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
334 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
335 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
336 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
337 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
338 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
339 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
340 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
341 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
342 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
343 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
348 int UtcDaliToolkitTextLabelSetPropertyP(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
352 TextLabel label = TextLabel::New();
353 DALI_TEST_CHECK( label );
355 application.GetScene().Add( label );
357 // Note - we can't check the defaults since the stylesheets are platform-specific
358 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
359 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
361 // Check that text can be correctly reset
362 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
363 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
365 // Check font properties.
366 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
367 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
369 Property::Map fontStyleMapSet;
370 Property::Map fontStyleMapGet;
372 fontStyleMapSet.Insert( "weight", "bold" );
373 fontStyleMapSet.Insert( "width", "condensed" );
374 fontStyleMapSet.Insert( "slant", "italic" );
375 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
377 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
378 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
379 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
381 // Check the old font style format.
382 fontStyleMapSet.Clear();
383 fontStyleMapSet.Insert( "weight", "thin" );
384 fontStyleMapSet.Insert( "width", "expanded" );
385 fontStyleMapSet.Insert( "slant", "oblique" );
386 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
388 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
389 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
390 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
392 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
393 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
395 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
396 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
397 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
400 fontStyleMapSet.Clear();
401 fontStyleMapSet.Insert( "weight", "normal" );
402 fontStyleMapSet.Insert( "slant", "oblique" );
404 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
405 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
406 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
407 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
409 fontStyleMapSet.Clear();
410 fontStyleMapSet.Insert( "slant", "roman" );
412 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
413 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
414 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
416 // Replace 'roman' for 'normal'.
417 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
418 if( NULL != slantValue )
420 if( "normal" == slantValue->Get<std::string>() )
422 fontStyleMapGet["slant"] = "roman";
425 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
427 fontStyleMapSet.Clear();
429 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
430 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
431 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
432 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
435 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
436 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
438 // Check that the Alignment properties can be correctly set
439 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
440 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
441 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
442 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
444 // Check that text color can be properly set
445 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
446 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
448 Property::Map underlineMapSet;
449 Property::Map underlineMapGet;
451 underlineMapSet.Insert( "enable", false );
452 underlineMapSet.Insert( "color", Color::BLUE );
453 underlineMapSet.Insert( "height", 0 );
455 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
456 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
457 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
459 TextLabel label2 = TextLabel::New( "New text" );
460 DALI_TEST_CHECK( label2 );
461 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
463 // Check the enable markup property.
464 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
465 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
466 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
468 // Check the text property when markup is enabled
469 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
470 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
472 // Check for incomplete marks.
473 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
474 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
477 application.SendNotification();
478 application.Render();
482 tet_result(TET_FAIL);
485 // Check autoscroll properties
486 const int SCROLL_SPEED = 80;
487 const int SCROLL_LOOPS = 4;
488 const float SCROLL_GAP = 50.0f;
489 const float SCROLL_LOOP_DELAY = 0.3f;
490 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
491 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
493 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
494 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
495 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
496 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
497 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
498 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
499 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
500 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
501 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
502 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
503 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
504 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
506 //Check autoscroll stop type property
507 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
508 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
510 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
511 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
513 // test natural size with multi-line and line spacing
515 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
516 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
517 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
518 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
519 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
521 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
522 // The height of the text when multi-line is enabled will be larger
523 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
524 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
526 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
527 // Everything else will remain the same
528 int lineSpacing = 20;
529 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
530 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
531 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
532 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
535 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
537 TextLabel label3 = TextLabel::New("Some text here end there end here");
538 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
539 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
540 Vector3 textNaturalSize = label3.GetNaturalSize();
541 int lineSpacing = 20;
542 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
543 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
544 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
545 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
547 // Check the line spacing property
548 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
549 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
550 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
552 // Check the underline property
553 underlineMapSet.Clear();
554 underlineMapSet.Insert( "enable", true );
555 underlineMapSet.Insert( "color", Color::RED );
556 underlineMapSet.Insert( "height", 1 );
558 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
560 application.SendNotification();
561 application.Render();
563 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
564 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
565 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
567 underlineMapSet.Clear();
568 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
569 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
570 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
572 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
574 application.SendNotification();
575 application.Render();
577 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
578 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
579 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
580 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
582 underlineMapSet.Clear();
584 Property::Map underlineDisabledMapGet;
585 underlineDisabledMapGet.Insert( "enable", false );
586 underlineDisabledMapGet.Insert( "color", Color::GREEN );
587 underlineDisabledMapGet.Insert( "height", 2 );
589 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
591 application.SendNotification();
592 application.Render();
594 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
595 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
596 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
598 // Check the shadow property
600 Property::Map shadowMapSet;
601 Property::Map shadowMapGet;
603 shadowMapSet.Insert( "color", Color::GREEN );
604 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
605 shadowMapSet.Insert( "blurRadius", 5.0f );
607 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
609 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
610 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
611 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
613 shadowMapSet.Clear();
615 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
616 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
617 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
619 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
621 // Replace the offset (string) by a vector2
622 shadowMapSet.Clear();
623 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
624 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
625 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
627 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
628 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
629 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
630 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
632 shadowMapSet.Clear();
633 Property::Map shadowDisabledMapGet;
634 shadowDisabledMapGet.Insert( "color", Color::BLUE );
635 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
636 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
638 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
640 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
641 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
644 // Check the emboss property
645 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
646 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
648 // Check the outline property
650 // Test string type first
651 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
652 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
653 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
655 // Then test the property map type
656 Property::Map outlineMapSet;
657 Property::Map outlineMapGet;
659 outlineMapSet["color"] = Color::RED;
660 outlineMapSet["width"] = 2.0f;
661 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
663 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
664 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
665 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
667 outlineMapSet.Clear();
668 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
669 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
670 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
672 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
673 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
674 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
675 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
677 // Check the background property
678 Property::Map backgroundMapSet;
679 Property::Map backgroundMapGet;
681 backgroundMapSet["enable"] = true;
682 backgroundMapSet["color"] = Color::RED;
683 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
685 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
686 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
687 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
689 backgroundMapSet.Clear();
690 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
691 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
692 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
694 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
695 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
696 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
697 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
699 // Check the pixel size of font
700 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
701 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 // Check the ellipsis property
704 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
705 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
706 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
708 // Check the layout direction property
709 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
710 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
712 // Check the line size property
713 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
715 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 application.SendNotification();
718 application.Render();
723 int UtcDaliToolkitTextlabelAtlasRenderP(void)
725 ToolkitTestApplication application;
726 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
727 TextLabel label = TextLabel::New("Test Text");
728 DALI_TEST_CHECK( label );
730 // Avoid a crash when core load gl resources.
731 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
733 application.GetScene().Add( label );
735 // Turn on all the effects
736 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
737 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
739 Property::Map underlineMap;
740 underlineMap.Insert( "enable", true );
741 underlineMap.Insert( "color", Color::RED );
742 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
744 Property::Map shadowMap;
745 shadowMap.Insert( "color", Color::BLUE );
746 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
747 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
751 // Render some text with the shared atlas backend
752 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
753 application.SendNotification();
754 application.Render();
758 tet_result(TET_FAIL);
763 // Render some text with the shared atlas backend
764 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
765 application.SendNotification();
766 application.Render();
770 tet_result(TET_FAIL);
775 int UtcDaliToolkitTextLabelLanguagesP(void)
777 ToolkitTestApplication application;
778 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
779 TextLabel label = TextLabel::New();
780 DALI_TEST_CHECK( label );
782 application.GetScene().Add( label );
784 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
785 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
786 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
787 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
788 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
789 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
791 label.SetProperty( TextLabel::Property::TEXT, scripts );
792 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
794 application.SendNotification();
795 application.Render();
800 int UtcDaliToolkitTextLabelEmojisP(void)
802 ToolkitTestApplication application;
803 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
804 TextLabel label = TextLabel::New();
805 DALI_TEST_CHECK( label );
807 application.GetScene().Add( label );
809 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
811 char* pathNamePtr = get_current_dir_name();
812 const std::string pathName( pathNamePtr );
815 TextAbstraction::FontDescription fontDescription;
816 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
817 fontDescription.family = "BreezeColorEmoji";
818 fontDescription.width = TextAbstraction::FontWidth::NONE;
819 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
820 fontDescription.slant = TextAbstraction::FontSlant::NONE;
822 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
824 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>";
825 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
826 label.SetProperty( TextLabel::Property::TEXT, emojis );
828 Property::Map shadowMap;
829 shadowMap.Insert( "color", "green" );
830 shadowMap.Insert( "offset", "2 2" );
831 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
833 application.SendNotification();
834 application.Render();
839 int UtcDaliToolkitTextlabelScrollingP(void)
841 ToolkitTestApplication application;
842 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
843 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
844 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
846 DALI_TEST_CHECK( labelImmediate );
847 DALI_TEST_CHECK( labelFinished );
848 // Avoid a crash when core load gl resources.
849 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
850 application.GetScene().Add( labelImmediate );
851 // Turn on all the effects
852 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
853 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
854 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
855 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
856 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
858 application.GetScene().Add( labelFinished );
859 // Turn on all the effects
860 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
861 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
862 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
863 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
864 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
870 // Render some text with the shared atlas backend
871 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
872 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
874 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
875 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
877 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
878 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
879 application.SendNotification();
880 application.Render();
882 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
883 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
884 application.SendNotification();
885 application.Render();
890 tet_result(TET_FAIL);
896 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
898 ToolkitTestApplication application;
899 TextLabel labelShort = TextLabel::New("Some text to scroll");
900 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!");
902 DALI_TEST_CHECK( labelShort );
903 DALI_TEST_CHECK( labelLong );
904 // Avoid a crash when core load gl resources.
905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
906 application.GetScene().Add( labelShort );
907 // Turn on all the effects
908 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
909 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
910 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
911 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
912 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
913 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
915 application.GetScene().Add( labelLong );
916 // Turn on all the effects
917 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
918 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
919 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
920 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
921 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
922 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
926 // Render some text with the shared atlas backend
927 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
928 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
929 application.SendNotification();
930 application.Render();
932 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
933 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
934 application.SendNotification();
935 application.Render();
940 tet_result(TET_FAIL);
946 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
948 ToolkitTestApplication application;
949 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
950 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
952 DALI_TEST_CHECK( labelShort );
953 DALI_TEST_CHECK( labelLong );
954 // Avoid a crash when core load gl resources.
955 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
956 application.GetScene().Add( labelShort );
957 // Turn on all the effects
958 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
959 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
960 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
961 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
962 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
963 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
965 application.GetScene().Add( labelLong );
966 // Turn on all the effects
967 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
968 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
969 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
970 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
971 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
972 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
976 // Render some text with the shared atlas backend
977 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
978 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
979 application.SendNotification();
980 application.Render();
982 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
983 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
984 application.SendNotification();
985 application.Render();
990 tet_result(TET_FAIL);
996 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
998 ToolkitTestApplication application;
999 TextLabel labelShort = TextLabel::New("Some text to scroll");
1000 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!");
1002 DALI_TEST_CHECK( labelShort );
1003 DALI_TEST_CHECK( labelLong );
1004 // Avoid a crash when core load gl resources.
1005 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1006 application.GetScene().Add( labelShort );
1007 // Turn on all the effects
1008 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1009 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1010 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1011 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1012 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1013 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1015 application.GetScene().Add( labelLong );
1016 // Turn on all the effects
1017 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1018 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1019 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1020 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1021 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1022 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1026 // Render some text with the shared atlas backend
1027 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1028 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1029 application.SendNotification();
1030 application.Render();
1032 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1033 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1034 application.SendNotification();
1035 application.Render();
1040 tet_result(TET_FAIL);
1046 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1048 ToolkitTestApplication application;
1049 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1050 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1052 DALI_TEST_CHECK( labelShort );
1053 DALI_TEST_CHECK( labelLong );
1054 // Avoid a crash when core load gl resources.
1055 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1056 application.GetScene().Add( labelShort );
1057 // Turn on all the effects
1058 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1059 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1060 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1061 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1062 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1063 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1065 application.GetScene().Add( labelLong );
1066 // Turn on all the effects
1067 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1068 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1069 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1070 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1071 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1072 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1076 // Render some text with the shared atlas backend
1077 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1078 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1079 application.SendNotification();
1080 application.Render();
1082 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1083 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1084 application.SendNotification();
1085 application.Render();
1090 tet_result(TET_FAIL);
1096 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1098 ToolkitTestApplication application;
1099 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1100 TextLabel label = TextLabel::New("Some text to scroll");
1101 DALI_TEST_CHECK( label );
1102 // Avoid a crash when core load gl resources.
1103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1104 application.GetScene().Add( label );
1105 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1106 // Turn on all the effects
1107 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1108 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1109 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1110 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1113 application.SendNotification();
1114 application.Render();
1116 unsigned int actorCount1 = label.GetChildCount();
1117 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1121 // Render some text with the shared atlas backend
1122 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1123 application.SendNotification();
1124 application.Render(2000);
1126 unsigned int actorCount1 = label.GetChildCount();
1127 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1129 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1132 application.SendNotification();
1133 application.Render();
1135 unsigned int actorCount2 = label.GetChildCount();
1136 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1138 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1143 tet_result(TET_FAIL);
1149 int UtcDaliToolkitTextlabelScrollingN(void)
1151 ToolkitTestApplication application;
1152 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1154 TextLabel label = TextLabel::New("Some text to scroll");
1155 DALI_TEST_CHECK( label );
1157 application.GetScene().Add( label );
1159 // Avoid a crash when core load gl resources.
1160 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1162 // The text scrolling works only on single line text.
1163 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1165 // Turn on all the effects.
1166 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1167 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1168 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1170 // Enable the auto scrolling effect.
1171 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1173 // The auto scrolling shouldn't be enabled.
1174 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1175 DALI_TEST_CHECK( !enabled );
1180 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1182 ToolkitTestApplication application;
1183 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1185 TextLabel label = TextLabel::New("Some text to scroll");
1186 DALI_TEST_CHECK( label );
1188 application.GetScene().Add( label );
1190 // Avoid a crash when core load gl resources.
1191 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1193 // Turn on all the effects.
1194 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1195 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1196 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1200 // Enable the auto scrolling effect.
1201 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1202 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1204 // Disable the ellipsis
1205 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1208 application.SendNotification();
1209 application.Render();
1211 // Stop auto scrolling
1212 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1214 // Check the ellipsis property
1215 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1219 tet_result(TET_FAIL);
1225 int UtcDaliToolkitTextlabelEllipsis(void)
1227 ToolkitTestApplication application;
1228 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1230 TextLabel label = TextLabel::New("Hello world");
1231 DALI_TEST_CHECK( label );
1233 // Avoid a crash when core load gl resources.
1234 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1236 application.GetScene().Add( label );
1238 // Turn on all the effects
1239 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1240 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1241 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1246 application.SendNotification();
1247 application.Render();
1251 tet_result(TET_FAIL);
1254 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1255 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1256 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1261 application.SendNotification();
1262 application.Render();
1266 tet_result(TET_FAIL);
1270 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1271 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1272 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1277 application.SendNotification();
1278 application.Render();
1282 tet_result(TET_FAIL);
1288 int UtcDaliToolkitTextlabelTextWrapMode(void)
1290 ToolkitTestApplication application;
1291 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1295 TextLabel label = TextLabel::New();
1296 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1297 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1298 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1302 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1303 application.GetScene().Add( label );
1305 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1306 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1308 application.SendNotification();
1309 application.Render();
1311 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1312 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1314 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1315 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1317 application.SendNotification();
1318 application.Render();
1320 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1321 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1323 application.SendNotification();
1324 application.Render();
1326 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1327 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1329 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1330 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1332 application.SendNotification();
1333 application.Render();
1335 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1336 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1338 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1339 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1340 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1345 int UtcDaliToolkitTextLabelColorComponents(void)
1347 ToolkitTestApplication application;
1349 TextLabel label = TextLabel::New();
1350 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1351 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1352 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1353 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1354 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1356 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1357 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1358 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1359 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1360 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1362 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1363 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1364 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1365 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1366 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1368 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1369 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1370 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1372 // Test a transparent text - Rendering should be skipped.
1373 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1374 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1376 application.GetScene().Add( label );
1378 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1379 drawTrace.Enable( true );
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1386 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1390 application.SendNotification();
1391 application.Render();
1393 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1395 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1407 int UtcDaliToolkitTextlabelTextStyle01(void)
1409 ToolkitTestApplication application;
1410 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1412 TextLabel label = TextLabel::New();
1413 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1414 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1415 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1416 application.GetScene().Add( label );
1418 Property::Map outlineMapSet;
1419 Property::Map outlineMapGet;
1421 outlineMapSet["color"] = Color::BLUE;
1422 outlineMapSet["width"] = 2.0f;
1423 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1425 application.SendNotification();
1426 application.Render();
1428 Property::Map shadowMapSet;
1429 shadowMapSet.Insert( "color", "green" );
1430 shadowMapSet.Insert( "offset", "2 2" );
1431 shadowMapSet.Insert( "blurRadius", "3" );
1432 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1434 outlineMapSet["color"] = Color::RED;
1435 outlineMapSet["width"] = 0.0f;
1436 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1438 application.SendNotification();
1439 application.Render();
1441 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1443 Property::Value* colorValue = outlineMapGet.Find("color");
1445 bool colorMatched( false );
1449 Property::Type valueType = colorValue->GetType();
1451 if ( Property::STRING == valueType )
1453 std::string stringValue;
1454 colorValue->Get( stringValue );
1455 if ( stringValue == "red" )
1457 colorMatched = true;
1460 else if ( Property::VECTOR4 == valueType )
1462 Vector4 colorVector4;
1463 colorValue->Get( colorVector4 );
1464 if ( colorVector4 == Color::RED )
1466 colorMatched = true;
1471 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1476 int UtcDaliToolkitTextlabelMultiline(void)
1478 ToolkitTestApplication application;
1479 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1481 TextLabel label = TextLabel::New();
1482 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1483 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1484 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1485 application.GetScene().Add( label );
1487 application.SendNotification();
1488 application.Render();
1490 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1491 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1493 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1495 application.SendNotification();
1496 application.Render();
1498 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1499 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1505 int UtcDaliToolkitTextlabelTextDirection(void)
1507 ToolkitTestApplication application;
1508 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1510 TextLabel label = TextLabel::New();
1511 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1513 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1514 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1515 application.GetScene().Add( label );
1518 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1521 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1522 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1524 // Test RTL text starting with weak character
1525 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1526 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1528 // Test RTL text string with emoji and weak character
1529 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1530 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1535 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1537 ToolkitTestApplication application;
1538 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1540 TextLabel label = TextLabel::New();
1542 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1543 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1544 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1545 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1546 application.GetScene().Add( label );
1547 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1549 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1550 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1552 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1553 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1558 int UtcDaliToolkitTextLabelBitmapFont(void)
1560 ToolkitTestApplication application;
1561 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1563 DevelText::BitmapFontDescription fontDescription;
1564 fontDescription.name = "Digits";
1565 fontDescription.underlinePosition = 0.f;
1566 fontDescription.underlineThickness = 0.f;
1568 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1569 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1570 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1571 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1572 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1573 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1574 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1575 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1576 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1577 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1578 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1580 TextAbstraction::BitmapFont bitmapFont;
1581 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1583 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1584 fontClient.GetFontId( bitmapFont );
1586 TextLabel label = TextLabel::New();
1588 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1589 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1591 // 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.
1592 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1594 application.GetScene().Add( label );
1596 application.SendNotification();
1597 application.Render();
1599 // The text has been rendered if the height of the text-label is the height of the line.
1600 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1605 int ConvertPointToPixel( float point )
1607 unsigned int horizontalDpi = 0u;
1608 unsigned int verticalDpi = 0u;
1609 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1610 fontClient.GetDpi( horizontalDpi, verticalDpi );
1612 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1615 int UtcDaliToolkitTextlabelTextFit(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1619 TextLabel label = TextLabel::New();
1620 Vector2 size( 460.0f, 100.0f );
1621 label.SetProperty( Actor::Property::SIZE, size );
1622 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1625 Property::Map textFitMapSet;
1626 textFitMapSet["enable"] = true;
1627 textFitMapSet["minSize"] = 10.f;
1628 textFitMapSet["maxSize"] = 100.f;
1629 textFitMapSet["stepSize"] = -1.f;
1630 textFitMapSet["fontSizeType"] = "pointSize";
1632 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1633 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1635 application.GetScene().Add( label );
1637 application.SendNotification();
1638 application.Render();
1640 const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1641 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1644 textFitMapSet.Clear();
1645 textFitMapSet["enable"] = true;
1646 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1647 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1648 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1649 textFitMapSet["fontSizeType"] = "pixelSize";
1651 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1653 application.SendNotification();
1654 application.Render();
1656 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1661 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1663 ToolkitTestApplication application;
1664 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1666 DevelText::BitmapFontDescription fontDescription;
1667 fontDescription.name = "Digits";
1668 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1670 TextAbstraction::BitmapFont bitmapFont;
1671 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1673 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1674 fontClient.GetFontId( bitmapFont );
1676 TextLabel label = TextLabel::New();
1677 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1678 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1679 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1680 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1681 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1683 Property::Map underlineMapSet;
1684 underlineMapSet.Clear();
1685 underlineMapSet.Insert( "enable", true );
1686 underlineMapSet.Insert( "color", Color::RED );
1687 underlineMapSet.Insert( "height", 1 );
1688 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1689 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1691 application.GetScene().Add( label );
1693 application.SendNotification();
1694 application.Render();
1696 const int maxTextureSize = Dali::GetMaxTextureSize();
1697 // Whether the rendered text is greater than maxTextureSize
1698 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1700 // Check if the number of renderers is greater than 1.
1701 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1706 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1708 ToolkitTestApplication application;
1709 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1711 Vector2 size( 300.0f, 100.0f );
1713 Dali::Toolkit::DevelText::RendererParameters textParameters;
1714 textParameters.text = "This is a sample text to get the last index.";
1715 textParameters.layout = "multiLine";
1716 textParameters.fontSize = 20.f;
1717 textParameters.textWidth = 300u;
1718 textParameters.textHeight = 100u;
1719 textParameters.ellipsisEnabled = true;
1720 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1722 DALI_TEST_CHECK( !indexArray.Empty() );
1723 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1728 int UtcDaliToolkitTextlabelFontSizeScale(void)
1730 ToolkitTestApplication application;
1731 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1733 TextLabel label = TextLabel::New();
1734 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1735 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1736 Vector3 nonScaledSize = label.GetNaturalSize();
1738 TextLabel labelScaled = TextLabel::New();
1739 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1740 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1741 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1742 Vector3 scaledSize = labelScaled.GetNaturalSize();
1744 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1746 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1747 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1748 nonScaledSize = label.GetNaturalSize();
1750 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1751 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1752 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1753 scaledSize = labelScaled.GetNaturalSize();
1755 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1760 // Positive test for the anchorClicked signal.
1761 int UtcDaliToolkitTextlabelAnchorClicked(void)
1763 ToolkitTestApplication application;
1764 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1765 TextLabel label = TextLabel::New();
1766 DALI_TEST_CHECK(label);
1768 application.GetScene().Add(label);
1770 // connect to the anchor clicked signal.
1771 ConnectionTracker* testTracker = new ConnectionTracker();
1772 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1773 bool anchorClickedSignal = false;
1774 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1776 gAnchorClickedCallBackCalled = false;
1777 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1778 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1779 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1780 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1781 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1783 application.SendNotification();
1784 application.Render();
1786 // Create a tap event to touch the text label.
1787 TestGenerateTap(application, 5.0f, 25.0f);
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1792 DALI_TEST_CHECK(anchorClickedSignal);
1795 gAnchorClickedCallBackNotCalled = true;
1796 // Tap the outside of anchor, callback should not be called.
1797 TestGenerateTap(application, 150.f, 100.f);
1798 application.SendNotification();
1799 application.Render();
1801 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);