2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali-toolkit/devel-api/text/bitmap-font.h>
32 using namespace Toolkit;
34 void dali_textlabel_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_textlabel_cleanup(void)
41 test_return_value = TET_PASS;
47 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
48 const char* const PROPERTY_NAME_TEXT = "text";
49 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
50 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
51 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
52 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
53 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
54 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
55 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
56 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
62 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
63 const char* const PROPERTY_NAME_UNDERLINE = "underline";
64 const char* const PROPERTY_NAME_SHADOW = "shadow";
65 const char* const PROPERTY_NAME_EMBOSS = "emboss";
66 const char* const PROPERTY_NAME_OUTLINE = "outline";
67 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
69 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
70 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
71 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
73 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
74 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
76 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
78 const Property::Map::SizeType size = mapGet.Count();
80 if( size == mapSet.Count() )
82 for( unsigned int index = 0u; index < size; ++index )
84 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
86 // Find the keys of the 'get' map
87 Property::Index indexKey = valueGet.first.indexKey;
88 std::string stringKey = valueGet.first.stringKey;
90 if( !indexConversionTable.empty() )
92 if( stringKey.empty() )
94 stringKey = indexConversionTable[ indexKey ];
97 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
99 Property::Index index = 0u;
100 for( auto key : indexConversionTable )
102 if( key == stringKey )
112 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
114 if( nullptr != valueSet )
116 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
118 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
121 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
123 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
126 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
128 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
131 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
133 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
136 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
138 Vector2 vector2Get = valueGet.second.Get<Vector2>();
139 Vector2 vector2Set = valueSet->Get<Vector2>();
140 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
143 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
145 Vector4 vector4Get = valueGet.second.Get<Vector4>();
146 Vector4 vector4Set = valueSet->Get<Vector4>();
147 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 );
153 if ( valueGet.first.type == Property::Key::INDEX )
155 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
159 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
171 int UtcDaliToolkitTextLabelConstructorP(void)
173 ToolkitTestApplication application;
174 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
176 DALI_TEST_CHECK( !textLabel );
180 int UtcDaliToolkitTextLabelNewP(void)
182 ToolkitTestApplication application;
183 tet_infoline(" UtcDaliToolkitTextLabelNewP");
184 TextLabel textLabel = TextLabel::New( "Test Text" );
185 DALI_TEST_CHECK( textLabel );
189 int UtcDaliToolkitTextLabelDownCastP(void)
191 ToolkitTestApplication application;
192 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
193 TextLabel textLabel1 = TextLabel::New();
194 BaseHandle object( textLabel1 );
196 TextLabel textLabel2 = TextLabel::DownCast( object );
197 DALI_TEST_CHECK( textLabel2 );
199 TextLabel textLabel3 = DownCast< TextLabel >( object );
200 DALI_TEST_CHECK( textLabel3 );
204 int UtcDaliToolkitTextLabelDownCastN(void)
206 ToolkitTestApplication application;
207 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
208 BaseHandle uninitializedObject;
209 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
210 DALI_TEST_CHECK( !textLabel1 );
212 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
213 DALI_TEST_CHECK( !textLabel2 );
217 int UtcDaliToolkitTextLabelCopyConstructorP(void)
219 ToolkitTestApplication application;
220 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
221 TextLabel textLabel = TextLabel::New();
222 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
224 TextLabel copy( textLabel );
225 DALI_TEST_CHECK( copy );
226 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
230 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
232 ToolkitTestApplication application;
233 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
234 TextLabel textLabel = TextLabel::New();
235 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
237 TextLabel copy = textLabel;
238 DALI_TEST_CHECK( copy );
239 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
243 // Positive test case for a method
244 int UtcDaliToolkitTextLabelGetPropertyP(void)
246 ToolkitTestApplication application;
247 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
248 TextLabel label = TextLabel::New("Test Text");
249 DALI_TEST_CHECK( label );
251 // Check Property Indices are correct
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
274 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
279 int UtcDaliToolkitTextLabelSetPropertyP(void)
281 ToolkitTestApplication application;
282 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
283 TextLabel label = TextLabel::New();
284 DALI_TEST_CHECK( label );
286 Stage::GetCurrent().Add( label );
288 // Note - we can't check the defaults since the stylesheets are platform-specific
289 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
290 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
292 // Check that text can be correctly reset
293 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
294 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
296 // Check font properties.
297 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
298 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
300 Property::Map fontStyleMapSet;
301 Property::Map fontStyleMapGet;
303 fontStyleMapSet.Insert( "weight", "bold" );
304 fontStyleMapSet.Insert( "width", "condensed" );
305 fontStyleMapSet.Insert( "slant", "italic" );
306 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
308 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
309 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
310 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
312 // Check the old font style format.
313 fontStyleMapSet.Clear();
314 fontStyleMapSet.Insert( "weight", "thin" );
315 fontStyleMapSet.Insert( "width", "expanded" );
316 fontStyleMapSet.Insert( "slant", "oblique" );
317 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
319 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
320 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
321 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
323 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
324 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
327 fontStyleMapSet.Clear();
328 fontStyleMapSet.Insert( "weight", "normal" );
329 fontStyleMapSet.Insert( "slant", "oblique" );
331 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
332 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
333 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
334 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
336 fontStyleMapSet.Clear();
337 fontStyleMapSet.Insert( "slant", "roman" );
339 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
340 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
341 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
343 // Replace 'roman' for 'normal'.
344 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
345 if( NULL != slantValue )
347 if( "normal" == slantValue->Get<std::string>() )
349 fontStyleMapGet["slant"] = "roman";
352 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
354 fontStyleMapSet.Clear();
356 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
357 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
358 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
359 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
362 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
363 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
365 // Check that the Alignment properties can be correctly set
366 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
367 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
368 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
369 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
371 // Check that text color can be properly set
372 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
373 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
375 Property::Map underlineMapSet;
376 Property::Map underlineMapGet;
378 underlineMapSet.Insert( "enable", false );
379 underlineMapSet.Insert( "color", Color::BLUE );
380 underlineMapSet.Insert( "height", 0 );
382 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
383 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
384 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
386 TextLabel label2 = TextLabel::New( "New text" );
387 DALI_TEST_CHECK( label2 );
388 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
390 // Check the enable markup property.
391 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
392 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
393 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
395 // Check the text property when markup is enabled
396 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
397 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
399 // Check for incomplete marks.
400 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
401 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
404 application.SendNotification();
405 application.Render();
409 tet_result(TET_FAIL);
412 // Check autoscroll properties
413 const int SCROLL_SPEED = 80;
414 const int SCROLL_LOOPS = 4;
415 const float SCROLL_GAP = 50.0f;
416 const float SCROLL_LOOP_DELAY = 0.3f;
417 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
418 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
420 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
421 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
422 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
423 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
424 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
425 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
426 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
427 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
428 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
429 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
430 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
431 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
433 //Check autoscroll stop type property
434 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
435 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
437 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
438 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
440 // test natural size with multi-line and line spacing
442 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
443 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
444 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
445 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
446 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
448 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
449 // The height of the text when multi-line is enabled will be larger
450 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
451 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
453 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
454 // Everything else will remain the same
455 int lineSpacing = 20;
456 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
457 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
458 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
459 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
462 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
464 TextLabel label3 = TextLabel::New("Some text here end there end here");
465 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
466 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
467 Vector3 textNaturalSize = label3.GetNaturalSize();
468 int lineSpacing = 20;
469 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
470 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
471 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
472 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
474 // Check the line spacing property
475 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
476 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
477 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
479 // Check the underline property
480 underlineMapSet.Clear();
481 underlineMapSet.Insert( "enable", true );
482 underlineMapSet.Insert( "color", Color::RED );
483 underlineMapSet.Insert( "height", 1 );
485 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
487 application.SendNotification();
488 application.Render();
490 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
491 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
492 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
494 underlineMapSet.Clear();
495 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
496 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
497 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
499 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
501 application.SendNotification();
502 application.Render();
504 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
505 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
506 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
507 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
509 underlineMapSet.Clear();
511 Property::Map underlineDisabledMapGet;
512 underlineDisabledMapGet.Insert( "enable", false );
513 underlineDisabledMapGet.Insert( "color", Color::GREEN );
514 underlineDisabledMapGet.Insert( "height", 2 );
516 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
518 application.SendNotification();
519 application.Render();
521 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
522 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
523 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
525 // Check the shadow property
527 Property::Map shadowMapSet;
528 Property::Map shadowMapGet;
530 shadowMapSet.Insert( "color", Color::GREEN );
531 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
532 shadowMapSet.Insert( "blurRadius", 5.0f );
534 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
536 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
537 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
538 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
540 shadowMapSet.Clear();
542 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
543 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
544 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
546 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
548 // Replace the offset (string) by a vector2
549 shadowMapSet.Clear();
550 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
551 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
552 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
554 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
555 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
556 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
557 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
559 shadowMapSet.Clear();
560 Property::Map shadowDisabledMapGet;
561 shadowDisabledMapGet.Insert( "color", Color::BLUE );
562 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
563 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
565 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
567 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
568 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
569 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
571 // Check the emboss property
572 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
573 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
575 // Check the outline property
577 // Test string type first
578 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
579 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
580 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
582 // Then test the property map type
583 Property::Map outlineMapSet;
584 Property::Map outlineMapGet;
586 outlineMapSet["color"] = Color::RED;
587 outlineMapSet["width"] = 2.0f;
588 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
590 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
591 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
594 outlineMapSet.Clear();
595 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
596 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
597 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
599 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
600 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
601 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
602 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
604 // Check the background property
605 Property::Map backgroundMapSet;
606 Property::Map backgroundMapGet;
608 backgroundMapSet["enable"] = true;
609 backgroundMapSet["color"] = Color::RED;
610 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
612 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
613 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
616 backgroundMapSet.Clear();
617 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
618 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
619 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
621 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
622 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
623 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
624 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
626 // Check the pixel size of font
627 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
628 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630 // Check the ellipsis property
631 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
632 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
633 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
635 // Check the layout direction property
636 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
637 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
639 application.SendNotification();
640 application.Render();
645 int UtcDaliToolkitTextlabelAtlasRenderP(void)
647 ToolkitTestApplication application;
648 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
649 TextLabel label = TextLabel::New("Test Text");
650 DALI_TEST_CHECK( label );
652 // Avoid a crash when core load gl resources.
653 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
655 Stage::GetCurrent().Add( label );
657 // Turn on all the effects
658 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
659 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
661 Property::Map underlineMap;
662 underlineMap.Insert( "enable", true );
663 underlineMap.Insert( "color", Color::RED );
664 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
666 Property::Map shadowMap;
667 shadowMap.Insert( "color", Color::BLUE );
668 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
669 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
673 // Render some text with the shared atlas backend
674 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
675 application.SendNotification();
676 application.Render();
680 tet_result(TET_FAIL);
685 // Render some text with the shared atlas backend
686 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
687 application.SendNotification();
688 application.Render();
692 tet_result(TET_FAIL);
697 int UtcDaliToolkitTextLabelLanguagesP(void)
699 ToolkitTestApplication application;
700 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
701 TextLabel label = TextLabel::New();
702 DALI_TEST_CHECK( label );
704 Stage::GetCurrent().Add( label );
706 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
707 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
708 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
709 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
710 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
711 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
713 label.SetProperty( TextLabel::Property::TEXT, scripts );
714 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
716 application.SendNotification();
717 application.Render();
722 int UtcDaliToolkitTextLabelEmojisP(void)
724 ToolkitTestApplication application;
725 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
726 TextLabel label = TextLabel::New();
727 DALI_TEST_CHECK( label );
729 Stage::GetCurrent().Add( label );
731 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
733 char* pathNamePtr = get_current_dir_name();
734 const std::string pathName( pathNamePtr );
737 TextAbstraction::FontDescription fontDescription;
738 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
739 fontDescription.family = "BreezeColorEmoji";
740 fontDescription.width = TextAbstraction::FontWidth::NONE;
741 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
742 fontDescription.slant = TextAbstraction::FontSlant::NONE;
744 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
746 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>";
747 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
748 label.SetProperty( TextLabel::Property::TEXT, emojis );
750 Property::Map shadowMap;
751 shadowMap.Insert( "color", "green" );
752 shadowMap.Insert( "offset", "2 2" );
753 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
755 application.SendNotification();
756 application.Render();
761 int UtcDaliToolkitTextlabelScrollingP(void)
763 ToolkitTestApplication application;
764 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
765 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
766 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
768 DALI_TEST_CHECK( labelImmediate );
769 DALI_TEST_CHECK( labelFinished );
770 // Avoid a crash when core load gl resources.
771 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
772 Stage::GetCurrent().Add( labelImmediate );
773 // Turn on all the effects
774 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
775 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
776 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
777 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
778 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
780 Stage::GetCurrent().Add( labelFinished );
781 // Turn on all the effects
782 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
783 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
784 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
785 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
786 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
792 // Render some text with the shared atlas backend
793 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
794 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
796 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
797 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
799 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
800 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801 application.SendNotification();
802 application.Render();
804 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
806 application.SendNotification();
807 application.Render();
812 tet_result(TET_FAIL);
818 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
820 ToolkitTestApplication application;
821 TextLabel labelShort = TextLabel::New("Some text to scroll");
822 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!");
824 DALI_TEST_CHECK( labelShort );
825 DALI_TEST_CHECK( labelLong );
826 // Avoid a crash when core load gl resources.
827 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
828 Stage::GetCurrent().Add( labelShort );
829 // Turn on all the effects
830 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
831 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
832 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
833 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
834 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
835 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
837 Stage::GetCurrent().Add( labelLong );
838 // Turn on all the effects
839 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
840 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
841 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
842 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
843 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
844 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
848 // Render some text with the shared atlas backend
849 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
850 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
851 application.SendNotification();
852 application.Render();
854 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
855 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
856 application.SendNotification();
857 application.Render();
862 tet_result(TET_FAIL);
868 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
870 ToolkitTestApplication application;
871 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
872 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
874 DALI_TEST_CHECK( labelShort );
875 DALI_TEST_CHECK( labelLong );
876 // Avoid a crash when core load gl resources.
877 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
878 Stage::GetCurrent().Add( labelShort );
879 // Turn on all the effects
880 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
881 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
882 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
883 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
884 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
885 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
887 Stage::GetCurrent().Add( labelLong );
888 // Turn on all the effects
889 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
890 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
891 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
892 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
893 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
894 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
898 // Render some text with the shared atlas backend
899 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
900 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
901 application.SendNotification();
902 application.Render();
904 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
905 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
906 application.SendNotification();
907 application.Render();
912 tet_result(TET_FAIL);
918 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
920 ToolkitTestApplication application;
921 TextLabel labelShort = TextLabel::New("Some text to scroll");
922 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!");
924 DALI_TEST_CHECK( labelShort );
925 DALI_TEST_CHECK( labelLong );
926 // Avoid a crash when core load gl resources.
927 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
928 Stage::GetCurrent().Add( labelShort );
929 // Turn on all the effects
930 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
931 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
932 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
933 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
934 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
935 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
937 Stage::GetCurrent().Add( labelLong );
938 // Turn on all the effects
939 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
940 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
941 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
942 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
943 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
944 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
948 // Render some text with the shared atlas backend
949 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
950 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
951 application.SendNotification();
952 application.Render();
954 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
955 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
956 application.SendNotification();
957 application.Render();
962 tet_result(TET_FAIL);
968 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
970 ToolkitTestApplication application;
971 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
972 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
974 DALI_TEST_CHECK( labelShort );
975 DALI_TEST_CHECK( labelLong );
976 // Avoid a crash when core load gl resources.
977 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
978 Stage::GetCurrent().Add( labelShort );
979 // Turn on all the effects
980 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
981 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
982 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
983 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
984 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
985 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
987 Stage::GetCurrent().Add( labelLong );
988 // Turn on all the effects
989 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
990 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
991 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
992 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
993 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
994 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
998 // Render some text with the shared atlas backend
999 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1000 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1001 application.SendNotification();
1002 application.Render();
1004 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1005 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1006 application.SendNotification();
1007 application.Render();
1012 tet_result(TET_FAIL);
1018 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1022 TextLabel label = TextLabel::New("Some text to scroll");
1023 DALI_TEST_CHECK( label );
1024 // Avoid a crash when core load gl resources.
1025 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1026 Stage::GetCurrent().Add( label );
1027 label.SetSize( 360.0f, 20.f );
1028 // Turn on all the effects
1029 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1030 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1031 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1032 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1035 application.SendNotification();
1036 application.Render();
1038 unsigned int actorCount1 = label.GetChildCount();
1039 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1043 // Render some text with the shared atlas backend
1044 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1045 application.SendNotification();
1046 application.Render(2000);
1048 unsigned int actorCount1 = label.GetChildCount();
1049 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1051 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1054 application.SendNotification();
1055 application.Render();
1057 unsigned int actorCount2 = label.GetChildCount();
1058 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1060 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1065 tet_result(TET_FAIL);
1071 int UtcDaliToolkitTextlabelScrollingN(void)
1073 ToolkitTestApplication application;
1074 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1076 TextLabel label = TextLabel::New("Some text to scroll");
1077 DALI_TEST_CHECK( label );
1079 Stage::GetCurrent().Add( label );
1081 // Avoid a crash when core load gl resources.
1082 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1084 // The text scrolling works only on single line text.
1085 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1087 // Turn on all the effects.
1088 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1089 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1090 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1092 // Enable the auto scrolling effect.
1093 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1095 // The auto scrolling shouldn't be enabled.
1096 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1097 DALI_TEST_CHECK( !enabled );
1102 int UtcDaliToolkitTextlabelEllipsis(void)
1104 ToolkitTestApplication application;
1105 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1107 TextLabel label = TextLabel::New("Hello world");
1108 DALI_TEST_CHECK( label );
1110 // Avoid a crash when core load gl resources.
1111 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1113 Stage::GetCurrent().Add( label );
1115 // Turn on all the effects
1116 label.SetAnchorPoint( AnchorPoint::CENTER );
1117 label.SetParentOrigin( ParentOrigin::CENTER );
1118 label.SetSize( 360.0f, 10.f );
1123 application.SendNotification();
1124 application.Render();
1128 tet_result(TET_FAIL);
1131 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1132 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1133 label.SetSize( 400.0f, 10.f );
1138 application.SendNotification();
1139 application.Render();
1143 tet_result(TET_FAIL);
1147 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1148 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1149 label.SetSize( 400.0f, 10.f );
1154 application.SendNotification();
1155 application.Render();
1159 tet_result(TET_FAIL);
1165 int UtcDaliToolkitTextlabelTextWrapMode(void)
1167 ToolkitTestApplication application;
1168 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1172 TextLabel label = TextLabel::New();
1173 label.SetSize( 300.0f, 300.f );
1174 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1175 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1179 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1180 Stage::GetCurrent().Add( label );
1182 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1183 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1185 application.SendNotification();
1186 application.Render();
1188 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1189 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1191 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1192 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1194 application.SendNotification();
1195 application.Render();
1197 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1198 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1200 application.SendNotification();
1201 application.Render();
1203 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1204 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1206 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1207 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1209 application.SendNotification();
1210 application.Render();
1212 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1213 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1215 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1216 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1217 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1222 int UtcDaliToolkitTextLabelColorComponents(void)
1224 ToolkitTestApplication application;
1226 TextLabel label = TextLabel::New();
1227 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1228 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1229 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1230 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1231 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1233 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1234 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1235 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1237 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1239 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1240 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1242 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1243 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1245 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1246 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1247 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1248 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1250 // Test a transparent text - Rendering should be skipped.
1251 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1252 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1254 Stage::GetCurrent().Add( label );
1256 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1257 drawTrace.Enable( true );
1259 application.SendNotification();
1260 application.Render();
1262 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1264 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1268 application.SendNotification();
1269 application.Render();
1271 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1273 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1277 application.SendNotification();
1278 application.Render();
1280 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1285 int UtcDaliToolkitTextlabelTextStyle01(void)
1287 ToolkitTestApplication application;
1288 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1290 TextLabel label = TextLabel::New();
1291 label.SetSize( 300.0f, 300.f );
1292 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1293 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1294 Stage::GetCurrent().Add( label );
1296 Property::Map outlineMapSet;
1297 Property::Map outlineMapGet;
1299 outlineMapSet["color"] = Color::BLUE;
1300 outlineMapSet["width"] = 2.0f;
1301 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1303 application.SendNotification();
1304 application.Render();
1306 Property::Map shadowMapSet;
1307 shadowMapSet.Insert( "color", "green" );
1308 shadowMapSet.Insert( "offset", "2 2" );
1309 shadowMapSet.Insert( "blurRadius", "3" );
1310 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1312 outlineMapSet["color"] = Color::RED;
1313 outlineMapSet["width"] = 0.0f;
1314 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1316 application.SendNotification();
1317 application.Render();
1319 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1321 Property::Value* colorValue = outlineMapGet.Find("color");
1323 bool colorMatched( false );
1327 Property::Type valueType = colorValue->GetType();
1329 if ( Property::STRING == valueType )
1331 std::string stringValue;
1332 colorValue->Get( stringValue );
1333 if ( stringValue == "red" )
1335 colorMatched = true;
1338 else if ( Property::VECTOR4 == valueType )
1340 Vector4 colorVector4;
1341 colorValue->Get( colorVector4 );
1342 if ( colorVector4 == Color::RED )
1344 colorMatched = true;
1349 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1354 int UtcDaliToolkitTextlabelMultiline(void)
1356 ToolkitTestApplication application;
1357 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1359 TextLabel label = TextLabel::New();
1360 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1361 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1362 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1363 Stage::GetCurrent().Add( label );
1365 application.SendNotification();
1366 application.Render();
1368 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1369 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1371 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1373 application.SendNotification();
1374 application.Render();
1376 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1377 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1383 int UtcDaliToolkitTextlabelTextDirection(void)
1385 ToolkitTestApplication application;
1386 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1388 TextLabel label = TextLabel::New();
1389 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1391 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1392 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1393 Stage::GetCurrent().Add( label );
1396 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1399 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1400 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1402 // Test RTL text starting with weak character
1403 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1404 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1406 // Test RTL text string with emoji and weak character
1407 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1408 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1413 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1415 ToolkitTestApplication application;
1416 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1418 TextLabel label = TextLabel::New();
1420 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1421 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1422 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1423 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1424 Stage::GetCurrent().Add( label );
1425 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1427 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1428 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1430 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1431 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1436 int UtcDaliToolkitTextLabelBitmapFont(void)
1438 ToolkitTestApplication application;
1439 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1441 DevelText::BitmapFontDescription fontDescription;
1442 fontDescription.name = "Digits";
1443 fontDescription.underlinePosition = 0.f;
1444 fontDescription.underlineThickness = 0.f;
1446 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1447 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1448 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1449 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1450 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1451 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1452 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1453 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1454 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1455 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1456 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1458 TextAbstraction::BitmapFont bitmapFont;
1459 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1461 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1462 fontClient.GetFontId( bitmapFont );
1464 TextLabel label = TextLabel::New();
1466 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1467 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1469 // 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.
1470 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1472 Stage::GetCurrent().Add( label );
1474 application.SendNotification();
1475 application.Render();
1477 // The text has been rendered if the height of the text-label is the height of the line.
1478 DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1483 int ConvertPointToPixel( float point )
1485 unsigned int horizontalDpi = 0u;
1486 unsigned int verticalDpi = 0u;
1487 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1488 fontClient.GetDpi( horizontalDpi, verticalDpi );
1490 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1493 int UtcDaliToolkitTextlabelTextFit(void)
1495 ToolkitTestApplication application;
1496 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1497 TextLabel label = TextLabel::New();
1498 Vector2 size( 460.0f, 100.0f );
1499 label.SetSize( size );
1500 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1503 Property::Map textFitMapSet;
1504 textFitMapSet["enable"] = true;
1505 textFitMapSet["minSize"] = 10.f;
1506 textFitMapSet["maxSize"] = 100.f;
1507 textFitMapSet["stepSize"] = -1.f;
1508 textFitMapSet["fontSizeType"] = "pointSize";
1510 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1511 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1513 Stage::GetCurrent().Add( label );
1515 application.SendNotification();
1516 application.Render();
1518 const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
1519 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1522 textFitMapSet.Clear();
1523 textFitMapSet["enable"] = true;
1524 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1525 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1526 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1527 textFitMapSet["fontSizeType"] = "pixelSize";
1529 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1531 application.SendNotification();
1532 application.Render();
1534 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );