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";
76 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
77 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
79 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
81 const Property::Map::SizeType size = mapGet.Count();
83 if( size == mapSet.Count() )
85 for( unsigned int index = 0u; index < size; ++index )
87 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
89 // Find the keys of the 'get' map
90 Property::Index indexKey = valueGet.first.indexKey;
91 std::string stringKey = valueGet.first.stringKey;
93 if( !indexConversionTable.empty() )
95 if( stringKey.empty() )
97 stringKey = indexConversionTable[ indexKey ];
100 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
102 Property::Index index = 0u;
103 for( auto key : indexConversionTable )
105 if( key == stringKey )
115 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
117 if( nullptr != valueSet )
119 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
121 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
124 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
126 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
129 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
131 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
134 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
136 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
139 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
141 Vector2 vector2Get = valueGet.second.Get<Vector2>();
142 Vector2 vector2Set = valueSet->Get<Vector2>();
143 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
146 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
148 Vector4 vector4Get = valueGet.second.Get<Vector4>();
149 Vector4 vector4Set = valueSet->Get<Vector4>();
150 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 );
156 if ( valueGet.first.type == Property::Key::INDEX )
158 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
162 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
174 int UtcDaliToolkitTextLabelConstructorP(void)
176 ToolkitTestApplication application;
177 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
179 DALI_TEST_CHECK( !textLabel );
183 int UtcDaliToolkitTextLabelNewP(void)
185 ToolkitTestApplication application;
186 tet_infoline(" UtcDaliToolkitTextLabelNewP");
187 TextLabel textLabel = TextLabel::New( "Test Text" );
188 DALI_TEST_CHECK( textLabel );
192 int UtcDaliToolkitTextLabelDownCastP(void)
194 ToolkitTestApplication application;
195 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
196 TextLabel textLabel1 = TextLabel::New();
197 BaseHandle object( textLabel1 );
199 TextLabel textLabel2 = TextLabel::DownCast( object );
200 DALI_TEST_CHECK( textLabel2 );
202 TextLabel textLabel3 = DownCast< TextLabel >( object );
203 DALI_TEST_CHECK( textLabel3 );
207 int UtcDaliToolkitTextLabelDownCastN(void)
209 ToolkitTestApplication application;
210 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
211 BaseHandle uninitializedObject;
212 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
213 DALI_TEST_CHECK( !textLabel1 );
215 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
216 DALI_TEST_CHECK( !textLabel2 );
220 int UtcDaliToolkitTextLabelCopyConstructorP(void)
222 ToolkitTestApplication application;
223 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
224 TextLabel textLabel = TextLabel::New();
225 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
227 TextLabel copy( textLabel );
228 DALI_TEST_CHECK( copy );
229 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
233 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
235 ToolkitTestApplication application;
236 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
237 TextLabel textLabel = TextLabel::New();
238 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
240 TextLabel copy = textLabel;
241 DALI_TEST_CHECK( copy );
242 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
246 // Positive test case for a method
247 int UtcDaliToolkitTextLabelGetPropertyP(void)
249 ToolkitTestApplication application;
250 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
251 TextLabel label = TextLabel::New("Test Text");
252 DALI_TEST_CHECK( label );
254 // Check Property Indices are correct
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
274 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
275 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
276 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
277 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
282 int UtcDaliToolkitTextLabelSetPropertyP(void)
284 ToolkitTestApplication application;
285 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
286 TextLabel label = TextLabel::New();
287 DALI_TEST_CHECK( label );
289 application.GetScene().Add( label );
291 // Note - we can't check the defaults since the stylesheets are platform-specific
292 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
293 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
295 // Check that text can be correctly reset
296 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
297 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
299 // Check font properties.
300 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
301 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
303 Property::Map fontStyleMapSet;
304 Property::Map fontStyleMapGet;
306 fontStyleMapSet.Insert( "weight", "bold" );
307 fontStyleMapSet.Insert( "width", "condensed" );
308 fontStyleMapSet.Insert( "slant", "italic" );
309 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
311 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
312 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
313 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
315 // Check the old font style format.
316 fontStyleMapSet.Clear();
317 fontStyleMapSet.Insert( "weight", "thin" );
318 fontStyleMapSet.Insert( "width", "expanded" );
319 fontStyleMapSet.Insert( "slant", "oblique" );
320 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
322 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
323 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
324 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
326 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
327 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
330 fontStyleMapSet.Clear();
331 fontStyleMapSet.Insert( "weight", "normal" );
332 fontStyleMapSet.Insert( "slant", "oblique" );
334 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
335 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
336 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
337 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
339 fontStyleMapSet.Clear();
340 fontStyleMapSet.Insert( "slant", "roman" );
342 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
343 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
344 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
346 // Replace 'roman' for 'normal'.
347 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
348 if( NULL != slantValue )
350 if( "normal" == slantValue->Get<std::string>() )
352 fontStyleMapGet["slant"] = "roman";
355 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
357 fontStyleMapSet.Clear();
359 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
360 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
361 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
362 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
365 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
366 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
368 // Check that the Alignment properties can be correctly set
369 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
370 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
371 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
372 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
374 // Check that text color can be properly set
375 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
376 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
378 Property::Map underlineMapSet;
379 Property::Map underlineMapGet;
381 underlineMapSet.Insert( "enable", false );
382 underlineMapSet.Insert( "color", Color::BLUE );
383 underlineMapSet.Insert( "height", 0 );
385 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
386 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
387 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
389 TextLabel label2 = TextLabel::New( "New text" );
390 DALI_TEST_CHECK( label2 );
391 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
393 // Check the enable markup property.
394 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
395 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
396 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
398 // Check the text property when markup is enabled
399 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
400 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
402 // Check for incomplete marks.
403 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
404 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
407 application.SendNotification();
408 application.Render();
412 tet_result(TET_FAIL);
415 // Check autoscroll properties
416 const int SCROLL_SPEED = 80;
417 const int SCROLL_LOOPS = 4;
418 const float SCROLL_GAP = 50.0f;
419 const float SCROLL_LOOP_DELAY = 0.3f;
420 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
421 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
423 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
424 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
425 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
426 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
427 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
428 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
429 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
430 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
431 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
432 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
433 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
434 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
436 //Check autoscroll stop type property
437 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
438 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
440 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
441 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
443 // test natural size with multi-line and line spacing
445 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
446 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
447 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
448 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
449 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
451 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
452 // The height of the text when multi-line is enabled will be larger
453 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
454 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
456 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
457 // Everything else will remain the same
458 int lineSpacing = 20;
459 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
460 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
461 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
462 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
465 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
467 TextLabel label3 = TextLabel::New("Some text here end there end here");
468 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
469 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
470 Vector3 textNaturalSize = label3.GetNaturalSize();
471 int lineSpacing = 20;
472 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
473 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
474 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
475 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
477 // Check the line spacing property
478 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
479 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
480 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
482 // Check the underline property
483 underlineMapSet.Clear();
484 underlineMapSet.Insert( "enable", true );
485 underlineMapSet.Insert( "color", Color::RED );
486 underlineMapSet.Insert( "height", 1 );
488 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
490 application.SendNotification();
491 application.Render();
493 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
494 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
495 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
497 underlineMapSet.Clear();
498 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
499 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
500 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
502 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
504 application.SendNotification();
505 application.Render();
507 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
508 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
509 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
510 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
512 underlineMapSet.Clear();
514 Property::Map underlineDisabledMapGet;
515 underlineDisabledMapGet.Insert( "enable", false );
516 underlineDisabledMapGet.Insert( "color", Color::GREEN );
517 underlineDisabledMapGet.Insert( "height", 2 );
519 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
521 application.SendNotification();
522 application.Render();
524 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
525 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
526 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
528 // Check the shadow property
530 Property::Map shadowMapSet;
531 Property::Map shadowMapGet;
533 shadowMapSet.Insert( "color", Color::GREEN );
534 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
535 shadowMapSet.Insert( "blurRadius", 5.0f );
537 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
539 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
540 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
541 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
543 shadowMapSet.Clear();
545 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
546 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
547 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
549 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
551 // Replace the offset (string) by a vector2
552 shadowMapSet.Clear();
553 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
554 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
555 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
557 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
558 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
559 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
560 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
562 shadowMapSet.Clear();
563 Property::Map shadowDisabledMapGet;
564 shadowDisabledMapGet.Insert( "color", Color::BLUE );
565 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
566 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
568 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
570 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
571 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
572 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
574 // Check the emboss property
575 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
576 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
578 // Check the outline property
580 // Test string type first
581 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
582 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
583 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
585 // Then test the property map type
586 Property::Map outlineMapSet;
587 Property::Map outlineMapGet;
589 outlineMapSet["color"] = Color::RED;
590 outlineMapSet["width"] = 2.0f;
591 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
593 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
594 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
595 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
597 outlineMapSet.Clear();
598 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
599 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
600 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
602 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
603 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
604 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
605 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
607 // Check the background property
608 Property::Map backgroundMapSet;
609 Property::Map backgroundMapGet;
611 backgroundMapSet["enable"] = true;
612 backgroundMapSet["color"] = Color::RED;
613 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
615 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
616 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
617 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
619 backgroundMapSet.Clear();
620 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
621 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
622 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
624 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
625 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
626 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
627 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
629 // Check the pixel size of font
630 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
631 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
633 // Check the ellipsis property
634 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
635 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
636 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
638 // Check the layout direction property
639 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
640 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
642 // Check the line size property
643 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
644 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
645 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
647 application.SendNotification();
648 application.Render();
653 int UtcDaliToolkitTextlabelAtlasRenderP(void)
655 ToolkitTestApplication application;
656 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
657 TextLabel label = TextLabel::New("Test Text");
658 DALI_TEST_CHECK( label );
660 // Avoid a crash when core load gl resources.
661 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
663 application.GetScene().Add( label );
665 // Turn on all the effects
666 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
667 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
669 Property::Map underlineMap;
670 underlineMap.Insert( "enable", true );
671 underlineMap.Insert( "color", Color::RED );
672 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
674 Property::Map shadowMap;
675 shadowMap.Insert( "color", Color::BLUE );
676 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
677 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
681 // Render some text with the shared atlas backend
682 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
683 application.SendNotification();
684 application.Render();
688 tet_result(TET_FAIL);
693 // Render some text with the shared atlas backend
694 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
695 application.SendNotification();
696 application.Render();
700 tet_result(TET_FAIL);
705 int UtcDaliToolkitTextLabelLanguagesP(void)
707 ToolkitTestApplication application;
708 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
709 TextLabel label = TextLabel::New();
710 DALI_TEST_CHECK( label );
712 application.GetScene().Add( label );
714 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
715 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
716 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
717 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
718 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
719 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
721 label.SetProperty( TextLabel::Property::TEXT, scripts );
722 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
724 application.SendNotification();
725 application.Render();
730 int UtcDaliToolkitTextLabelEmojisP(void)
732 ToolkitTestApplication application;
733 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
734 TextLabel label = TextLabel::New();
735 DALI_TEST_CHECK( label );
737 application.GetScene().Add( label );
739 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
741 char* pathNamePtr = get_current_dir_name();
742 const std::string pathName( pathNamePtr );
745 TextAbstraction::FontDescription fontDescription;
746 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
747 fontDescription.family = "BreezeColorEmoji";
748 fontDescription.width = TextAbstraction::FontWidth::NONE;
749 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
750 fontDescription.slant = TextAbstraction::FontSlant::NONE;
752 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
754 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>";
755 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
756 label.SetProperty( TextLabel::Property::TEXT, emojis );
758 Property::Map shadowMap;
759 shadowMap.Insert( "color", "green" );
760 shadowMap.Insert( "offset", "2 2" );
761 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
763 application.SendNotification();
764 application.Render();
769 int UtcDaliToolkitTextlabelScrollingP(void)
771 ToolkitTestApplication application;
772 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
773 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
774 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
776 DALI_TEST_CHECK( labelImmediate );
777 DALI_TEST_CHECK( labelFinished );
778 // Avoid a crash when core load gl resources.
779 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
780 application.GetScene().Add( labelImmediate );
781 // Turn on all the effects
782 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
783 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
784 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
785 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
786 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
788 application.GetScene().Add( labelFinished );
789 // Turn on all the effects
790 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
791 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
792 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
793 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
794 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
800 // Render some text with the shared atlas backend
801 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
802 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
804 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
807 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
808 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
809 application.SendNotification();
810 application.Render();
812 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
813 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
814 application.SendNotification();
815 application.Render();
820 tet_result(TET_FAIL);
826 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
828 ToolkitTestApplication application;
829 TextLabel labelShort = TextLabel::New("Some text to scroll");
830 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!");
832 DALI_TEST_CHECK( labelShort );
833 DALI_TEST_CHECK( labelLong );
834 // Avoid a crash when core load gl resources.
835 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
836 application.GetScene().Add( labelShort );
837 // Turn on all the effects
838 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
839 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
840 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
841 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
842 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
843 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
845 application.GetScene().Add( labelLong );
846 // Turn on all the effects
847 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
848 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
849 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
850 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
851 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
852 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
856 // Render some text with the shared atlas backend
857 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
858 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
859 application.SendNotification();
860 application.Render();
862 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
863 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
864 application.SendNotification();
865 application.Render();
870 tet_result(TET_FAIL);
876 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
878 ToolkitTestApplication application;
879 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
880 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
882 DALI_TEST_CHECK( labelShort );
883 DALI_TEST_CHECK( labelLong );
884 // Avoid a crash when core load gl resources.
885 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
886 application.GetScene().Add( labelShort );
887 // Turn on all the effects
888 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
889 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
890 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
891 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
892 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
893 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
895 application.GetScene().Add( labelLong );
896 // Turn on all the effects
897 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
898 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
899 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
900 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
901 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
902 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
906 // Render some text with the shared atlas backend
907 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
908 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
909 application.SendNotification();
910 application.Render();
912 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
913 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
914 application.SendNotification();
915 application.Render();
920 tet_result(TET_FAIL);
926 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
928 ToolkitTestApplication application;
929 TextLabel labelShort = TextLabel::New("Some text to scroll");
930 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!");
932 DALI_TEST_CHECK( labelShort );
933 DALI_TEST_CHECK( labelLong );
934 // Avoid a crash when core load gl resources.
935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
936 application.GetScene().Add( labelShort );
937 // Turn on all the effects
938 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
939 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
940 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
941 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
942 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
943 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
945 application.GetScene().Add( labelLong );
946 // Turn on all the effects
947 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
948 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
949 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
950 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
951 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
952 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
956 // Render some text with the shared atlas backend
957 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
958 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
959 application.SendNotification();
960 application.Render();
962 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
963 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
964 application.SendNotification();
965 application.Render();
970 tet_result(TET_FAIL);
976 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
978 ToolkitTestApplication application;
979 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
980 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
982 DALI_TEST_CHECK( labelShort );
983 DALI_TEST_CHECK( labelLong );
984 // Avoid a crash when core load gl resources.
985 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
986 application.GetScene().Add( labelShort );
987 // Turn on all the effects
988 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
989 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
990 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
991 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
992 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
993 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
995 application.GetScene().Add( labelLong );
996 // Turn on all the effects
997 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
998 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
999 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1000 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1001 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1002 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1006 // Render some text with the shared atlas backend
1007 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1008 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1009 application.SendNotification();
1010 application.Render();
1012 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1013 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1014 application.SendNotification();
1015 application.Render();
1020 tet_result(TET_FAIL);
1026 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1028 ToolkitTestApplication application;
1029 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1030 TextLabel label = TextLabel::New("Some text to scroll");
1031 DALI_TEST_CHECK( label );
1032 // Avoid a crash when core load gl resources.
1033 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1034 application.GetScene().Add( label );
1035 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1036 // Turn on all the effects
1037 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1038 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1039 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1040 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1043 application.SendNotification();
1044 application.Render();
1046 unsigned int actorCount1 = label.GetChildCount();
1047 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1051 // Render some text with the shared atlas backend
1052 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1053 application.SendNotification();
1054 application.Render(2000);
1056 unsigned int actorCount1 = label.GetChildCount();
1057 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1059 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1062 application.SendNotification();
1063 application.Render();
1065 unsigned int actorCount2 = label.GetChildCount();
1066 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1068 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1073 tet_result(TET_FAIL);
1079 int UtcDaliToolkitTextlabelScrollingN(void)
1081 ToolkitTestApplication application;
1082 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1084 TextLabel label = TextLabel::New("Some text to scroll");
1085 DALI_TEST_CHECK( label );
1087 application.GetScene().Add( label );
1089 // Avoid a crash when core load gl resources.
1090 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1092 // The text scrolling works only on single line text.
1093 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1095 // Turn on all the effects.
1096 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1097 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1098 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1100 // Enable the auto scrolling effect.
1101 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1103 // The auto scrolling shouldn't be enabled.
1104 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1105 DALI_TEST_CHECK( !enabled );
1110 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1112 ToolkitTestApplication application;
1113 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1115 TextLabel label = TextLabel::New("Some text to scroll");
1116 DALI_TEST_CHECK( label );
1118 application.GetScene().Add( label );
1120 // Avoid a crash when core load gl resources.
1121 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1123 // Turn on all the effects.
1124 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1125 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1126 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1130 // Enable the auto scrolling effect.
1131 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1132 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1134 // Disable the ellipsis
1135 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1138 application.SendNotification();
1139 application.Render();
1141 // Stop auto scrolling
1142 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1144 // Check the ellipsis property
1145 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1149 tet_result(TET_FAIL);
1155 int UtcDaliToolkitTextlabelEllipsis(void)
1157 ToolkitTestApplication application;
1158 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1160 TextLabel label = TextLabel::New("Hello world");
1161 DALI_TEST_CHECK( label );
1163 // Avoid a crash when core load gl resources.
1164 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1166 application.GetScene().Add( label );
1168 // Turn on all the effects
1169 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1170 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1171 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1176 application.SendNotification();
1177 application.Render();
1181 tet_result(TET_FAIL);
1184 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1185 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1186 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1191 application.SendNotification();
1192 application.Render();
1196 tet_result(TET_FAIL);
1200 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1201 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1202 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1207 application.SendNotification();
1208 application.Render();
1212 tet_result(TET_FAIL);
1218 int UtcDaliToolkitTextlabelTextWrapMode(void)
1220 ToolkitTestApplication application;
1221 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1225 TextLabel label = TextLabel::New();
1226 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1227 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1228 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1232 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1233 application.GetScene().Add( label );
1235 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1236 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1238 application.SendNotification();
1239 application.Render();
1241 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1242 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1244 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1245 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1247 application.SendNotification();
1248 application.Render();
1250 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1251 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1253 application.SendNotification();
1254 application.Render();
1256 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1257 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1259 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1260 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1262 application.SendNotification();
1263 application.Render();
1265 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1266 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1268 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1269 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1270 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1275 int UtcDaliToolkitTextLabelColorComponents(void)
1277 ToolkitTestApplication application;
1279 TextLabel label = TextLabel::New();
1280 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1281 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1282 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1283 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1284 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1286 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1287 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1288 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1289 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1290 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1292 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1293 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1294 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1295 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1296 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1298 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1299 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1300 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1302 // Test a transparent text - Rendering should be skipped.
1303 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1304 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1306 application.GetScene().Add( label );
1308 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1309 drawTrace.Enable( true );
1311 application.SendNotification();
1312 application.Render();
1314 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1316 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1325 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1329 application.SendNotification();
1330 application.Render();
1332 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1337 int UtcDaliToolkitTextlabelTextStyle01(void)
1339 ToolkitTestApplication application;
1340 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1342 TextLabel label = TextLabel::New();
1343 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1344 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1345 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1346 application.GetScene().Add( label );
1348 Property::Map outlineMapSet;
1349 Property::Map outlineMapGet;
1351 outlineMapSet["color"] = Color::BLUE;
1352 outlineMapSet["width"] = 2.0f;
1353 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1355 application.SendNotification();
1356 application.Render();
1358 Property::Map shadowMapSet;
1359 shadowMapSet.Insert( "color", "green" );
1360 shadowMapSet.Insert( "offset", "2 2" );
1361 shadowMapSet.Insert( "blurRadius", "3" );
1362 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1364 outlineMapSet["color"] = Color::RED;
1365 outlineMapSet["width"] = 0.0f;
1366 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1368 application.SendNotification();
1369 application.Render();
1371 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1373 Property::Value* colorValue = outlineMapGet.Find("color");
1375 bool colorMatched( false );
1379 Property::Type valueType = colorValue->GetType();
1381 if ( Property::STRING == valueType )
1383 std::string stringValue;
1384 colorValue->Get( stringValue );
1385 if ( stringValue == "red" )
1387 colorMatched = true;
1390 else if ( Property::VECTOR4 == valueType )
1392 Vector4 colorVector4;
1393 colorValue->Get( colorVector4 );
1394 if ( colorVector4 == Color::RED )
1396 colorMatched = true;
1401 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1406 int UtcDaliToolkitTextlabelMultiline(void)
1408 ToolkitTestApplication application;
1409 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1411 TextLabel label = TextLabel::New();
1412 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1413 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1414 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1415 application.GetScene().Add( label );
1417 application.SendNotification();
1418 application.Render();
1420 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1421 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1423 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1425 application.SendNotification();
1426 application.Render();
1428 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1429 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1435 int UtcDaliToolkitTextlabelTextDirection(void)
1437 ToolkitTestApplication application;
1438 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1440 TextLabel label = TextLabel::New();
1441 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1443 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1444 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1445 application.GetScene().Add( label );
1448 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1451 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1452 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1454 // Test RTL text starting with weak character
1455 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1456 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1458 // Test RTL text string with emoji and weak character
1459 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1460 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1465 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1467 ToolkitTestApplication application;
1468 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1470 TextLabel label = TextLabel::New();
1472 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1473 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1474 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1475 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1476 application.GetScene().Add( label );
1477 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1479 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1480 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1482 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1483 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1488 int UtcDaliToolkitTextLabelBitmapFont(void)
1490 ToolkitTestApplication application;
1491 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1493 DevelText::BitmapFontDescription fontDescription;
1494 fontDescription.name = "Digits";
1495 fontDescription.underlinePosition = 0.f;
1496 fontDescription.underlineThickness = 0.f;
1498 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1499 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1500 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1501 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1502 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1503 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1504 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1505 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1506 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1507 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1508 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1510 TextAbstraction::BitmapFont bitmapFont;
1511 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1513 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1514 fontClient.GetFontId( bitmapFont );
1516 TextLabel label = TextLabel::New();
1518 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1519 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1521 // 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.
1522 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1524 application.GetScene().Add( label );
1526 application.SendNotification();
1527 application.Render();
1529 // The text has been rendered if the height of the text-label is the height of the line.
1530 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1535 int ConvertPointToPixel( float point )
1537 unsigned int horizontalDpi = 0u;
1538 unsigned int verticalDpi = 0u;
1539 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1540 fontClient.GetDpi( horizontalDpi, verticalDpi );
1542 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1545 int UtcDaliToolkitTextlabelTextFit(void)
1547 ToolkitTestApplication application;
1548 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1549 TextLabel label = TextLabel::New();
1550 Vector2 size( 460.0f, 100.0f );
1551 label.SetProperty( Actor::Property::SIZE, size );
1552 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1555 Property::Map textFitMapSet;
1556 textFitMapSet["enable"] = true;
1557 textFitMapSet["minSize"] = 10.f;
1558 textFitMapSet["maxSize"] = 100.f;
1559 textFitMapSet["stepSize"] = -1.f;
1560 textFitMapSet["fontSizeType"] = "pointSize";
1562 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1563 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1565 application.GetScene().Add( label );
1567 application.SendNotification();
1568 application.Render();
1570 const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1571 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1574 textFitMapSet.Clear();
1575 textFitMapSet["enable"] = true;
1576 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1577 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1578 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1579 textFitMapSet["fontSizeType"] = "pixelSize";
1581 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1583 application.SendNotification();
1584 application.Render();
1586 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1591 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1593 ToolkitTestApplication application;
1594 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1596 DevelText::BitmapFontDescription fontDescription;
1597 fontDescription.name = "Digits";
1598 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1600 TextAbstraction::BitmapFont bitmapFont;
1601 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1603 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1604 fontClient.GetFontId( bitmapFont );
1606 TextLabel label = TextLabel::New();
1607 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1608 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1609 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1610 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1611 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1613 Property::Map underlineMapSet;
1614 underlineMapSet.Clear();
1615 underlineMapSet.Insert( "enable", true );
1616 underlineMapSet.Insert( "color", Color::RED );
1617 underlineMapSet.Insert( "height", 1 );
1618 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1619 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1621 application.GetScene().Add( label );
1623 application.SendNotification();
1624 application.Render();
1626 const int maxTextureSize = Dali::GetMaxTextureSize();
1627 // Whether the rendered text is greater than maxTextureSize
1628 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1630 // Check if the number of renderers is greater than 1.
1631 DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1636 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1638 ToolkitTestApplication application;
1639 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1641 Vector2 size( 300.0f, 100.0f );
1643 Dali::Toolkit::DevelText::RendererParameters textParameters;
1644 textParameters.text = "This is a sample text to get the last index.";
1645 textParameters.layout = "multiLine";
1646 textParameters.fontSize = 20.f;
1647 textParameters.textWidth = 300u;
1648 textParameters.textHeight = 100u;
1649 textParameters.ellipsisEnabled = true;
1650 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1652 DALI_TEST_CHECK( !indexArray.Empty() );
1653 DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );