2 * Copyright (c) 2020 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 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
82 const Property::Map::SizeType size = mapGet.Count();
84 if( size == mapSet.Count() )
86 for( unsigned int index = 0u; index < size; ++index )
88 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
90 // Find the keys of the 'get' map
91 Property::Index indexKey = valueGet.first.indexKey;
92 std::string stringKey = valueGet.first.stringKey;
94 if( !indexConversionTable.empty() )
96 if( stringKey.empty() )
98 stringKey = indexConversionTable[ indexKey ];
101 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
103 Property::Index index = 0u;
104 for( auto key : indexConversionTable )
106 if( key == stringKey )
116 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
118 if( nullptr != valueSet )
120 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
122 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
125 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
127 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
130 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
132 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
135 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
137 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
140 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
142 Vector2 vector2Get = valueGet.second.Get<Vector2>();
143 Vector2 vector2Set = valueSet->Get<Vector2>();
144 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
147 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
149 Vector4 vector4Get = valueGet.second.Get<Vector4>();
150 Vector4 vector4Set = valueSet->Get<Vector4>();
151 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 );
157 if ( valueGet.first.type == Property::Key::INDEX )
159 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
163 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
175 int UtcDaliToolkitTextLabelConstructorP(void)
177 ToolkitTestApplication application;
178 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
180 DALI_TEST_CHECK( !textLabel );
184 int UtcDaliToolkitTextLabelNewP(void)
186 ToolkitTestApplication application;
187 tet_infoline(" UtcDaliToolkitTextLabelNewP");
188 TextLabel textLabel = TextLabel::New( "Test Text" );
189 DALI_TEST_CHECK( textLabel );
193 int UtcDaliToolkitTextLabelDownCastP(void)
195 ToolkitTestApplication application;
196 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
197 TextLabel textLabel1 = TextLabel::New();
198 BaseHandle object( textLabel1 );
200 TextLabel textLabel2 = TextLabel::DownCast( object );
201 DALI_TEST_CHECK( textLabel2 );
203 TextLabel textLabel3 = DownCast< TextLabel >( object );
204 DALI_TEST_CHECK( textLabel3 );
208 int UtcDaliToolkitTextLabelDownCastN(void)
210 ToolkitTestApplication application;
211 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
212 BaseHandle uninitializedObject;
213 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
214 DALI_TEST_CHECK( !textLabel1 );
216 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
217 DALI_TEST_CHECK( !textLabel2 );
221 int UtcDaliToolkitTextLabelCopyConstructorP(void)
223 ToolkitTestApplication application;
224 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
225 TextLabel textLabel = TextLabel::New();
226 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
228 TextLabel copy( textLabel );
229 DALI_TEST_CHECK( copy );
230 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
234 int UtcDaliTextLabelMoveConstructor(void)
236 ToolkitTestApplication application;
238 TextLabel textLabel = TextLabel::New();
239 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
240 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
242 TextLabel moved = std::move( textLabel );
243 DALI_TEST_CHECK( moved );
244 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
245 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
246 DALI_TEST_CHECK( !textLabel );
251 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
253 ToolkitTestApplication application;
254 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
255 TextLabel textLabel = TextLabel::New();
256 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
258 TextLabel copy = textLabel;
259 DALI_TEST_CHECK( copy );
260 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
264 int UtcDaliTextLabelMoveAssignment(void)
266 ToolkitTestApplication application;
268 TextLabel textLabel = TextLabel::New();
269 textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
270 DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
273 moved = std::move( textLabel );
274 DALI_TEST_CHECK( moved );
275 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
276 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
277 DALI_TEST_CHECK( !textLabel );
282 // Positive test case for a method
283 int UtcDaliToolkitTextLabelGetPropertyP(void)
285 ToolkitTestApplication application;
286 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
287 TextLabel label = TextLabel::New("Test Text");
288 DALI_TEST_CHECK( label );
290 // Check Property Indices are correct
291 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
292 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
293 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
294 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
295 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
296 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
297 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
298 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
299 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
300 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
301 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
302 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
303 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
304 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
305 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
306 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
307 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
308 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
309 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
310 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
311 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
312 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
313 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
314 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
319 int UtcDaliToolkitTextLabelSetPropertyP(void)
321 ToolkitTestApplication application;
322 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
323 TextLabel label = TextLabel::New();
324 DALI_TEST_CHECK( label );
326 application.GetScene().Add( label );
328 // Note - we can't check the defaults since the stylesheets are platform-specific
329 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
330 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
332 // Check that text can be correctly reset
333 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
334 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
336 // Check font properties.
337 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
338 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
340 Property::Map fontStyleMapSet;
341 Property::Map fontStyleMapGet;
343 fontStyleMapSet.Insert( "weight", "bold" );
344 fontStyleMapSet.Insert( "width", "condensed" );
345 fontStyleMapSet.Insert( "slant", "italic" );
346 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
348 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
349 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
350 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
352 // Check the old font style format.
353 fontStyleMapSet.Clear();
354 fontStyleMapSet.Insert( "weight", "thin" );
355 fontStyleMapSet.Insert( "width", "expanded" );
356 fontStyleMapSet.Insert( "slant", "oblique" );
357 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
359 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
360 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
361 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
363 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
364 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
366 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
367 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
368 label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
371 fontStyleMapSet.Clear();
372 fontStyleMapSet.Insert( "weight", "normal" );
373 fontStyleMapSet.Insert( "slant", "oblique" );
375 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
376 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
377 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
378 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
380 fontStyleMapSet.Clear();
381 fontStyleMapSet.Insert( "slant", "roman" );
383 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
384 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
385 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
387 // Replace 'roman' for 'normal'.
388 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
389 if( NULL != slantValue )
391 if( "normal" == slantValue->Get<std::string>() )
393 fontStyleMapGet["slant"] = "roman";
396 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
398 fontStyleMapSet.Clear();
400 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
401 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
402 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
403 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
406 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
407 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
409 // Check that the Alignment properties can be correctly set
410 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
411 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
412 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
413 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
415 // Check that text color can be properly set
416 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
417 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
419 Property::Map underlineMapSet;
420 Property::Map underlineMapGet;
422 underlineMapSet.Insert( "enable", false );
423 underlineMapSet.Insert( "color", Color::BLUE );
424 underlineMapSet.Insert( "height", 0 );
426 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
427 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
428 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
430 TextLabel label2 = TextLabel::New( "New text" );
431 DALI_TEST_CHECK( label2 );
432 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
434 // Check the enable markup property.
435 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
436 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
437 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
439 // Check the text property when markup is enabled
440 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
441 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
443 // Check for incomplete marks.
444 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
445 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
448 application.SendNotification();
449 application.Render();
453 tet_result(TET_FAIL);
456 // Check autoscroll properties
457 const int SCROLL_SPEED = 80;
458 const int SCROLL_LOOPS = 4;
459 const float SCROLL_GAP = 50.0f;
460 const float SCROLL_LOOP_DELAY = 0.3f;
461 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
462 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
464 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
465 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
466 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
467 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
468 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
469 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
470 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
471 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
472 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
473 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
474 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
475 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
477 //Check autoscroll stop type property
478 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
479 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
481 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
482 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
484 // test natural size with multi-line and line spacing
486 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
487 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
488 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
489 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
490 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
492 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
493 // The height of the text when multi-line is enabled will be larger
494 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
495 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
497 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
498 // Everything else will remain the same
499 int lineSpacing = 20;
500 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
501 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
502 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
503 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
506 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
508 TextLabel label3 = TextLabel::New("Some text here end there end here");
509 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
510 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
511 Vector3 textNaturalSize = label3.GetNaturalSize();
512 int lineSpacing = 20;
513 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
514 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
515 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
516 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
518 // Check the line spacing property
519 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
520 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
521 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
523 // Check the underline property
524 underlineMapSet.Clear();
525 underlineMapSet.Insert( "enable", true );
526 underlineMapSet.Insert( "color", Color::RED );
527 underlineMapSet.Insert( "height", 1 );
529 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
531 application.SendNotification();
532 application.Render();
534 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
535 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
536 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
538 underlineMapSet.Clear();
539 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
540 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
541 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
543 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
545 application.SendNotification();
546 application.Render();
548 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
549 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
550 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
551 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
553 underlineMapSet.Clear();
555 Property::Map underlineDisabledMapGet;
556 underlineDisabledMapGet.Insert( "enable", false );
557 underlineDisabledMapGet.Insert( "color", Color::GREEN );
558 underlineDisabledMapGet.Insert( "height", 2 );
560 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
562 application.SendNotification();
563 application.Render();
565 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
566 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
567 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
569 // Check the shadow property
571 Property::Map shadowMapSet;
572 Property::Map shadowMapGet;
574 shadowMapSet.Insert( "color", Color::GREEN );
575 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
576 shadowMapSet.Insert( "blurRadius", 5.0f );
578 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
580 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
581 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
582 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
584 shadowMapSet.Clear();
586 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
587 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
588 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
590 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
592 // Replace the offset (string) by a vector2
593 shadowMapSet.Clear();
594 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
595 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
596 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
598 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
599 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
600 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
601 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
603 shadowMapSet.Clear();
604 Property::Map shadowDisabledMapGet;
605 shadowDisabledMapGet.Insert( "color", Color::BLUE );
606 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
607 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
609 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
611 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
612 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
613 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
615 // Check the emboss property
616 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
617 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
619 // Check the outline property
621 // Test string type first
622 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
623 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
624 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
626 // Then test the property map type
627 Property::Map outlineMapSet;
628 Property::Map outlineMapGet;
630 outlineMapSet["color"] = Color::RED;
631 outlineMapSet["width"] = 2.0f;
632 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
634 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
635 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
636 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
638 outlineMapSet.Clear();
639 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
640 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
641 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
643 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
644 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
645 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
646 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
648 // Check the background property
649 Property::Map backgroundMapSet;
650 Property::Map backgroundMapGet;
652 backgroundMapSet["enable"] = true;
653 backgroundMapSet["color"] = Color::RED;
654 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
656 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
657 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
658 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
660 backgroundMapSet.Clear();
661 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
662 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
663 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
665 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
666 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
667 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
668 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
670 // Check the pixel size of font
671 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
672 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
674 // Check the ellipsis property
675 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
676 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
677 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
679 // Check the layout direction property
680 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
681 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
683 // Check the line size property
684 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
686 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 application.SendNotification();
689 application.Render();
694 int UtcDaliToolkitTextlabelAtlasRenderP(void)
696 ToolkitTestApplication application;
697 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
698 TextLabel label = TextLabel::New("Test Text");
699 DALI_TEST_CHECK( label );
701 // Avoid a crash when core load gl resources.
702 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
704 application.GetScene().Add( label );
706 // Turn on all the effects
707 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
708 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
710 Property::Map underlineMap;
711 underlineMap.Insert( "enable", true );
712 underlineMap.Insert( "color", Color::RED );
713 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
715 Property::Map shadowMap;
716 shadowMap.Insert( "color", Color::BLUE );
717 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
718 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
722 // Render some text with the shared atlas backend
723 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
724 application.SendNotification();
725 application.Render();
729 tet_result(TET_FAIL);
734 // Render some text with the shared atlas backend
735 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
736 application.SendNotification();
737 application.Render();
741 tet_result(TET_FAIL);
746 int UtcDaliToolkitTextLabelLanguagesP(void)
748 ToolkitTestApplication application;
749 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
750 TextLabel label = TextLabel::New();
751 DALI_TEST_CHECK( label );
753 application.GetScene().Add( label );
755 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
756 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
757 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
758 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
759 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
760 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
762 label.SetProperty( TextLabel::Property::TEXT, scripts );
763 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
765 application.SendNotification();
766 application.Render();
771 int UtcDaliToolkitTextLabelEmojisP(void)
773 ToolkitTestApplication application;
774 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
775 TextLabel label = TextLabel::New();
776 DALI_TEST_CHECK( label );
778 application.GetScene().Add( label );
780 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
782 char* pathNamePtr = get_current_dir_name();
783 const std::string pathName( pathNamePtr );
786 TextAbstraction::FontDescription fontDescription;
787 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
788 fontDescription.family = "BreezeColorEmoji";
789 fontDescription.width = TextAbstraction::FontWidth::NONE;
790 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
791 fontDescription.slant = TextAbstraction::FontSlant::NONE;
793 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
795 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>";
796 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
797 label.SetProperty( TextLabel::Property::TEXT, emojis );
799 Property::Map shadowMap;
800 shadowMap.Insert( "color", "green" );
801 shadowMap.Insert( "offset", "2 2" );
802 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
804 application.SendNotification();
805 application.Render();
810 int UtcDaliToolkitTextlabelScrollingP(void)
812 ToolkitTestApplication application;
813 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
814 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
815 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
817 DALI_TEST_CHECK( labelImmediate );
818 DALI_TEST_CHECK( labelFinished );
819 // Avoid a crash when core load gl resources.
820 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
821 application.GetScene().Add( labelImmediate );
822 // Turn on all the effects
823 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
824 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
825 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
826 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
827 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
829 application.GetScene().Add( labelFinished );
830 // Turn on all the effects
831 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
832 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
833 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
834 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
835 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
841 // Render some text with the shared atlas backend
842 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
843 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
845 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
846 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
848 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
849 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
850 application.SendNotification();
851 application.Render();
853 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
854 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
855 application.SendNotification();
856 application.Render();
861 tet_result(TET_FAIL);
867 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
869 ToolkitTestApplication application;
870 TextLabel labelShort = TextLabel::New("Some text to scroll");
871 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!");
873 DALI_TEST_CHECK( labelShort );
874 DALI_TEST_CHECK( labelLong );
875 // Avoid a crash when core load gl resources.
876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
877 application.GetScene().Add( labelShort );
878 // Turn on all the effects
879 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
880 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
881 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
882 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
883 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
884 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
886 application.GetScene().Add( labelLong );
887 // Turn on all the effects
888 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
889 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
890 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
891 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
892 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
893 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
897 // Render some text with the shared atlas backend
898 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
899 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
900 application.SendNotification();
901 application.Render();
903 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
904 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
905 application.SendNotification();
906 application.Render();
911 tet_result(TET_FAIL);
917 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
919 ToolkitTestApplication application;
920 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
921 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
923 DALI_TEST_CHECK( labelShort );
924 DALI_TEST_CHECK( labelLong );
925 // Avoid a crash when core load gl resources.
926 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
927 application.GetScene().Add( labelShort );
928 // Turn on all the effects
929 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
930 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
931 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
932 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
933 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
934 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
936 application.GetScene().Add( labelLong );
937 // Turn on all the effects
938 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
939 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
940 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
941 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
942 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
943 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
947 // Render some text with the shared atlas backend
948 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
949 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
950 application.SendNotification();
951 application.Render();
953 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
954 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
955 application.SendNotification();
956 application.Render();
961 tet_result(TET_FAIL);
967 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
969 ToolkitTestApplication application;
970 TextLabel labelShort = TextLabel::New("Some text to scroll");
971 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!");
973 DALI_TEST_CHECK( labelShort );
974 DALI_TEST_CHECK( labelLong );
975 // Avoid a crash when core load gl resources.
976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
977 application.GetScene().Add( labelShort );
978 // Turn on all the effects
979 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
980 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
981 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
982 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
983 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
984 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
986 application.GetScene().Add( labelLong );
987 // Turn on all the effects
988 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
989 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
990 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
991 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
992 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
993 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
997 // Render some text with the shared atlas backend
998 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
999 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1000 application.SendNotification();
1001 application.Render();
1003 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1004 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1005 application.SendNotification();
1006 application.Render();
1011 tet_result(TET_FAIL);
1017 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1019 ToolkitTestApplication application;
1020 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1021 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1023 DALI_TEST_CHECK( labelShort );
1024 DALI_TEST_CHECK( labelLong );
1025 // Avoid a crash when core load gl resources.
1026 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1027 application.GetScene().Add( labelShort );
1028 // Turn on all the effects
1029 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1030 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1031 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1032 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1033 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1034 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1036 application.GetScene().Add( labelLong );
1037 // Turn on all the effects
1038 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1039 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1040 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1041 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1042 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1043 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1047 // Render some text with the shared atlas backend
1048 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1049 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1050 application.SendNotification();
1051 application.Render();
1053 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1054 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1055 application.SendNotification();
1056 application.Render();
1061 tet_result(TET_FAIL);
1067 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1069 ToolkitTestApplication application;
1070 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1071 TextLabel label = TextLabel::New("Some text to scroll");
1072 DALI_TEST_CHECK( label );
1073 // Avoid a crash when core load gl resources.
1074 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1075 application.GetScene().Add( label );
1076 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1077 // Turn on all the effects
1078 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1079 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1080 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1081 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1084 application.SendNotification();
1085 application.Render();
1087 unsigned int actorCount1 = label.GetChildCount();
1088 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1092 // Render some text with the shared atlas backend
1093 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1094 application.SendNotification();
1095 application.Render(2000);
1097 unsigned int actorCount1 = label.GetChildCount();
1098 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1100 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1103 application.SendNotification();
1104 application.Render();
1106 unsigned int actorCount2 = label.GetChildCount();
1107 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1109 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1114 tet_result(TET_FAIL);
1120 int UtcDaliToolkitTextlabelScrollingN(void)
1122 ToolkitTestApplication application;
1123 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1125 TextLabel label = TextLabel::New("Some text to scroll");
1126 DALI_TEST_CHECK( label );
1128 application.GetScene().Add( label );
1130 // Avoid a crash when core load gl resources.
1131 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1133 // The text scrolling works only on single line text.
1134 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1136 // Turn on all the effects.
1137 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1138 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1139 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1141 // Enable the auto scrolling effect.
1142 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1144 // The auto scrolling shouldn't be enabled.
1145 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1146 DALI_TEST_CHECK( !enabled );
1151 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1153 ToolkitTestApplication application;
1154 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1156 TextLabel label = TextLabel::New("Some text to scroll");
1157 DALI_TEST_CHECK( label );
1159 application.GetScene().Add( label );
1161 // Avoid a crash when core load gl resources.
1162 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1164 // Turn on all the effects.
1165 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1166 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1167 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1171 // Enable the auto scrolling effect.
1172 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1173 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1175 // Disable the ellipsis
1176 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1179 application.SendNotification();
1180 application.Render();
1182 // Stop auto scrolling
1183 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1185 // Check the ellipsis property
1186 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1190 tet_result(TET_FAIL);
1196 int UtcDaliToolkitTextlabelEllipsis(void)
1198 ToolkitTestApplication application;
1199 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1201 TextLabel label = TextLabel::New("Hello world");
1202 DALI_TEST_CHECK( label );
1204 // Avoid a crash when core load gl resources.
1205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1207 application.GetScene().Add( label );
1209 // Turn on all the effects
1210 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1211 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1212 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1217 application.SendNotification();
1218 application.Render();
1222 tet_result(TET_FAIL);
1225 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1226 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1227 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1232 application.SendNotification();
1233 application.Render();
1237 tet_result(TET_FAIL);
1241 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1242 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1243 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1248 application.SendNotification();
1249 application.Render();
1253 tet_result(TET_FAIL);
1259 int UtcDaliToolkitTextlabelTextWrapMode(void)
1261 ToolkitTestApplication application;
1262 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1266 TextLabel label = TextLabel::New();
1267 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1268 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1269 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1273 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1274 application.GetScene().Add( label );
1276 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1277 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1279 application.SendNotification();
1280 application.Render();
1282 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1283 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1285 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1286 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1288 application.SendNotification();
1289 application.Render();
1291 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1292 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1294 application.SendNotification();
1295 application.Render();
1297 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1298 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1300 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1301 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1303 application.SendNotification();
1304 application.Render();
1306 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1307 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1309 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1310 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1311 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1316 int UtcDaliToolkitTextLabelColorComponents(void)
1318 ToolkitTestApplication application;
1320 TextLabel label = TextLabel::New();
1321 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1322 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1323 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1324 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1325 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1327 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1328 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1329 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1330 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1331 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1333 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1334 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1335 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1336 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1337 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1339 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1340 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1343 // Test a transparent text - Rendering should be skipped.
1344 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1345 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1347 application.GetScene().Add( label );
1349 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1350 drawTrace.Enable( true );
1352 application.SendNotification();
1353 application.Render();
1355 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1357 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1361 application.SendNotification();
1362 application.Render();
1364 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1366 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1370 application.SendNotification();
1371 application.Render();
1373 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1378 int UtcDaliToolkitTextlabelTextStyle01(void)
1380 ToolkitTestApplication application;
1381 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1383 TextLabel label = TextLabel::New();
1384 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1385 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1386 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1387 application.GetScene().Add( label );
1389 Property::Map outlineMapSet;
1390 Property::Map outlineMapGet;
1392 outlineMapSet["color"] = Color::BLUE;
1393 outlineMapSet["width"] = 2.0f;
1394 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1396 application.SendNotification();
1397 application.Render();
1399 Property::Map shadowMapSet;
1400 shadowMapSet.Insert( "color", "green" );
1401 shadowMapSet.Insert( "offset", "2 2" );
1402 shadowMapSet.Insert( "blurRadius", "3" );
1403 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1405 outlineMapSet["color"] = Color::RED;
1406 outlineMapSet["width"] = 0.0f;
1407 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1409 application.SendNotification();
1410 application.Render();
1412 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1414 Property::Value* colorValue = outlineMapGet.Find("color");
1416 bool colorMatched( false );
1420 Property::Type valueType = colorValue->GetType();
1422 if ( Property::STRING == valueType )
1424 std::string stringValue;
1425 colorValue->Get( stringValue );
1426 if ( stringValue == "red" )
1428 colorMatched = true;
1431 else if ( Property::VECTOR4 == valueType )
1433 Vector4 colorVector4;
1434 colorValue->Get( colorVector4 );
1435 if ( colorVector4 == Color::RED )
1437 colorMatched = true;
1442 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1447 int UtcDaliToolkitTextlabelMultiline(void)
1449 ToolkitTestApplication application;
1450 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1452 TextLabel label = TextLabel::New();
1453 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1454 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1455 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1456 application.GetScene().Add( label );
1458 application.SendNotification();
1459 application.Render();
1461 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1462 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1464 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1466 application.SendNotification();
1467 application.Render();
1469 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1470 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1476 int UtcDaliToolkitTextlabelTextDirection(void)
1478 ToolkitTestApplication application;
1479 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1481 TextLabel label = TextLabel::New();
1482 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1484 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1485 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1486 application.GetScene().Add( label );
1489 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1492 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1493 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1495 // Test RTL text starting with weak character
1496 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1497 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1499 // Test RTL text string with emoji and weak character
1500 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1501 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1506 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1508 ToolkitTestApplication application;
1509 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1511 TextLabel label = TextLabel::New();
1513 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1514 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1515 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1516 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1517 application.GetScene().Add( label );
1518 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1520 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1521 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1523 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1524 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1529 int UtcDaliToolkitTextLabelBitmapFont(void)
1531 ToolkitTestApplication application;
1532 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1534 DevelText::BitmapFontDescription fontDescription;
1535 fontDescription.name = "Digits";
1536 fontDescription.underlinePosition = 0.f;
1537 fontDescription.underlineThickness = 0.f;
1539 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1540 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1541 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1542 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1543 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1544 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1545 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1546 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1547 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1548 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1549 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1551 TextAbstraction::BitmapFont bitmapFont;
1552 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1554 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1555 fontClient.GetFontId( bitmapFont );
1557 TextLabel label = TextLabel::New();
1559 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1560 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1562 // 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.
1563 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1565 application.GetScene().Add( label );
1567 application.SendNotification();
1568 application.Render();
1570 // The text has been rendered if the height of the text-label is the height of the line.
1571 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1576 int ConvertPointToPixel( float point )
1578 unsigned int horizontalDpi = 0u;
1579 unsigned int verticalDpi = 0u;
1580 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1581 fontClient.GetDpi( horizontalDpi, verticalDpi );
1583 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1586 int UtcDaliToolkitTextlabelTextFit(void)
1588 ToolkitTestApplication application;
1589 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1590 TextLabel label = TextLabel::New();
1591 Vector2 size( 460.0f, 100.0f );
1592 label.SetProperty( Actor::Property::SIZE, size );
1593 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1596 Property::Map textFitMapSet;
1597 textFitMapSet["enable"] = true;
1598 textFitMapSet["minSize"] = 10.f;
1599 textFitMapSet["maxSize"] = 100.f;
1600 textFitMapSet["stepSize"] = -1.f;
1601 textFitMapSet["fontSizeType"] = "pointSize";
1603 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1604 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1606 application.GetScene().Add( label );
1608 application.SendNotification();
1609 application.Render();
1611 const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1612 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1615 textFitMapSet.Clear();
1616 textFitMapSet["enable"] = true;
1617 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1618 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1619 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1620 textFitMapSet["fontSizeType"] = "pixelSize";
1622 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1624 application.SendNotification();
1625 application.Render();
1627 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1632 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1634 ToolkitTestApplication application;
1635 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1637 DevelText::BitmapFontDescription fontDescription;
1638 fontDescription.name = "Digits";
1639 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1641 TextAbstraction::BitmapFont bitmapFont;
1642 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1644 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1645 fontClient.GetFontId( bitmapFont );
1647 TextLabel label = TextLabel::New();
1648 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1649 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1650 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1651 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1652 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1654 Property::Map underlineMapSet;
1655 underlineMapSet.Clear();
1656 underlineMapSet.Insert( "enable", true );
1657 underlineMapSet.Insert( "color", Color::RED );
1658 underlineMapSet.Insert( "height", 1 );
1659 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1660 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1662 application.GetScene().Add( label );
1664 application.SendNotification();
1665 application.Render();
1667 const int maxTextureSize = Dali::GetMaxTextureSize();
1668 // Whether the rendered text is greater than maxTextureSize
1669 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1671 // Check if the number of renderers is greater than 1.
1672 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1677 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1679 ToolkitTestApplication application;
1680 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1682 Vector2 size( 300.0f, 100.0f );
1684 Dali::Toolkit::DevelText::RendererParameters textParameters;
1685 textParameters.text = "This is a sample text to get the last index.";
1686 textParameters.layout = "multiLine";
1687 textParameters.fontSize = 20.f;
1688 textParameters.textWidth = 300u;
1689 textParameters.textHeight = 100u;
1690 textParameters.ellipsisEnabled = true;
1691 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1693 DALI_TEST_CHECK( !indexArray.Empty() );
1694 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1699 int UtcDaliToolkitTextlabelFontSizeScale(void)
1701 ToolkitTestApplication application;
1702 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1704 TextLabel label = TextLabel::New();
1705 label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1706 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1707 Vector3 nonScaledSize = label.GetNaturalSize();
1709 TextLabel labelScaled = TextLabel::New();
1710 labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1711 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1712 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1713 Vector3 scaledSize = labelScaled.GetNaturalSize();
1715 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1717 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1718 label.SetProperty( TextLabel::Property::TEXT, "Test" );
1719 nonScaledSize = label.GetNaturalSize();
1721 labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1722 labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1723 labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1724 scaledSize = labelScaled.GetNaturalSize();
1726 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );