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 // Check for incomplete marks.
399 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
400 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
403 application.SendNotification();
404 application.Render();
408 tet_result(TET_FAIL);
411 // Check autoscroll properties
412 const int SCROLL_SPEED = 80;
413 const int SCROLL_LOOPS = 4;
414 const float SCROLL_GAP = 50.0f;
415 const float SCROLL_LOOP_DELAY = 0.3f;
416 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
417 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
419 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
420 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
421 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
422 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
423 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
424 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
425 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
426 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
427 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
428 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
429 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
430 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
432 //Check autoscroll stop type property
433 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
434 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
436 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
437 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
439 // test natural size with multi-line and line spacing
441 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
442 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
443 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
444 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
445 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
447 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
448 // The height of the text when multi-line is enabled will be larger
449 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
450 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
452 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
453 // Everything else will remain the same
454 int lineSpacing = 20;
455 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
456 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
457 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
458 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
461 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
463 TextLabel label3 = TextLabel::New("Some text here end there end here");
464 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
465 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
466 Vector3 textNaturalSize = label3.GetNaturalSize();
467 int lineSpacing = 20;
468 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
469 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
470 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
471 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
473 // Check the line spacing property
474 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
475 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
476 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
478 // Check the underline property
479 underlineMapSet.Clear();
480 underlineMapSet.Insert( "enable", true );
481 underlineMapSet.Insert( "color", Color::RED );
482 underlineMapSet.Insert( "height", 1 );
484 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
486 application.SendNotification();
487 application.Render();
489 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
490 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
491 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
493 underlineMapSet.Clear();
494 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
495 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
496 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
498 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
500 application.SendNotification();
501 application.Render();
503 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
504 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
505 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
506 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
508 underlineMapSet.Clear();
510 Property::Map underlineDisabledMapGet;
511 underlineDisabledMapGet.Insert( "enable", false );
512 underlineDisabledMapGet.Insert( "color", Color::GREEN );
513 underlineDisabledMapGet.Insert( "height", 2 );
515 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
517 application.SendNotification();
518 application.Render();
520 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
521 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
522 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
524 // Check the shadow property
526 Property::Map shadowMapSet;
527 Property::Map shadowMapGet;
529 shadowMapSet.Insert( "color", Color::GREEN );
530 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
531 shadowMapSet.Insert( "blurRadius", 5.0f );
533 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
535 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
536 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
537 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
539 shadowMapSet.Clear();
541 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
542 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
543 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
545 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
547 // Replace the offset (string) by a vector2
548 shadowMapSet.Clear();
549 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
550 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
551 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
553 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
554 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
555 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
556 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
558 shadowMapSet.Clear();
559 Property::Map shadowDisabledMapGet;
560 shadowDisabledMapGet.Insert( "color", Color::BLUE );
561 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
562 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
564 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
566 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
567 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
568 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
570 // Check the emboss property
571 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
572 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
574 // Check the outline property
576 // Test string type first
577 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
578 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
579 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
581 // Then test the property map type
582 Property::Map outlineMapSet;
583 Property::Map outlineMapGet;
585 outlineMapSet["color"] = Color::RED;
586 outlineMapSet["width"] = 2.0f;
587 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
589 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
590 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
591 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
593 outlineMapSet.Clear();
594 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
595 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
596 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
598 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
599 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
600 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
601 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
603 // Check the background property
604 Property::Map backgroundMapSet;
605 Property::Map backgroundMapGet;
607 backgroundMapSet["enable"] = true;
608 backgroundMapSet["color"] = Color::RED;
609 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
611 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
612 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
613 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
615 backgroundMapSet.Clear();
616 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
617 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
618 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
620 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
621 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
622 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
623 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
625 // Check the pixel size of font
626 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
627 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
629 // Check the ellipsis property
630 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
631 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
632 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
634 // Check the layout direction property
635 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
636 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
638 application.SendNotification();
639 application.Render();
644 int UtcDaliToolkitTextlabelAtlasRenderP(void)
646 ToolkitTestApplication application;
647 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
648 TextLabel label = TextLabel::New("Test Text");
649 DALI_TEST_CHECK( label );
651 // Avoid a crash when core load gl resources.
652 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
654 Stage::GetCurrent().Add( label );
656 // Turn on all the effects
657 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
658 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
660 Property::Map underlineMap;
661 underlineMap.Insert( "enable", true );
662 underlineMap.Insert( "color", Color::RED );
663 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
665 Property::Map shadowMap;
666 shadowMap.Insert( "color", Color::BLUE );
667 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
668 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
672 // Render some text with the shared atlas backend
673 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
674 application.SendNotification();
675 application.Render();
679 tet_result(TET_FAIL);
684 // Render some text with the shared atlas backend
685 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
686 application.SendNotification();
687 application.Render();
691 tet_result(TET_FAIL);
696 int UtcDaliToolkitTextLabelLanguagesP(void)
698 ToolkitTestApplication application;
699 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
700 TextLabel label = TextLabel::New();
701 DALI_TEST_CHECK( label );
703 Stage::GetCurrent().Add( label );
705 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
706 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
707 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
708 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
709 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
710 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
712 label.SetProperty( TextLabel::Property::TEXT, scripts );
713 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
715 application.SendNotification();
716 application.Render();
721 int UtcDaliToolkitTextLabelEmojisP(void)
723 ToolkitTestApplication application;
724 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
725 TextLabel label = TextLabel::New();
726 DALI_TEST_CHECK( label );
728 Stage::GetCurrent().Add( label );
730 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
732 char* pathNamePtr = get_current_dir_name();
733 const std::string pathName( pathNamePtr );
736 TextAbstraction::FontDescription fontDescription;
737 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
738 fontDescription.family = "BreezeColorEmoji";
739 fontDescription.width = TextAbstraction::FontWidth::NONE;
740 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
741 fontDescription.slant = TextAbstraction::FontSlant::NONE;
743 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
745 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>";
746 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
747 label.SetProperty( TextLabel::Property::TEXT, emojis );
749 Property::Map shadowMap;
750 shadowMap.Insert( "color", "green" );
751 shadowMap.Insert( "offset", "2 2" );
752 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
754 application.SendNotification();
755 application.Render();
760 int UtcDaliToolkitTextlabelScrollingP(void)
762 ToolkitTestApplication application;
763 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
764 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
765 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
767 DALI_TEST_CHECK( labelImmediate );
768 DALI_TEST_CHECK( labelFinished );
769 // Avoid a crash when core load gl resources.
770 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
771 Stage::GetCurrent().Add( labelImmediate );
772 // Turn on all the effects
773 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
774 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
775 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
776 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
777 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
779 Stage::GetCurrent().Add( labelFinished );
780 // Turn on all the effects
781 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
782 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
783 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
784 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
785 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
791 // Render some text with the shared atlas backend
792 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
793 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
795 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
796 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
798 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
799 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
800 application.SendNotification();
801 application.Render();
803 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
804 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805 application.SendNotification();
806 application.Render();
811 tet_result(TET_FAIL);
817 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
819 ToolkitTestApplication application;
820 TextLabel labelShort = TextLabel::New("Some text to scroll");
821 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!");
823 DALI_TEST_CHECK( labelShort );
824 DALI_TEST_CHECK( labelLong );
825 // Avoid a crash when core load gl resources.
826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
827 Stage::GetCurrent().Add( labelShort );
828 // Turn on all the effects
829 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
830 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
831 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
832 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
833 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
834 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
836 Stage::GetCurrent().Add( labelLong );
837 // Turn on all the effects
838 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
839 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
840 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
841 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
842 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
843 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
847 // Render some text with the shared atlas backend
848 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
849 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
850 application.SendNotification();
851 application.Render();
853 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
854 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
855 application.SendNotification();
856 application.Render();
861 tet_result(TET_FAIL);
867 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
869 ToolkitTestApplication application;
870 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
871 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
873 DALI_TEST_CHECK( labelShort );
874 DALI_TEST_CHECK( labelLong );
875 // Avoid a crash when core load gl resources.
876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
877 Stage::GetCurrent().Add( labelShort );
878 // Turn on all the effects
879 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
880 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
881 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
882 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
883 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
884 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
886 Stage::GetCurrent().Add( labelLong );
887 // Turn on all the effects
888 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
889 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
890 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
891 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
892 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
893 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
897 // Render some text with the shared atlas backend
898 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
899 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
900 application.SendNotification();
901 application.Render();
903 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
904 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
905 application.SendNotification();
906 application.Render();
911 tet_result(TET_FAIL);
917 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
919 ToolkitTestApplication application;
920 TextLabel labelShort = TextLabel::New("Some text to scroll");
921 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!");
923 DALI_TEST_CHECK( labelShort );
924 DALI_TEST_CHECK( labelLong );
925 // Avoid a crash when core load gl resources.
926 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
927 Stage::GetCurrent().Add( labelShort );
928 // Turn on all the effects
929 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
930 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
931 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
932 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
933 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
934 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
936 Stage::GetCurrent().Add( labelLong );
937 // Turn on all the effects
938 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
939 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
940 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
941 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
942 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
943 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
947 // Render some text with the shared atlas backend
948 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
949 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
950 application.SendNotification();
951 application.Render();
953 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
954 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
955 application.SendNotification();
956 application.Render();
961 tet_result(TET_FAIL);
967 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
969 ToolkitTestApplication application;
970 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
971 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
973 DALI_TEST_CHECK( labelShort );
974 DALI_TEST_CHECK( labelLong );
975 // Avoid a crash when core load gl resources.
976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
977 Stage::GetCurrent().Add( labelShort );
978 // Turn on all the effects
979 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
980 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
981 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
982 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
983 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
984 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
986 Stage::GetCurrent().Add( labelLong );
987 // Turn on all the effects
988 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
989 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
990 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
991 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
992 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
993 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
997 // Render some text with the shared atlas backend
998 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
999 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1000 application.SendNotification();
1001 application.Render();
1003 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1004 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1005 application.SendNotification();
1006 application.Render();
1011 tet_result(TET_FAIL);
1017 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1019 ToolkitTestApplication application;
1020 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1021 TextLabel label = TextLabel::New("Some text to scroll");
1022 DALI_TEST_CHECK( label );
1023 // Avoid a crash when core load gl resources.
1024 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1025 Stage::GetCurrent().Add( label );
1026 label.SetSize( 360.0f, 20.f );
1027 // Turn on all the effects
1028 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1029 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1030 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1031 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1034 application.SendNotification();
1035 application.Render();
1037 unsigned int actorCount1 = label.GetChildCount();
1038 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1042 // Render some text with the shared atlas backend
1043 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1044 application.SendNotification();
1045 application.Render(2000);
1047 unsigned int actorCount1 = label.GetChildCount();
1048 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1050 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1053 application.SendNotification();
1054 application.Render();
1056 unsigned int actorCount2 = label.GetChildCount();
1057 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1059 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1064 tet_result(TET_FAIL);
1070 int UtcDaliToolkitTextlabelScrollingN(void)
1072 ToolkitTestApplication application;
1073 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1075 TextLabel label = TextLabel::New("Some text to scroll");
1076 DALI_TEST_CHECK( label );
1078 Stage::GetCurrent().Add( label );
1080 // Avoid a crash when core load gl resources.
1081 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1083 // The text scrolling works only on single line text.
1084 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1086 // Turn on all the effects.
1087 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1088 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1089 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1091 // Enable the auto scrolling effect.
1092 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1094 // The auto scrolling shouldn't be enabled.
1095 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1096 DALI_TEST_CHECK( !enabled );
1101 int UtcDaliToolkitTextlabelEllipsis(void)
1103 ToolkitTestApplication application;
1104 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1106 TextLabel label = TextLabel::New("Hello world");
1107 DALI_TEST_CHECK( label );
1109 // Avoid a crash when core load gl resources.
1110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1112 Stage::GetCurrent().Add( label );
1114 // Turn on all the effects
1115 label.SetAnchorPoint( AnchorPoint::CENTER );
1116 label.SetParentOrigin( ParentOrigin::CENTER );
1117 label.SetSize( 360.0f, 10.f );
1122 application.SendNotification();
1123 application.Render();
1127 tet_result(TET_FAIL);
1130 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1131 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1132 label.SetSize( 400.0f, 10.f );
1137 application.SendNotification();
1138 application.Render();
1142 tet_result(TET_FAIL);
1146 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1147 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1148 label.SetSize( 400.0f, 10.f );
1153 application.SendNotification();
1154 application.Render();
1158 tet_result(TET_FAIL);
1164 int UtcDaliToolkitTextlabelTextWrapMode(void)
1166 ToolkitTestApplication application;
1167 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1171 TextLabel label = TextLabel::New();
1172 label.SetSize( 300.0f, 300.f );
1173 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1174 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1178 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1179 Stage::GetCurrent().Add( label );
1181 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1182 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1184 application.SendNotification();
1185 application.Render();
1187 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1188 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1190 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1191 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1193 application.SendNotification();
1194 application.Render();
1196 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1197 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1199 application.SendNotification();
1200 application.Render();
1202 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1203 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1205 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1206 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1208 application.SendNotification();
1209 application.Render();
1211 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1212 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1214 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1215 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1216 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1221 int UtcDaliToolkitTextLabelColorComponents(void)
1223 ToolkitTestApplication application;
1225 TextLabel label = TextLabel::New();
1226 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1227 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1228 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1229 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1230 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1232 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1233 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1234 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1235 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1238 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1239 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1242 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1244 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1245 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1246 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1247 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1249 // Test a transparent text - Rendering should be skipped.
1250 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1251 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1253 Stage::GetCurrent().Add( label );
1255 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1256 drawTrace.Enable( true );
1258 application.SendNotification();
1259 application.Render();
1261 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1263 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1267 application.SendNotification();
1268 application.Render();
1270 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1272 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1276 application.SendNotification();
1277 application.Render();
1279 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1284 int UtcDaliToolkitTextlabelTextStyle01(void)
1286 ToolkitTestApplication application;
1287 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1289 TextLabel label = TextLabel::New();
1290 label.SetSize( 300.0f, 300.f );
1291 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1292 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1293 Stage::GetCurrent().Add( label );
1295 Property::Map outlineMapSet;
1296 Property::Map outlineMapGet;
1298 outlineMapSet["color"] = Color::BLUE;
1299 outlineMapSet["width"] = 2.0f;
1300 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1302 application.SendNotification();
1303 application.Render();
1305 Property::Map shadowMapSet;
1306 shadowMapSet.Insert( "color", "green" );
1307 shadowMapSet.Insert( "offset", "2 2" );
1308 shadowMapSet.Insert( "blurRadius", "3" );
1309 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1311 outlineMapSet["color"] = Color::RED;
1312 outlineMapSet["width"] = 0.0f;
1313 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1315 application.SendNotification();
1316 application.Render();
1318 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1320 Property::Value* colorValue = outlineMapGet.Find("color");
1322 bool colorMatched( false );
1326 Property::Type valueType = colorValue->GetType();
1328 if ( Property::STRING == valueType )
1330 std::string stringValue;
1331 colorValue->Get( stringValue );
1332 if ( stringValue == "red" )
1334 colorMatched = true;
1337 else if ( Property::VECTOR4 == valueType )
1339 Vector4 colorVector4;
1340 colorValue->Get( colorVector4 );
1341 if ( colorVector4 == Color::RED )
1343 colorMatched = true;
1348 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1353 int UtcDaliToolkitTextlabelMultiline(void)
1355 ToolkitTestApplication application;
1356 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1358 TextLabel label = TextLabel::New();
1359 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1360 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1361 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1362 Stage::GetCurrent().Add( label );
1364 application.SendNotification();
1365 application.Render();
1367 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1368 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1370 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1372 application.SendNotification();
1373 application.Render();
1375 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1376 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1382 int UtcDaliToolkitTextlabelTextDirection(void)
1384 ToolkitTestApplication application;
1385 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1387 TextLabel label = TextLabel::New();
1388 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1390 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1391 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1392 Stage::GetCurrent().Add( label );
1395 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1398 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1399 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1401 // Test RTL text starting with weak character
1402 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1403 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1405 // Test RTL text string with emoji and weak character
1406 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1407 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1412 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1414 ToolkitTestApplication application;
1415 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1417 TextLabel label = TextLabel::New();
1419 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1420 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1421 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1422 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1423 Stage::GetCurrent().Add( label );
1424 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1426 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1427 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1429 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1430 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1435 int UtcDaliToolkitTextLabelBitmapFont(void)
1437 ToolkitTestApplication application;
1438 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1440 DevelText::BitmapFontDescription fontDescription;
1441 fontDescription.name = "Digits";
1442 fontDescription.underlinePosition = 0.f;
1443 fontDescription.underlineThickness = 0.f;
1445 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1446 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1447 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1448 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1449 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1450 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1451 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1452 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1453 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1454 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1455 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1457 TextAbstraction::BitmapFont bitmapFont;
1458 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1460 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1461 fontClient.GetFontId( bitmapFont );
1463 TextLabel label = TextLabel::New();
1465 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1466 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1468 // 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.
1469 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1471 Stage::GetCurrent().Add( label );
1473 application.SendNotification();
1474 application.Render();
1476 // The text has been rendered if the height of the text-label is the height of the line.
1477 DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1482 int ConvertPointToPixel( float point )
1484 unsigned int horizontalDpi = 0u;
1485 unsigned int verticalDpi = 0u;
1486 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1487 fontClient.GetDpi( horizontalDpi, verticalDpi );
1489 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1492 int UtcDaliToolkitTextlabelTextFit(void)
1494 ToolkitTestApplication application;
1495 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1496 TextLabel label = TextLabel::New();
1497 Vector2 size( 460.0f, 100.0f );
1498 label.SetSize( size );
1499 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1502 Property::Map textFitMapSet;
1503 textFitMapSet["enable"] = true;
1504 textFitMapSet["minSize"] = 10.f;
1505 textFitMapSet["maxSize"] = 100.f;
1506 textFitMapSet["stepSize"] = -1.f;
1507 textFitMapSet["fontSizeType"] = "pointSize";
1509 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1510 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1512 Stage::GetCurrent().Add( label );
1514 application.SendNotification();
1515 application.Render();
1517 const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
1518 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1521 textFitMapSet.Clear();
1522 textFitMapSet["enable"] = true;
1523 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1524 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1525 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1526 textFitMapSet["fontSizeType"] = "pixelSize";
1528 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1530 application.SendNotification();
1531 application.Render();
1533 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );