2 * Copyright (c) 2019 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>
33 using namespace Toolkit;
35 void dali_textlabel_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textlabel_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
51 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
52 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
53 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
56 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
57 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
63 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
64 const char* const PROPERTY_NAME_UNDERLINE = "underline";
65 const char* const PROPERTY_NAME_SHADOW = "shadow";
66 const char* const PROPERTY_NAME_EMBOSS = "emboss";
67 const char* const PROPERTY_NAME_OUTLINE = "outline";
68 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
70 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
71 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
72 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
74 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
75 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
77 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
79 const Property::Map::SizeType size = mapGet.Count();
81 if( size == mapSet.Count() )
83 for( unsigned int index = 0u; index < size; ++index )
85 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
87 // Find the keys of the 'get' map
88 Property::Index indexKey = valueGet.first.indexKey;
89 std::string stringKey = valueGet.first.stringKey;
91 if( !indexConversionTable.empty() )
93 if( stringKey.empty() )
95 stringKey = indexConversionTable[ indexKey ];
98 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
100 Property::Index index = 0u;
101 for( auto key : indexConversionTable )
103 if( key == stringKey )
113 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
115 if( nullptr != valueSet )
117 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
119 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
122 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
124 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
127 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
129 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
132 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
134 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
137 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
139 Vector2 vector2Get = valueGet.second.Get<Vector2>();
140 Vector2 vector2Set = valueSet->Get<Vector2>();
141 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
144 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
146 Vector4 vector4Get = valueGet.second.Get<Vector4>();
147 Vector4 vector4Set = valueSet->Get<Vector4>();
148 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 );
154 if ( valueGet.first.type == Property::Key::INDEX )
156 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
160 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
172 int UtcDaliToolkitTextLabelConstructorP(void)
174 ToolkitTestApplication application;
175 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
177 DALI_TEST_CHECK( !textLabel );
181 int UtcDaliToolkitTextLabelNewP(void)
183 ToolkitTestApplication application;
184 tet_infoline(" UtcDaliToolkitTextLabelNewP");
185 TextLabel textLabel = TextLabel::New( "Test Text" );
186 DALI_TEST_CHECK( textLabel );
190 int UtcDaliToolkitTextLabelDownCastP(void)
192 ToolkitTestApplication application;
193 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
194 TextLabel textLabel1 = TextLabel::New();
195 BaseHandle object( textLabel1 );
197 TextLabel textLabel2 = TextLabel::DownCast( object );
198 DALI_TEST_CHECK( textLabel2 );
200 TextLabel textLabel3 = DownCast< TextLabel >( object );
201 DALI_TEST_CHECK( textLabel3 );
205 int UtcDaliToolkitTextLabelDownCastN(void)
207 ToolkitTestApplication application;
208 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
209 BaseHandle uninitializedObject;
210 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
211 DALI_TEST_CHECK( !textLabel1 );
213 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
214 DALI_TEST_CHECK( !textLabel2 );
218 int UtcDaliToolkitTextLabelCopyConstructorP(void)
220 ToolkitTestApplication application;
221 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
222 TextLabel textLabel = TextLabel::New();
223 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
225 TextLabel copy( textLabel );
226 DALI_TEST_CHECK( copy );
227 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
231 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
233 ToolkitTestApplication application;
234 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
235 TextLabel textLabel = TextLabel::New();
236 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
238 TextLabel copy = textLabel;
239 DALI_TEST_CHECK( copy );
240 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
244 // Positive test case for a method
245 int UtcDaliToolkitTextLabelGetPropertyP(void)
247 ToolkitTestApplication application;
248 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
249 TextLabel label = TextLabel::New("Test Text");
250 DALI_TEST_CHECK( label );
252 // Check Property Indices are correct
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
274 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
275 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
280 int UtcDaliToolkitTextLabelSetPropertyP(void)
282 ToolkitTestApplication application;
283 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
284 TextLabel label = TextLabel::New();
285 DALI_TEST_CHECK( label );
287 Stage::GetCurrent().Add( label );
289 // Note - we can't check the defaults since the stylesheets are platform-specific
290 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
291 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
293 // Check that text can be correctly reset
294 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
295 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
297 // Check font properties.
298 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
299 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
301 Property::Map fontStyleMapSet;
302 Property::Map fontStyleMapGet;
304 fontStyleMapSet.Insert( "weight", "bold" );
305 fontStyleMapSet.Insert( "width", "condensed" );
306 fontStyleMapSet.Insert( "slant", "italic" );
307 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
309 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
310 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
311 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
313 // Check the old font style format.
314 fontStyleMapSet.Clear();
315 fontStyleMapSet.Insert( "weight", "thin" );
316 fontStyleMapSet.Insert( "width", "expanded" );
317 fontStyleMapSet.Insert( "slant", "oblique" );
318 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
320 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
321 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
322 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
324 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
325 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
328 fontStyleMapSet.Clear();
329 fontStyleMapSet.Insert( "weight", "normal" );
330 fontStyleMapSet.Insert( "slant", "oblique" );
332 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
333 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
334 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
335 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
337 fontStyleMapSet.Clear();
338 fontStyleMapSet.Insert( "slant", "roman" );
340 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
341 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
342 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
344 // Replace 'roman' for 'normal'.
345 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
346 if( NULL != slantValue )
348 if( "normal" == slantValue->Get<std::string>() )
350 fontStyleMapGet["slant"] = "roman";
353 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
355 fontStyleMapSet.Clear();
357 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
358 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
359 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
360 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
363 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
364 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
366 // Check that the Alignment properties can be correctly set
367 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
368 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
369 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
370 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
372 // Check that text color can be properly set
373 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
374 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
376 Property::Map underlineMapSet;
377 Property::Map underlineMapGet;
379 underlineMapSet.Insert( "enable", false );
380 underlineMapSet.Insert( "color", Color::BLUE );
381 underlineMapSet.Insert( "height", 0 );
383 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
384 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
385 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
387 TextLabel label2 = TextLabel::New( "New text" );
388 DALI_TEST_CHECK( label2 );
389 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
391 // Check the enable markup property.
392 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
393 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
394 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
396 // Check the text property when markup is enabled
397 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
398 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
400 // Check for incomplete marks.
401 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
402 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
405 application.SendNotification();
406 application.Render();
410 tet_result(TET_FAIL);
413 // Check autoscroll properties
414 const int SCROLL_SPEED = 80;
415 const int SCROLL_LOOPS = 4;
416 const float SCROLL_GAP = 50.0f;
417 const float SCROLL_LOOP_DELAY = 0.3f;
418 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
419 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
421 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
422 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
423 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
424 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
425 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
426 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
427 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
428 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
429 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
430 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
431 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
432 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
434 //Check autoscroll stop type property
435 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
436 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
438 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
439 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
441 // test natural size with multi-line and line spacing
443 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
444 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
445 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
446 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
447 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
449 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
450 // The height of the text when multi-line is enabled will be larger
451 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
452 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
454 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
455 // Everything else will remain the same
456 int lineSpacing = 20;
457 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
458 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
459 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
460 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
463 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
465 TextLabel label3 = TextLabel::New("Some text here end there end here");
466 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
467 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
468 Vector3 textNaturalSize = label3.GetNaturalSize();
469 int lineSpacing = 20;
470 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
471 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
472 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
473 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
475 // Check the line spacing property
476 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
477 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
478 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
480 // Check the underline property
481 underlineMapSet.Clear();
482 underlineMapSet.Insert( "enable", true );
483 underlineMapSet.Insert( "color", Color::RED );
484 underlineMapSet.Insert( "height", 1 );
486 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
488 application.SendNotification();
489 application.Render();
491 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
492 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
493 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
495 underlineMapSet.Clear();
496 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
497 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
498 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
500 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
502 application.SendNotification();
503 application.Render();
505 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
506 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
507 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
508 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
510 underlineMapSet.Clear();
512 Property::Map underlineDisabledMapGet;
513 underlineDisabledMapGet.Insert( "enable", false );
514 underlineDisabledMapGet.Insert( "color", Color::GREEN );
515 underlineDisabledMapGet.Insert( "height", 2 );
517 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
519 application.SendNotification();
520 application.Render();
522 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
523 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
524 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
526 // Check the shadow property
528 Property::Map shadowMapSet;
529 Property::Map shadowMapGet;
531 shadowMapSet.Insert( "color", Color::GREEN );
532 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
533 shadowMapSet.Insert( "blurRadius", 5.0f );
535 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
537 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
538 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
539 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
541 shadowMapSet.Clear();
543 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
544 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
545 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
547 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
549 // Replace the offset (string) by a vector2
550 shadowMapSet.Clear();
551 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
552 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
553 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
555 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
556 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
557 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
558 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
560 shadowMapSet.Clear();
561 Property::Map shadowDisabledMapGet;
562 shadowDisabledMapGet.Insert( "color", Color::BLUE );
563 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
564 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
566 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
568 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
569 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
570 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
572 // Check the emboss property
573 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
574 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
576 // Check the outline property
578 // Test string type first
579 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
580 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
581 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
583 // Then test the property map type
584 Property::Map outlineMapSet;
585 Property::Map outlineMapGet;
587 outlineMapSet["color"] = Color::RED;
588 outlineMapSet["width"] = 2.0f;
589 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
591 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
592 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
593 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
595 outlineMapSet.Clear();
596 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
597 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
598 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
600 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
601 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
602 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
603 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
605 // Check the background property
606 Property::Map backgroundMapSet;
607 Property::Map backgroundMapGet;
609 backgroundMapSet["enable"] = true;
610 backgroundMapSet["color"] = Color::RED;
611 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
613 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
614 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
617 backgroundMapSet.Clear();
618 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
619 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
620 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
622 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
623 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
624 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
625 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
627 // Check the pixel size of font
628 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
629 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 // Check the ellipsis property
632 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
633 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
634 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
636 // Check the layout direction property
637 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
638 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
640 // Check the line size property
641 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
643 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 application.SendNotification();
646 application.Render();
651 int UtcDaliToolkitTextlabelAtlasRenderP(void)
653 ToolkitTestApplication application;
654 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
655 TextLabel label = TextLabel::New("Test Text");
656 DALI_TEST_CHECK( label );
658 // Avoid a crash when core load gl resources.
659 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
661 Stage::GetCurrent().Add( label );
663 // Turn on all the effects
664 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
665 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
667 Property::Map underlineMap;
668 underlineMap.Insert( "enable", true );
669 underlineMap.Insert( "color", Color::RED );
670 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
672 Property::Map shadowMap;
673 shadowMap.Insert( "color", Color::BLUE );
674 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
675 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
679 // Render some text with the shared atlas backend
680 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
681 application.SendNotification();
682 application.Render();
686 tet_result(TET_FAIL);
691 // Render some text with the shared atlas backend
692 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
693 application.SendNotification();
694 application.Render();
698 tet_result(TET_FAIL);
703 int UtcDaliToolkitTextLabelLanguagesP(void)
705 ToolkitTestApplication application;
706 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
707 TextLabel label = TextLabel::New();
708 DALI_TEST_CHECK( label );
710 Stage::GetCurrent().Add( label );
712 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
713 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
714 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
715 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
716 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
717 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
719 label.SetProperty( TextLabel::Property::TEXT, scripts );
720 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
722 application.SendNotification();
723 application.Render();
728 int UtcDaliToolkitTextLabelEmojisP(void)
730 ToolkitTestApplication application;
731 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
732 TextLabel label = TextLabel::New();
733 DALI_TEST_CHECK( label );
735 Stage::GetCurrent().Add( label );
737 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
739 char* pathNamePtr = get_current_dir_name();
740 const std::string pathName( pathNamePtr );
743 TextAbstraction::FontDescription fontDescription;
744 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
745 fontDescription.family = "BreezeColorEmoji";
746 fontDescription.width = TextAbstraction::FontWidth::NONE;
747 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
748 fontDescription.slant = TextAbstraction::FontSlant::NONE;
750 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
752 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>";
753 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
754 label.SetProperty( TextLabel::Property::TEXT, emojis );
756 Property::Map shadowMap;
757 shadowMap.Insert( "color", "green" );
758 shadowMap.Insert( "offset", "2 2" );
759 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
761 application.SendNotification();
762 application.Render();
767 int UtcDaliToolkitTextlabelScrollingP(void)
769 ToolkitTestApplication application;
770 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
771 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
772 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
774 DALI_TEST_CHECK( labelImmediate );
775 DALI_TEST_CHECK( labelFinished );
776 // Avoid a crash when core load gl resources.
777 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
778 Stage::GetCurrent().Add( labelImmediate );
779 // Turn on all the effects
780 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
781 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
782 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
783 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
784 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
786 Stage::GetCurrent().Add( labelFinished );
787 // Turn on all the effects
788 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
789 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
790 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
791 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
792 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
798 // Render some text with the shared atlas backend
799 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
800 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
802 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
803 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
806 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
807 application.SendNotification();
808 application.Render();
810 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
811 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
812 application.SendNotification();
813 application.Render();
818 tet_result(TET_FAIL);
824 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
826 ToolkitTestApplication application;
827 TextLabel labelShort = TextLabel::New("Some text to scroll");
828 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!");
830 DALI_TEST_CHECK( labelShort );
831 DALI_TEST_CHECK( labelLong );
832 // Avoid a crash when core load gl resources.
833 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
834 Stage::GetCurrent().Add( labelShort );
835 // Turn on all the effects
836 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
837 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
838 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
839 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
840 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
841 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
843 Stage::GetCurrent().Add( labelLong );
844 // Turn on all the effects
845 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
846 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
847 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
848 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
849 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
850 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
854 // Render some text with the shared atlas backend
855 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
856 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
857 application.SendNotification();
858 application.Render();
860 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
861 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
862 application.SendNotification();
863 application.Render();
868 tet_result(TET_FAIL);
874 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
876 ToolkitTestApplication application;
877 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
878 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
880 DALI_TEST_CHECK( labelShort );
881 DALI_TEST_CHECK( labelLong );
882 // Avoid a crash when core load gl resources.
883 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
884 Stage::GetCurrent().Add( labelShort );
885 // Turn on all the effects
886 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
887 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
888 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
889 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
890 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
891 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
893 Stage::GetCurrent().Add( labelLong );
894 // Turn on all the effects
895 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
896 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
897 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
898 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
899 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
900 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
904 // Render some text with the shared atlas backend
905 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
906 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
907 application.SendNotification();
908 application.Render();
910 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
911 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
912 application.SendNotification();
913 application.Render();
918 tet_result(TET_FAIL);
924 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
926 ToolkitTestApplication application;
927 TextLabel labelShort = TextLabel::New("Some text to scroll");
928 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!");
930 DALI_TEST_CHECK( labelShort );
931 DALI_TEST_CHECK( labelLong );
932 // Avoid a crash when core load gl resources.
933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
934 Stage::GetCurrent().Add( labelShort );
935 // Turn on all the effects
936 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
937 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
938 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
939 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
940 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
941 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
943 Stage::GetCurrent().Add( labelLong );
944 // Turn on all the effects
945 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
946 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
947 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
948 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
949 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
950 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
954 // Render some text with the shared atlas backend
955 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
956 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
957 application.SendNotification();
958 application.Render();
960 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
961 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
962 application.SendNotification();
963 application.Render();
968 tet_result(TET_FAIL);
974 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
976 ToolkitTestApplication application;
977 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
978 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
980 DALI_TEST_CHECK( labelShort );
981 DALI_TEST_CHECK( labelLong );
982 // Avoid a crash when core load gl resources.
983 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
984 Stage::GetCurrent().Add( labelShort );
985 // Turn on all the effects
986 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
987 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
988 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
989 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
990 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
991 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
993 Stage::GetCurrent().Add( labelLong );
994 // Turn on all the effects
995 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
996 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
997 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
998 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
999 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1000 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1004 // Render some text with the shared atlas backend
1005 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1006 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1007 application.SendNotification();
1008 application.Render();
1010 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1011 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1012 application.SendNotification();
1013 application.Render();
1018 tet_result(TET_FAIL);
1024 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1026 ToolkitTestApplication application;
1027 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1028 TextLabel label = TextLabel::New("Some text to scroll");
1029 DALI_TEST_CHECK( label );
1030 // Avoid a crash when core load gl resources.
1031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1032 Stage::GetCurrent().Add( label );
1033 label.SetSize( 360.0f, 20.f );
1034 // Turn on all the effects
1035 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1036 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1037 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1038 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1041 application.SendNotification();
1042 application.Render();
1044 unsigned int actorCount1 = label.GetChildCount();
1045 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1049 // Render some text with the shared atlas backend
1050 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1051 application.SendNotification();
1052 application.Render(2000);
1054 unsigned int actorCount1 = label.GetChildCount();
1055 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1057 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1060 application.SendNotification();
1061 application.Render();
1063 unsigned int actorCount2 = label.GetChildCount();
1064 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1066 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1071 tet_result(TET_FAIL);
1077 int UtcDaliToolkitTextlabelScrollingN(void)
1079 ToolkitTestApplication application;
1080 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1082 TextLabel label = TextLabel::New("Some text to scroll");
1083 DALI_TEST_CHECK( label );
1085 Stage::GetCurrent().Add( label );
1087 // Avoid a crash when core load gl resources.
1088 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1090 // The text scrolling works only on single line text.
1091 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1093 // Turn on all the effects.
1094 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1095 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1096 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1098 // Enable the auto scrolling effect.
1099 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1101 // The auto scrolling shouldn't be enabled.
1102 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1103 DALI_TEST_CHECK( !enabled );
1108 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1110 ToolkitTestApplication application;
1111 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1113 TextLabel label = TextLabel::New("Some text to scroll");
1114 DALI_TEST_CHECK( label );
1116 Stage::GetCurrent().Add( label );
1118 // Avoid a crash when core load gl resources.
1119 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1121 // Turn on all the effects.
1122 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1123 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1124 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1128 // Enable the auto scrolling effect.
1129 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1130 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1132 // Disable the ellipsis
1133 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1136 application.SendNotification();
1137 application.Render();
1139 // Stop auto scrolling
1140 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1142 // Check the ellipsis property
1143 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1147 tet_result(TET_FAIL);
1153 int UtcDaliToolkitTextlabelEllipsis(void)
1155 ToolkitTestApplication application;
1156 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1158 TextLabel label = TextLabel::New("Hello world");
1159 DALI_TEST_CHECK( label );
1161 // Avoid a crash when core load gl resources.
1162 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1164 Stage::GetCurrent().Add( label );
1166 // Turn on all the effects
1167 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1168 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1169 label.SetSize( 360.0f, 10.f );
1174 application.SendNotification();
1175 application.Render();
1179 tet_result(TET_FAIL);
1182 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1183 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1184 label.SetSize( 400.0f, 10.f );
1189 application.SendNotification();
1190 application.Render();
1194 tet_result(TET_FAIL);
1198 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1199 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1200 label.SetSize( 400.0f, 10.f );
1205 application.SendNotification();
1206 application.Render();
1210 tet_result(TET_FAIL);
1216 int UtcDaliToolkitTextlabelTextWrapMode(void)
1218 ToolkitTestApplication application;
1219 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1223 TextLabel label = TextLabel::New();
1224 label.SetSize( 300.0f, 300.f );
1225 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1226 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1230 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1231 Stage::GetCurrent().Add( label );
1233 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1234 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1236 application.SendNotification();
1237 application.Render();
1239 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1240 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1242 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1243 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1245 application.SendNotification();
1246 application.Render();
1248 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1249 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1251 application.SendNotification();
1252 application.Render();
1254 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1255 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1257 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1258 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1260 application.SendNotification();
1261 application.Render();
1263 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1264 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1266 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1267 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1268 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1273 int UtcDaliToolkitTextLabelColorComponents(void)
1275 ToolkitTestApplication application;
1277 TextLabel label = TextLabel::New();
1278 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1279 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1280 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1281 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1282 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1284 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1285 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1286 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1287 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1288 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1290 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1291 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1292 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1293 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1294 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1296 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1297 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1298 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1299 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1301 // Test a transparent text - Rendering should be skipped.
1302 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1303 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1305 Stage::GetCurrent().Add( label );
1307 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1308 drawTrace.Enable( true );
1310 application.SendNotification();
1311 application.Render();
1313 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1315 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1324 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1328 application.SendNotification();
1329 application.Render();
1331 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1336 int UtcDaliToolkitTextlabelTextStyle01(void)
1338 ToolkitTestApplication application;
1339 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1341 TextLabel label = TextLabel::New();
1342 label.SetSize( 300.0f, 300.f );
1343 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1344 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1345 Stage::GetCurrent().Add( label );
1347 Property::Map outlineMapSet;
1348 Property::Map outlineMapGet;
1350 outlineMapSet["color"] = Color::BLUE;
1351 outlineMapSet["width"] = 2.0f;
1352 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1354 application.SendNotification();
1355 application.Render();
1357 Property::Map shadowMapSet;
1358 shadowMapSet.Insert( "color", "green" );
1359 shadowMapSet.Insert( "offset", "2 2" );
1360 shadowMapSet.Insert( "blurRadius", "3" );
1361 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1363 outlineMapSet["color"] = Color::RED;
1364 outlineMapSet["width"] = 0.0f;
1365 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1367 application.SendNotification();
1368 application.Render();
1370 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1372 Property::Value* colorValue = outlineMapGet.Find("color");
1374 bool colorMatched( false );
1378 Property::Type valueType = colorValue->GetType();
1380 if ( Property::STRING == valueType )
1382 std::string stringValue;
1383 colorValue->Get( stringValue );
1384 if ( stringValue == "red" )
1386 colorMatched = true;
1389 else if ( Property::VECTOR4 == valueType )
1391 Vector4 colorVector4;
1392 colorValue->Get( colorVector4 );
1393 if ( colorVector4 == Color::RED )
1395 colorMatched = true;
1400 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1405 int UtcDaliToolkitTextlabelMultiline(void)
1407 ToolkitTestApplication application;
1408 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1410 TextLabel label = TextLabel::New();
1411 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1412 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1413 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1414 Stage::GetCurrent().Add( label );
1416 application.SendNotification();
1417 application.Render();
1419 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1420 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1422 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1424 application.SendNotification();
1425 application.Render();
1427 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1428 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1434 int UtcDaliToolkitTextlabelTextDirection(void)
1436 ToolkitTestApplication application;
1437 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1439 TextLabel label = TextLabel::New();
1440 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1442 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1443 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1444 Stage::GetCurrent().Add( label );
1447 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1450 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1451 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1453 // Test RTL text starting with weak character
1454 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1455 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1457 // Test RTL text string with emoji and weak character
1458 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1459 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1464 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1466 ToolkitTestApplication application;
1467 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1469 TextLabel label = TextLabel::New();
1471 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1472 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1473 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1474 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1475 Stage::GetCurrent().Add( label );
1476 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1478 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1479 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1481 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1482 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1487 int UtcDaliToolkitTextLabelBitmapFont(void)
1489 ToolkitTestApplication application;
1490 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1492 DevelText::BitmapFontDescription fontDescription;
1493 fontDescription.name = "Digits";
1494 fontDescription.underlinePosition = 0.f;
1495 fontDescription.underlineThickness = 0.f;
1497 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1498 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1499 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1500 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1501 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1502 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1503 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1504 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1505 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1506 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1507 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1509 TextAbstraction::BitmapFont bitmapFont;
1510 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1512 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1513 fontClient.GetFontId( bitmapFont );
1515 TextLabel label = TextLabel::New();
1517 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1518 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1520 // 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.
1521 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1523 Stage::GetCurrent().Add( label );
1525 application.SendNotification();
1526 application.Render();
1528 // The text has been rendered if the height of the text-label is the height of the line.
1529 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1534 int ConvertPointToPixel( float point )
1536 unsigned int horizontalDpi = 0u;
1537 unsigned int verticalDpi = 0u;
1538 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1539 fontClient.GetDpi( horizontalDpi, verticalDpi );
1541 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1544 int UtcDaliToolkitTextlabelTextFit(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1548 TextLabel label = TextLabel::New();
1549 Vector2 size( 460.0f, 100.0f );
1550 label.SetSize( size );
1551 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1554 Property::Map textFitMapSet;
1555 textFitMapSet["enable"] = true;
1556 textFitMapSet["minSize"] = 10.f;
1557 textFitMapSet["maxSize"] = 100.f;
1558 textFitMapSet["stepSize"] = -1.f;
1559 textFitMapSet["fontSizeType"] = "pointSize";
1561 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1562 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1564 Stage::GetCurrent().Add( label );
1566 application.SendNotification();
1567 application.Render();
1569 const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
1570 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1573 textFitMapSet.Clear();
1574 textFitMapSet["enable"] = true;
1575 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1576 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1577 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1578 textFitMapSet["fontSizeType"] = "pixelSize";
1580 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1582 application.SendNotification();
1583 application.Render();
1585 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1590 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1592 ToolkitTestApplication application;
1593 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1595 DevelText::BitmapFontDescription fontDescription;
1596 fontDescription.name = "Digits";
1597 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1599 TextAbstraction::BitmapFont bitmapFont;
1600 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1602 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1603 fontClient.GetFontId( bitmapFont );
1605 TextLabel label = TextLabel::New();
1606 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1607 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1608 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1609 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1610 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1612 Property::Map underlineMapSet;
1613 underlineMapSet.Clear();
1614 underlineMapSet.Insert( "enable", true );
1615 underlineMapSet.Insert( "color", Color::RED );
1616 underlineMapSet.Insert( "height", 1 );
1617 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1618 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1620 Stage::GetCurrent().Add( label );
1622 application.SendNotification();
1623 application.Render();
1625 const int maxTextureSize = Dali::GetMaxTextureSize();
1626 // Whether the rendered text is greater than maxTextureSize
1627 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1629 // Check if the number of renderers is greater than 1.
1630 DALI_TEST_CHECK( label.GetRendererCount() > 1u );