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-toolkit/devel-api/text/bitmap-font.h>
31 using namespace Toolkit;
33 void dali_textlabel_startup(void)
35 test_return_value = TET_UNDEF;
38 void dali_textlabel_cleanup(void)
40 test_return_value = TET_PASS;
46 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
47 const char* const PROPERTY_NAME_TEXT = "text";
48 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
49 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
50 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
51 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
52 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
53 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
54 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
55 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
61 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
62 const char* const PROPERTY_NAME_UNDERLINE = "underline";
63 const char* const PROPERTY_NAME_SHADOW = "shadow";
64 const char* const PROPERTY_NAME_EMBOSS = "emboss";
65 const char* const PROPERTY_NAME_OUTLINE = "outline";
66 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
68 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
69 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
70 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
72 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
73 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
75 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
77 const Property::Map::SizeType size = mapGet.Count();
79 if( size == mapSet.Count() )
81 for( unsigned int index = 0u; index < size; ++index )
83 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
85 // Find the keys of the 'get' map
86 Property::Index indexKey = valueGet.first.indexKey;
87 std::string stringKey = valueGet.first.stringKey;
89 if( !indexConversionTable.empty() )
91 if( stringKey.empty() )
93 stringKey = indexConversionTable[ indexKey ];
96 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
98 Property::Index index = 0u;
99 for( auto key : indexConversionTable )
101 if( key == stringKey )
111 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
113 if( nullptr != valueSet )
115 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
117 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
120 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
122 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
125 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
127 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
130 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
132 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
135 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
137 Vector2 vector2Get = valueGet.second.Get<Vector2>();
138 Vector2 vector2Set = valueSet->Get<Vector2>();
139 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
142 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
144 Vector4 vector4Get = valueGet.second.Get<Vector4>();
145 Vector4 vector4Set = valueSet->Get<Vector4>();
146 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 );
152 if ( valueGet.first.type == Property::Key::INDEX )
154 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
158 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
170 int UtcDaliToolkitTextLabelConstructorP(void)
172 ToolkitTestApplication application;
173 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
175 DALI_TEST_CHECK( !textLabel );
179 int UtcDaliToolkitTextLabelNewP(void)
181 ToolkitTestApplication application;
182 tet_infoline(" UtcDaliToolkitTextLabelNewP");
183 TextLabel textLabel = TextLabel::New( "Test Text" );
184 DALI_TEST_CHECK( textLabel );
188 int UtcDaliToolkitTextLabelDownCastP(void)
190 ToolkitTestApplication application;
191 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
192 TextLabel textLabel1 = TextLabel::New();
193 BaseHandle object( textLabel1 );
195 TextLabel textLabel2 = TextLabel::DownCast( object );
196 DALI_TEST_CHECK( textLabel2 );
198 TextLabel textLabel3 = DownCast< TextLabel >( object );
199 DALI_TEST_CHECK( textLabel3 );
203 int UtcDaliToolkitTextLabelDownCastN(void)
205 ToolkitTestApplication application;
206 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
207 BaseHandle uninitializedObject;
208 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
209 DALI_TEST_CHECK( !textLabel1 );
211 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
212 DALI_TEST_CHECK( !textLabel2 );
216 int UtcDaliToolkitTextLabelCopyConstructorP(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
220 TextLabel textLabel = TextLabel::New();
221 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
223 TextLabel copy( textLabel );
224 DALI_TEST_CHECK( copy );
225 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
229 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
231 ToolkitTestApplication application;
232 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
233 TextLabel textLabel = TextLabel::New();
234 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
236 TextLabel copy = textLabel;
237 DALI_TEST_CHECK( copy );
238 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
242 // Positive test case for a method
243 int UtcDaliToolkitTextLabelGetPropertyP(void)
245 ToolkitTestApplication application;
246 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
247 TextLabel label = TextLabel::New("Test Text");
248 DALI_TEST_CHECK( label );
250 // Check Property Indices are correct
251 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
278 int UtcDaliToolkitTextLabelSetPropertyP(void)
280 ToolkitTestApplication application;
281 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
282 TextLabel label = TextLabel::New();
283 DALI_TEST_CHECK( label );
285 Stage::GetCurrent().Add( label );
287 // Note - we can't check the defaults since the stylesheets are platform-specific
288 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
289 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
291 // Check that text can be correctly reset
292 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
293 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
295 // Check font properties.
296 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
297 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
299 Property::Map fontStyleMapSet;
300 Property::Map fontStyleMapGet;
302 fontStyleMapSet.Insert( "weight", "bold" );
303 fontStyleMapSet.Insert( "width", "condensed" );
304 fontStyleMapSet.Insert( "slant", "italic" );
305 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
307 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
308 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
309 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
311 // Check the old font style format.
312 fontStyleMapSet.Clear();
313 fontStyleMapSet.Insert( "weight", "thin" );
314 fontStyleMapSet.Insert( "width", "expanded" );
315 fontStyleMapSet.Insert( "slant", "oblique" );
316 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
318 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
319 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
320 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
322 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
323 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
326 fontStyleMapSet.Clear();
327 fontStyleMapSet.Insert( "weight", "normal" );
328 fontStyleMapSet.Insert( "slant", "oblique" );
330 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
331 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
332 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
333 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
335 fontStyleMapSet.Clear();
336 fontStyleMapSet.Insert( "slant", "roman" );
338 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
339 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
340 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
342 // Replace 'roman' for 'normal'.
343 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
344 if( NULL != slantValue )
346 if( "normal" == slantValue->Get<std::string>() )
348 fontStyleMapGet["slant"] = "roman";
351 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
353 fontStyleMapSet.Clear();
355 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
356 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
357 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
358 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
361 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
362 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
364 // Check that the Alignment properties can be correctly set
365 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
366 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
367 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
368 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
370 // Check that text color can be properly set
371 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
372 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
374 Property::Map underlineMapSet;
375 Property::Map underlineMapGet;
377 underlineMapSet.Insert( "enable", false );
378 underlineMapSet.Insert( "color", Color::BLUE );
379 underlineMapSet.Insert( "height", 0 );
381 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
382 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
383 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
385 TextLabel label2 = TextLabel::New( "New text" );
386 DALI_TEST_CHECK( label2 );
387 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
389 // Check the enable markup property.
390 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
391 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
392 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
394 // Check the text property when markup is enabled
395 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
396 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
398 application.SendNotification();
399 application.Render();
401 // Check autoscroll properties
402 const int SCROLL_SPEED = 80;
403 const int SCROLL_LOOPS = 4;
404 const float SCROLL_GAP = 50.0f;
405 const float SCROLL_LOOP_DELAY = 0.3f;
406 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
407 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
409 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
410 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
411 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
412 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
413 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
414 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
415 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
416 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
417 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
418 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
419 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
420 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
422 //Check autoscroll stop type property
423 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
424 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
426 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
427 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
429 // test natural size with multi-line and line spacing
431 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
432 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
433 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
434 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
435 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
437 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
438 // The height of the text when multi-line is enabled will be larger
439 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
440 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
442 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
443 // Everything else will remain the same
444 int lineSpacing = 20;
445 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
446 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
447 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
448 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
451 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
453 TextLabel label3 = TextLabel::New("Some text here end there end here");
454 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
455 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
456 Vector3 textNaturalSize = label3.GetNaturalSize();
457 int lineSpacing = 20;
458 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
459 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
460 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
461 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
463 // Check the line spacing property
464 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
465 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
466 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
468 // Check the underline property
469 underlineMapSet.Clear();
470 underlineMapSet.Insert( "enable", true );
471 underlineMapSet.Insert( "color", Color::RED );
472 underlineMapSet.Insert( "height", 1 );
474 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
476 application.SendNotification();
477 application.Render();
479 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
480 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
481 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
483 underlineMapSet.Clear();
484 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
485 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
486 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
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 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
496 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
498 underlineMapSet.Clear();
500 Property::Map underlineDisabledMapGet;
501 underlineDisabledMapGet.Insert( "enable", false );
502 underlineDisabledMapGet.Insert( "color", Color::GREEN );
503 underlineDisabledMapGet.Insert( "height", 2 );
505 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
507 application.SendNotification();
508 application.Render();
510 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
511 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
512 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
514 // Check the shadow property
516 Property::Map shadowMapSet;
517 Property::Map shadowMapGet;
519 shadowMapSet.Insert( "color", Color::GREEN );
520 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
521 shadowMapSet.Insert( "blurRadius", 5.0f );
523 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
525 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
526 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
527 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
529 shadowMapSet.Clear();
531 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
532 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
533 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
535 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
537 // Replace the offset (string) by a vector2
538 shadowMapSet.Clear();
539 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
540 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
541 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
543 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
544 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
545 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
546 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
548 shadowMapSet.Clear();
549 Property::Map shadowDisabledMapGet;
550 shadowDisabledMapGet.Insert( "color", Color::BLUE );
551 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
552 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
554 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
556 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
557 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
558 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
560 // Check the emboss property
561 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
562 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
564 // Check the outline property
566 // Test string type first
567 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
568 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
569 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
571 // Then test the property map type
572 Property::Map outlineMapSet;
573 Property::Map outlineMapGet;
575 outlineMapSet["color"] = Color::RED;
576 outlineMapSet["width"] = 2.0f;
577 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
579 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
580 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
581 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
583 outlineMapSet.Clear();
584 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
585 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
586 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
588 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
589 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
590 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
591 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
593 // Check the background property
594 Property::Map backgroundMapSet;
595 Property::Map backgroundMapGet;
597 backgroundMapSet["enable"] = true;
598 backgroundMapSet["color"] = Color::RED;
599 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
601 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
602 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
603 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
605 backgroundMapSet.Clear();
606 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
607 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
608 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
610 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
611 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
612 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
613 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
615 // Check the pixel size of font
616 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
617 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 // Check the ellipsis property
620 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
621 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
622 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
624 // Check the layout direction property
625 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
626 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
628 application.SendNotification();
629 application.Render();
634 int UtcDaliToolkitTextlabelAtlasRenderP(void)
636 ToolkitTestApplication application;
637 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
638 TextLabel label = TextLabel::New("Test Text");
639 DALI_TEST_CHECK( label );
641 // Avoid a crash when core load gl resources.
642 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
644 Stage::GetCurrent().Add( label );
646 // Turn on all the effects
647 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
648 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
650 Property::Map underlineMap;
651 underlineMap.Insert( "enable", true );
652 underlineMap.Insert( "color", Color::RED );
653 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
655 Property::Map shadowMap;
656 shadowMap.Insert( "color", Color::BLUE );
657 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
658 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
662 // Render some text with the shared atlas backend
663 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
664 application.SendNotification();
665 application.Render();
669 tet_result(TET_FAIL);
674 // Render some text with the shared atlas backend
675 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
676 application.SendNotification();
677 application.Render();
681 tet_result(TET_FAIL);
686 int UtcDaliToolkitTextLabelLanguagesP(void)
688 ToolkitTestApplication application;
689 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
690 TextLabel label = TextLabel::New();
691 DALI_TEST_CHECK( label );
693 Stage::GetCurrent().Add( label );
695 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
696 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
697 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
698 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
699 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
700 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
702 label.SetProperty( TextLabel::Property::TEXT, scripts );
703 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
705 application.SendNotification();
706 application.Render();
711 int UtcDaliToolkitTextLabelEmojisP(void)
713 ToolkitTestApplication application;
714 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
715 TextLabel label = TextLabel::New();
716 DALI_TEST_CHECK( label );
718 Stage::GetCurrent().Add( label );
720 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
722 char* pathNamePtr = get_current_dir_name();
723 const std::string pathName( pathNamePtr );
726 TextAbstraction::FontDescription fontDescription;
727 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
728 fontDescription.family = "BreezeColorEmoji";
729 fontDescription.width = TextAbstraction::FontWidth::NONE;
730 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
731 fontDescription.slant = TextAbstraction::FontSlant::NONE;
733 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
735 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>";
736 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
737 label.SetProperty( TextLabel::Property::TEXT, emojis );
739 Property::Map shadowMap;
740 shadowMap.Insert( "color", "green" );
741 shadowMap.Insert( "offset", "2 2" );
742 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
744 application.SendNotification();
745 application.Render();
750 int UtcDaliToolkitTextlabelScrollingP(void)
752 ToolkitTestApplication application;
753 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
754 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
755 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
757 DALI_TEST_CHECK( labelImmediate );
758 DALI_TEST_CHECK( labelFinished );
759 // Avoid a crash when core load gl resources.
760 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
761 Stage::GetCurrent().Add( labelImmediate );
762 // Turn on all the effects
763 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
764 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
765 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
766 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
767 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
769 Stage::GetCurrent().Add( labelFinished );
770 // Turn on all the effects
771 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
772 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
773 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
774 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
775 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
781 // Render some text with the shared atlas backend
782 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
783 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
785 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
786 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
788 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
789 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
790 application.SendNotification();
791 application.Render();
793 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
794 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
795 application.SendNotification();
796 application.Render();
801 tet_result(TET_FAIL);
807 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
809 ToolkitTestApplication application;
810 TextLabel labelShort = TextLabel::New("Some text to scroll");
811 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!");
813 DALI_TEST_CHECK( labelShort );
814 DALI_TEST_CHECK( labelLong );
815 // Avoid a crash when core load gl resources.
816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
817 Stage::GetCurrent().Add( labelShort );
818 // Turn on all the effects
819 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
820 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
821 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
822 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
823 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
824 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
826 Stage::GetCurrent().Add( labelLong );
827 // Turn on all the effects
828 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
829 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
830 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
831 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
832 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
833 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
837 // Render some text with the shared atlas backend
838 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
839 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
840 application.SendNotification();
841 application.Render();
843 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
844 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
845 application.SendNotification();
846 application.Render();
851 tet_result(TET_FAIL);
857 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
859 ToolkitTestApplication application;
860 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
861 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
863 DALI_TEST_CHECK( labelShort );
864 DALI_TEST_CHECK( labelLong );
865 // Avoid a crash when core load gl resources.
866 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
867 Stage::GetCurrent().Add( labelShort );
868 // Turn on all the effects
869 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
870 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
871 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
872 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
873 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
874 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
876 Stage::GetCurrent().Add( labelLong );
877 // Turn on all the effects
878 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
879 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
880 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
881 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
882 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
883 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
887 // Render some text with the shared atlas backend
888 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
889 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
890 application.SendNotification();
891 application.Render();
893 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
894 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
895 application.SendNotification();
896 application.Render();
901 tet_result(TET_FAIL);
907 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
909 ToolkitTestApplication application;
910 TextLabel labelShort = TextLabel::New("Some text to scroll");
911 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!");
913 DALI_TEST_CHECK( labelShort );
914 DALI_TEST_CHECK( labelLong );
915 // Avoid a crash when core load gl resources.
916 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
917 Stage::GetCurrent().Add( labelShort );
918 // Turn on all the effects
919 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
920 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
921 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
922 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
923 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
924 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
926 Stage::GetCurrent().Add( labelLong );
927 // Turn on all the effects
928 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
929 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
930 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
931 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
932 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
933 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
937 // Render some text with the shared atlas backend
938 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
939 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
940 application.SendNotification();
941 application.Render();
943 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
944 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
945 application.SendNotification();
946 application.Render();
951 tet_result(TET_FAIL);
957 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
959 ToolkitTestApplication application;
960 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
961 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
963 DALI_TEST_CHECK( labelShort );
964 DALI_TEST_CHECK( labelLong );
965 // Avoid a crash when core load gl resources.
966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
967 Stage::GetCurrent().Add( labelShort );
968 // Turn on all the effects
969 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
970 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
971 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
972 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
973 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
974 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
976 Stage::GetCurrent().Add( labelLong );
977 // Turn on all the effects
978 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
979 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
980 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
981 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
982 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
983 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
987 // Render some text with the shared atlas backend
988 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
989 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
990 application.SendNotification();
991 application.Render();
993 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
994 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
995 application.SendNotification();
996 application.Render();
1001 tet_result(TET_FAIL);
1007 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1009 ToolkitTestApplication application;
1010 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1011 TextLabel label = TextLabel::New("Some text to scroll");
1012 DALI_TEST_CHECK( label );
1013 // Avoid a crash when core load gl resources.
1014 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1015 Stage::GetCurrent().Add( label );
1016 label.SetSize( 360.0f, 20.f );
1017 // Turn on all the effects
1018 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1019 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1020 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1021 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1024 application.SendNotification();
1025 application.Render();
1027 unsigned int actorCount1 = label.GetChildCount();
1028 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1032 // Render some text with the shared atlas backend
1033 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1034 application.SendNotification();
1035 application.Render(2000);
1037 unsigned int actorCount1 = label.GetChildCount();
1038 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1040 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1043 application.SendNotification();
1044 application.Render();
1046 unsigned int actorCount2 = label.GetChildCount();
1047 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1049 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1054 tet_result(TET_FAIL);
1060 int UtcDaliToolkitTextlabelScrollingN(void)
1062 ToolkitTestApplication application;
1063 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1065 TextLabel label = TextLabel::New("Some text to scroll");
1066 DALI_TEST_CHECK( label );
1068 Stage::GetCurrent().Add( label );
1070 // Avoid a crash when core load gl resources.
1071 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1073 // The text scrolling works only on single line text.
1074 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1076 // Turn on all the effects.
1077 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1078 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1079 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1081 // Enable the auto scrolling effect.
1082 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1084 // The auto scrolling shouldn't be enabled.
1085 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1086 DALI_TEST_CHECK( !enabled );
1091 int UtcDaliToolkitTextlabelEllipsis(void)
1093 ToolkitTestApplication application;
1094 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1096 TextLabel label = TextLabel::New("Hello world");
1097 DALI_TEST_CHECK( label );
1099 // Avoid a crash when core load gl resources.
1100 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1102 Stage::GetCurrent().Add( label );
1104 // Turn on all the effects
1105 label.SetAnchorPoint( AnchorPoint::CENTER );
1106 label.SetParentOrigin( ParentOrigin::CENTER );
1107 label.SetSize( 360.0f, 10.f );
1112 application.SendNotification();
1113 application.Render();
1117 tet_result(TET_FAIL);
1120 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1121 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1122 label.SetSize( 400.0f, 10.f );
1127 application.SendNotification();
1128 application.Render();
1132 tet_result(TET_FAIL);
1136 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1137 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1138 label.SetSize( 400.0f, 10.f );
1143 application.SendNotification();
1144 application.Render();
1148 tet_result(TET_FAIL);
1154 int UtcDaliToolkitTextlabelTextWrapMode(void)
1156 ToolkitTestApplication application;
1157 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1161 TextLabel label = TextLabel::New();
1162 label.SetSize( 300.0f, 300.f );
1163 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1164 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1168 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1169 Stage::GetCurrent().Add( label );
1171 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1172 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1174 application.SendNotification();
1175 application.Render();
1177 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1178 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1180 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1181 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1183 application.SendNotification();
1184 application.Render();
1186 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1187 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1189 application.SendNotification();
1190 application.Render();
1192 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1193 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1195 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1196 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1198 application.SendNotification();
1199 application.Render();
1201 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1202 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1204 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1205 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1206 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1211 int UtcDaliToolkitTextLabelColorComponents(void)
1213 ToolkitTestApplication application;
1215 TextLabel label = TextLabel::New();
1216 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1217 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1218 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1219 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1220 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1222 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1223 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1224 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1225 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1226 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1228 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1229 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1230 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1231 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1232 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1234 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1235 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1237 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1239 // Test a transparent text - Rendering should be skipped.
1240 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1241 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1243 Stage::GetCurrent().Add( label );
1245 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1246 drawTrace.Enable( true );
1248 application.SendNotification();
1249 application.Render();
1251 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1253 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1257 application.SendNotification();
1258 application.Render();
1260 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1262 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1266 application.SendNotification();
1267 application.Render();
1269 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1274 int UtcDaliToolkitTextlabelTextStyle01(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1279 TextLabel label = TextLabel::New();
1280 label.SetSize( 300.0f, 300.f );
1281 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1282 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1283 Stage::GetCurrent().Add( label );
1285 Property::Map outlineMapSet;
1286 Property::Map outlineMapGet;
1288 outlineMapSet["color"] = Color::BLUE;
1289 outlineMapSet["width"] = 2.0f;
1290 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1292 application.SendNotification();
1293 application.Render();
1295 Property::Map shadowMapSet;
1296 shadowMapSet.Insert( "color", "green" );
1297 shadowMapSet.Insert( "offset", "2 2" );
1298 shadowMapSet.Insert( "blurRadius", "3" );
1299 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1301 outlineMapSet["color"] = Color::RED;
1302 outlineMapSet["width"] = 0.0f;
1303 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1305 application.SendNotification();
1306 application.Render();
1308 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1310 Property::Value* colorValue = outlineMapGet.Find("color");
1312 bool colorMatched( false );
1316 Property::Type valueType = colorValue->GetType();
1318 if ( Property::STRING == valueType )
1320 std::string stringValue;
1321 colorValue->Get( stringValue );
1322 if ( stringValue == "red" )
1324 colorMatched = true;
1327 else if ( Property::VECTOR4 == valueType )
1329 Vector4 colorVector4;
1330 colorValue->Get( colorVector4 );
1331 if ( colorVector4 == Color::RED )
1333 colorMatched = true;
1338 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1343 int UtcDaliToolkitTextlabelMultiline(void)
1345 ToolkitTestApplication application;
1346 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1348 TextLabel label = TextLabel::New();
1349 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1350 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1351 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1352 Stage::GetCurrent().Add( label );
1354 application.SendNotification();
1355 application.Render();
1357 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1358 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1360 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1362 application.SendNotification();
1363 application.Render();
1365 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1366 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1372 int UtcDaliToolkitTextlabelTextDirection(void)
1374 ToolkitTestApplication application;
1375 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1377 TextLabel label = TextLabel::New();
1378 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1380 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1381 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1382 Stage::GetCurrent().Add( label );
1385 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1388 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1389 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1391 // Test RTL text starting with weak character
1392 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1393 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1395 // Test RTL text string with emoji and weak character
1396 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1397 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1402 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1404 ToolkitTestApplication application;
1405 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1407 TextLabel label = TextLabel::New();
1409 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1410 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1411 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1412 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1413 Stage::GetCurrent().Add( label );
1414 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1416 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1417 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1419 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1420 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1425 int UtcDaliToolkitTextLabelBitmapFont(void)
1427 ToolkitTestApplication application;
1428 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1430 DevelText::BitmapFontDescription fontDescription;
1431 fontDescription.name = "Digits";
1432 fontDescription.underlinePosition = 0.f;
1433 fontDescription.underlineThickness = 0.f;
1435 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1436 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1437 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1438 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1439 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1440 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1441 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1442 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1443 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1444 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1445 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1447 TextAbstraction::BitmapFont bitmapFont;
1448 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1450 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1451 fontClient.GetFontId( bitmapFont );
1453 TextLabel label = TextLabel::New();
1455 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1456 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1458 // 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.
1459 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1461 Stage::GetCurrent().Add( label );
1463 application.SendNotification();
1464 application.Render();
1466 // The text has been rendered if the height of the text-label is the height of the line.
1467 DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );