2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
34 using namespace Toolkit;
36 void dali_textlabel_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_textlabel_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
57 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
58 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
64 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
65 const char* const PROPERTY_NAME_UNDERLINE = "underline";
66 const char* const PROPERTY_NAME_SHADOW = "shadow";
67 const char* const PROPERTY_NAME_EMBOSS = "emboss";
68 const char* const PROPERTY_NAME_OUTLINE = "outline";
69 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
71 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
72 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
73 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
75 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
76 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
78 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
80 const Property::Map::SizeType size = mapGet.Count();
82 if( size == mapSet.Count() )
84 for( unsigned int index = 0u; index < size; ++index )
86 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
88 // Find the keys of the 'get' map
89 Property::Index indexKey = valueGet.first.indexKey;
90 std::string stringKey = valueGet.first.stringKey;
92 if( !indexConversionTable.empty() )
94 if( stringKey.empty() )
96 stringKey = indexConversionTable[ indexKey ];
99 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
101 Property::Index index = 0u;
102 for( auto key : indexConversionTable )
104 if( key == stringKey )
114 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
116 if( nullptr != valueSet )
118 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
120 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
123 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
125 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
128 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
130 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
133 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
135 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
138 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
140 Vector2 vector2Get = valueGet.second.Get<Vector2>();
141 Vector2 vector2Set = valueSet->Get<Vector2>();
142 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
145 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
147 Vector4 vector4Get = valueGet.second.Get<Vector4>();
148 Vector4 vector4Set = valueSet->Get<Vector4>();
149 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 );
155 if ( valueGet.first.type == Property::Key::INDEX )
157 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
161 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
173 int UtcDaliToolkitTextLabelConstructorP(void)
175 ToolkitTestApplication application;
176 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
178 DALI_TEST_CHECK( !textLabel );
182 int UtcDaliToolkitTextLabelNewP(void)
184 ToolkitTestApplication application;
185 tet_infoline(" UtcDaliToolkitTextLabelNewP");
186 TextLabel textLabel = TextLabel::New( "Test Text" );
187 DALI_TEST_CHECK( textLabel );
191 int UtcDaliToolkitTextLabelDownCastP(void)
193 ToolkitTestApplication application;
194 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
195 TextLabel textLabel1 = TextLabel::New();
196 BaseHandle object( textLabel1 );
198 TextLabel textLabel2 = TextLabel::DownCast( object );
199 DALI_TEST_CHECK( textLabel2 );
201 TextLabel textLabel3 = DownCast< TextLabel >( object );
202 DALI_TEST_CHECK( textLabel3 );
206 int UtcDaliToolkitTextLabelDownCastN(void)
208 ToolkitTestApplication application;
209 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
210 BaseHandle uninitializedObject;
211 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
212 DALI_TEST_CHECK( !textLabel1 );
214 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
215 DALI_TEST_CHECK( !textLabel2 );
219 int UtcDaliToolkitTextLabelCopyConstructorP(void)
221 ToolkitTestApplication application;
222 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
223 TextLabel textLabel = TextLabel::New();
224 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
226 TextLabel copy( textLabel );
227 DALI_TEST_CHECK( copy );
228 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
232 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
234 ToolkitTestApplication application;
235 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
236 TextLabel textLabel = TextLabel::New();
237 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
239 TextLabel copy = textLabel;
240 DALI_TEST_CHECK( copy );
241 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
245 // Positive test case for a method
246 int UtcDaliToolkitTextLabelGetPropertyP(void)
248 ToolkitTestApplication application;
249 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
250 TextLabel label = TextLabel::New("Test Text");
251 DALI_TEST_CHECK( label );
253 // Check Property Indices are correct
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
274 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
275 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
276 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
281 int UtcDaliToolkitTextLabelSetPropertyP(void)
283 ToolkitTestApplication application;
284 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
285 TextLabel label = TextLabel::New();
286 DALI_TEST_CHECK( label );
288 Stage::GetCurrent().Add( label );
290 // Note - we can't check the defaults since the stylesheets are platform-specific
291 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
292 DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
294 // Check that text can be correctly reset
295 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
296 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
298 // Check font properties.
299 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
300 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
302 Property::Map fontStyleMapSet;
303 Property::Map fontStyleMapGet;
305 fontStyleMapSet.Insert( "weight", "bold" );
306 fontStyleMapSet.Insert( "width", "condensed" );
307 fontStyleMapSet.Insert( "slant", "italic" );
308 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
310 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
311 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
312 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
314 // Check the old font style format.
315 fontStyleMapSet.Clear();
316 fontStyleMapSet.Insert( "weight", "thin" );
317 fontStyleMapSet.Insert( "width", "expanded" );
318 fontStyleMapSet.Insert( "slant", "oblique" );
319 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
321 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
322 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
323 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
325 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
326 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
329 fontStyleMapSet.Clear();
330 fontStyleMapSet.Insert( "weight", "normal" );
331 fontStyleMapSet.Insert( "slant", "oblique" );
333 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
334 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
335 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
336 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
338 fontStyleMapSet.Clear();
339 fontStyleMapSet.Insert( "slant", "roman" );
341 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
342 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
343 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
345 // Replace 'roman' for 'normal'.
346 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
347 if( NULL != slantValue )
349 if( "normal" == slantValue->Get<std::string>() )
351 fontStyleMapGet["slant"] = "roman";
354 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
356 fontStyleMapSet.Clear();
358 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
359 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
360 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
361 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
364 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
365 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
367 // Check that the Alignment properties can be correctly set
368 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
369 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
370 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
371 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
373 // Check that text color can be properly set
374 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
375 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
377 Property::Map underlineMapSet;
378 Property::Map underlineMapGet;
380 underlineMapSet.Insert( "enable", false );
381 underlineMapSet.Insert( "color", Color::BLUE );
382 underlineMapSet.Insert( "height", 0 );
384 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
385 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
386 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
388 TextLabel label2 = TextLabel::New( "New text" );
389 DALI_TEST_CHECK( label2 );
390 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
392 // Check the enable markup property.
393 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
394 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
395 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
397 // Check the text property when markup is enabled
398 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
399 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
401 // Check for incomplete marks.
402 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
403 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
406 application.SendNotification();
407 application.Render();
411 tet_result(TET_FAIL);
414 // Check autoscroll properties
415 const int SCROLL_SPEED = 80;
416 const int SCROLL_LOOPS = 4;
417 const float SCROLL_GAP = 50.0f;
418 const float SCROLL_LOOP_DELAY = 0.3f;
419 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
420 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
422 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
423 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
424 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
425 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
426 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
427 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
428 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
429 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
430 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
431 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
432 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
433 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
435 //Check autoscroll stop type property
436 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
437 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
439 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
440 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
442 // test natural size with multi-line and line spacing
444 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
445 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
446 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
447 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
448 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
450 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
451 // The height of the text when multi-line is enabled will be larger
452 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
453 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
455 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
456 // Everything else will remain the same
457 int lineSpacing = 20;
458 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
459 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
460 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
461 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
464 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
466 TextLabel label3 = TextLabel::New("Some text here end there end here");
467 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
468 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
469 Vector3 textNaturalSize = label3.GetNaturalSize();
470 int lineSpacing = 20;
471 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
472 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
473 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
474 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
476 // Check the line spacing property
477 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
478 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
479 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
481 // Check the underline property
482 underlineMapSet.Clear();
483 underlineMapSet.Insert( "enable", true );
484 underlineMapSet.Insert( "color", Color::RED );
485 underlineMapSet.Insert( "height", 1 );
487 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
489 application.SendNotification();
490 application.Render();
492 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
493 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
494 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
496 underlineMapSet.Clear();
497 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
498 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
499 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
501 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
503 application.SendNotification();
504 application.Render();
506 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
507 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
508 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
509 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
511 underlineMapSet.Clear();
513 Property::Map underlineDisabledMapGet;
514 underlineDisabledMapGet.Insert( "enable", false );
515 underlineDisabledMapGet.Insert( "color", Color::GREEN );
516 underlineDisabledMapGet.Insert( "height", 2 );
518 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
520 application.SendNotification();
521 application.Render();
523 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
524 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
525 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
527 // Check the shadow property
529 Property::Map shadowMapSet;
530 Property::Map shadowMapGet;
532 shadowMapSet.Insert( "color", Color::GREEN );
533 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
534 shadowMapSet.Insert( "blurRadius", 5.0f );
536 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
538 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
539 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
540 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
542 shadowMapSet.Clear();
544 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
545 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
546 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
548 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
550 // Replace the offset (string) by a vector2
551 shadowMapSet.Clear();
552 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
553 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
554 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
556 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
557 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
558 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
559 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
561 shadowMapSet.Clear();
562 Property::Map shadowDisabledMapGet;
563 shadowDisabledMapGet.Insert( "color", Color::BLUE );
564 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
565 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
567 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
569 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
570 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
571 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
573 // Check the emboss property
574 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
575 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
577 // Check the outline property
579 // Test string type first
580 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
581 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
582 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
584 // Then test the property map type
585 Property::Map outlineMapSet;
586 Property::Map outlineMapGet;
588 outlineMapSet["color"] = Color::RED;
589 outlineMapSet["width"] = 2.0f;
590 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
592 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
593 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
594 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
596 outlineMapSet.Clear();
597 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
598 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
599 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
601 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
602 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
603 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
604 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
606 // Check the background property
607 Property::Map backgroundMapSet;
608 Property::Map backgroundMapGet;
610 backgroundMapSet["enable"] = true;
611 backgroundMapSet["color"] = Color::RED;
612 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
614 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
615 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
618 backgroundMapSet.Clear();
619 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
620 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
621 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
623 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
624 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
625 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
626 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
628 // Check the pixel size of font
629 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
630 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
632 // Check the ellipsis property
633 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
634 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
635 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
637 // Check the layout direction property
638 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
639 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
641 // Check the line size property
642 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
643 label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
644 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
646 application.SendNotification();
647 application.Render();
652 int UtcDaliToolkitTextlabelAtlasRenderP(void)
654 ToolkitTestApplication application;
655 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
656 TextLabel label = TextLabel::New("Test Text");
657 DALI_TEST_CHECK( label );
659 // Avoid a crash when core load gl resources.
660 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
662 Stage::GetCurrent().Add( label );
664 // Turn on all the effects
665 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
666 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
668 Property::Map underlineMap;
669 underlineMap.Insert( "enable", true );
670 underlineMap.Insert( "color", Color::RED );
671 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
673 Property::Map shadowMap;
674 shadowMap.Insert( "color", Color::BLUE );
675 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
676 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
680 // Render some text with the shared atlas backend
681 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
682 application.SendNotification();
683 application.Render();
687 tet_result(TET_FAIL);
692 // Render some text with the shared atlas backend
693 label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
694 application.SendNotification();
695 application.Render();
699 tet_result(TET_FAIL);
704 int UtcDaliToolkitTextLabelLanguagesP(void)
706 ToolkitTestApplication application;
707 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
708 TextLabel label = TextLabel::New();
709 DALI_TEST_CHECK( label );
711 Stage::GetCurrent().Add( label );
713 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
714 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
715 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
716 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
717 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
718 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
720 label.SetProperty( TextLabel::Property::TEXT, scripts );
721 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
723 application.SendNotification();
724 application.Render();
729 int UtcDaliToolkitTextLabelEmojisP(void)
731 ToolkitTestApplication application;
732 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
733 TextLabel label = TextLabel::New();
734 DALI_TEST_CHECK( label );
736 Stage::GetCurrent().Add( label );
738 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
740 char* pathNamePtr = get_current_dir_name();
741 const std::string pathName( pathNamePtr );
744 TextAbstraction::FontDescription fontDescription;
745 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
746 fontDescription.family = "BreezeColorEmoji";
747 fontDescription.width = TextAbstraction::FontWidth::NONE;
748 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
749 fontDescription.slant = TextAbstraction::FontSlant::NONE;
751 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
753 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>";
754 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
755 label.SetProperty( TextLabel::Property::TEXT, emojis );
757 Property::Map shadowMap;
758 shadowMap.Insert( "color", "green" );
759 shadowMap.Insert( "offset", "2 2" );
760 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
762 application.SendNotification();
763 application.Render();
768 int UtcDaliToolkitTextlabelScrollingP(void)
770 ToolkitTestApplication application;
771 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
772 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
773 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
775 DALI_TEST_CHECK( labelImmediate );
776 DALI_TEST_CHECK( labelFinished );
777 // Avoid a crash when core load gl resources.
778 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
779 Stage::GetCurrent().Add( labelImmediate );
780 // Turn on all the effects
781 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
782 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
783 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
784 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
785 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
787 Stage::GetCurrent().Add( labelFinished );
788 // Turn on all the effects
789 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
790 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
791 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
792 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
793 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
799 // Render some text with the shared atlas backend
800 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
803 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
804 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
806 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
807 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
808 application.SendNotification();
809 application.Render();
811 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
812 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
813 application.SendNotification();
814 application.Render();
819 tet_result(TET_FAIL);
825 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
827 ToolkitTestApplication application;
828 TextLabel labelShort = TextLabel::New("Some text to scroll");
829 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!");
831 DALI_TEST_CHECK( labelShort );
832 DALI_TEST_CHECK( labelLong );
833 // Avoid a crash when core load gl resources.
834 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
835 Stage::GetCurrent().Add( labelShort );
836 // Turn on all the effects
837 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
838 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
839 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
840 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
841 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
842 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
844 Stage::GetCurrent().Add( labelLong );
845 // Turn on all the effects
846 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
847 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
848 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
849 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
850 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
851 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
855 // Render some text with the shared atlas backend
856 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
857 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
858 application.SendNotification();
859 application.Render();
861 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
862 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
863 application.SendNotification();
864 application.Render();
869 tet_result(TET_FAIL);
875 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
877 ToolkitTestApplication application;
878 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
879 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
881 DALI_TEST_CHECK( labelShort );
882 DALI_TEST_CHECK( labelLong );
883 // Avoid a crash when core load gl resources.
884 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
885 Stage::GetCurrent().Add( labelShort );
886 // Turn on all the effects
887 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
888 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
889 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
890 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
891 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
892 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
894 Stage::GetCurrent().Add( labelLong );
895 // Turn on all the effects
896 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
897 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
898 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
899 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
900 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
901 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
905 // Render some text with the shared atlas backend
906 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
907 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
908 application.SendNotification();
909 application.Render();
911 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
912 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
913 application.SendNotification();
914 application.Render();
919 tet_result(TET_FAIL);
925 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
927 ToolkitTestApplication application;
928 TextLabel labelShort = TextLabel::New("Some text to scroll");
929 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!");
931 DALI_TEST_CHECK( labelShort );
932 DALI_TEST_CHECK( labelLong );
933 // Avoid a crash when core load gl resources.
934 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
935 Stage::GetCurrent().Add( labelShort );
936 // Turn on all the effects
937 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
938 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
939 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
940 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
941 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
942 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
944 Stage::GetCurrent().Add( labelLong );
945 // Turn on all the effects
946 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
947 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
948 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
949 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
950 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
951 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
955 // Render some text with the shared atlas backend
956 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
957 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
958 application.SendNotification();
959 application.Render();
961 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
962 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
963 application.SendNotification();
964 application.Render();
969 tet_result(TET_FAIL);
975 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
977 ToolkitTestApplication application;
978 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
979 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
981 DALI_TEST_CHECK( labelShort );
982 DALI_TEST_CHECK( labelLong );
983 // Avoid a crash when core load gl resources.
984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
985 Stage::GetCurrent().Add( labelShort );
986 // Turn on all the effects
987 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
988 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
989 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
990 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
991 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
992 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
994 Stage::GetCurrent().Add( labelLong );
995 // Turn on all the effects
996 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
997 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
998 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
999 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1000 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1001 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1005 // Render some text with the shared atlas backend
1006 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1007 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1008 application.SendNotification();
1009 application.Render();
1011 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1012 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1013 application.SendNotification();
1014 application.Render();
1019 tet_result(TET_FAIL);
1025 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1027 ToolkitTestApplication application;
1028 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1029 TextLabel label = TextLabel::New("Some text to scroll");
1030 DALI_TEST_CHECK( label );
1031 // Avoid a crash when core load gl resources.
1032 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1033 Stage::GetCurrent().Add( label );
1034 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1035 // Turn on all the effects
1036 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1037 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1038 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1039 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1042 application.SendNotification();
1043 application.Render();
1045 unsigned int actorCount1 = label.GetChildCount();
1046 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1050 // Render some text with the shared atlas backend
1051 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1052 application.SendNotification();
1053 application.Render(2000);
1055 unsigned int actorCount1 = label.GetChildCount();
1056 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1058 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1061 application.SendNotification();
1062 application.Render();
1064 unsigned int actorCount2 = label.GetChildCount();
1065 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1067 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1072 tet_result(TET_FAIL);
1078 int UtcDaliToolkitTextlabelScrollingN(void)
1080 ToolkitTestApplication application;
1081 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1083 TextLabel label = TextLabel::New("Some text to scroll");
1084 DALI_TEST_CHECK( label );
1086 Stage::GetCurrent().Add( label );
1088 // Avoid a crash when core load gl resources.
1089 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1091 // The text scrolling works only on single line text.
1092 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1094 // Turn on all the effects.
1095 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1096 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1097 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1099 // Enable the auto scrolling effect.
1100 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1102 // The auto scrolling shouldn't be enabled.
1103 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1104 DALI_TEST_CHECK( !enabled );
1109 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1111 ToolkitTestApplication application;
1112 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1114 TextLabel label = TextLabel::New("Some text to scroll");
1115 DALI_TEST_CHECK( label );
1117 Stage::GetCurrent().Add( label );
1119 // Avoid a crash when core load gl resources.
1120 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1122 // Turn on all the effects.
1123 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1124 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1125 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1129 // Enable the auto scrolling effect.
1130 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1131 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1133 // Disable the ellipsis
1134 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1137 application.SendNotification();
1138 application.Render();
1140 // Stop auto scrolling
1141 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1143 // Check the ellipsis property
1144 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1148 tet_result(TET_FAIL);
1154 int UtcDaliToolkitTextlabelEllipsis(void)
1156 ToolkitTestApplication application;
1157 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1159 TextLabel label = TextLabel::New("Hello world");
1160 DALI_TEST_CHECK( label );
1162 // Avoid a crash when core load gl resources.
1163 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1165 Stage::GetCurrent().Add( label );
1167 // Turn on all the effects
1168 label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1169 label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1170 label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1175 application.SendNotification();
1176 application.Render();
1180 tet_result(TET_FAIL);
1183 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1184 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1185 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1190 application.SendNotification();
1191 application.Render();
1195 tet_result(TET_FAIL);
1199 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1200 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1201 label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1206 application.SendNotification();
1207 application.Render();
1211 tet_result(TET_FAIL);
1217 int UtcDaliToolkitTextlabelTextWrapMode(void)
1219 ToolkitTestApplication application;
1220 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1224 TextLabel label = TextLabel::New();
1225 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1226 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1227 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1231 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1232 Stage::GetCurrent().Add( label );
1234 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1235 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1237 application.SendNotification();
1238 application.Render();
1240 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1241 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1243 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1244 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1246 application.SendNotification();
1247 application.Render();
1249 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1250 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1252 application.SendNotification();
1253 application.Render();
1255 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1256 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1258 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1259 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1261 application.SendNotification();
1262 application.Render();
1264 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1265 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1267 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1268 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1269 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1274 int UtcDaliToolkitTextLabelColorComponents(void)
1276 ToolkitTestApplication application;
1278 TextLabel label = TextLabel::New();
1279 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1280 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1281 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1282 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1283 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1285 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1286 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1287 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1288 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1289 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1291 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1292 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1293 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1294 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1295 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1297 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1298 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1299 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1301 // Test a transparent text - Rendering should be skipped.
1302 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1303 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1305 Stage::GetCurrent().Add( label );
1307 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1308 drawTrace.Enable( true );
1310 application.SendNotification();
1311 application.Render();
1313 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1315 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1324 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1328 application.SendNotification();
1329 application.Render();
1331 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1336 int UtcDaliToolkitTextlabelTextStyle01(void)
1338 ToolkitTestApplication application;
1339 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1341 TextLabel label = TextLabel::New();
1342 label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1343 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1344 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1345 Stage::GetCurrent().Add( label );
1347 Property::Map outlineMapSet;
1348 Property::Map outlineMapGet;
1350 outlineMapSet["color"] = Color::BLUE;
1351 outlineMapSet["width"] = 2.0f;
1352 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1354 application.SendNotification();
1355 application.Render();
1357 Property::Map shadowMapSet;
1358 shadowMapSet.Insert( "color", "green" );
1359 shadowMapSet.Insert( "offset", "2 2" );
1360 shadowMapSet.Insert( "blurRadius", "3" );
1361 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1363 outlineMapSet["color"] = Color::RED;
1364 outlineMapSet["width"] = 0.0f;
1365 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1367 application.SendNotification();
1368 application.Render();
1370 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1372 Property::Value* colorValue = outlineMapGet.Find("color");
1374 bool colorMatched( false );
1378 Property::Type valueType = colorValue->GetType();
1380 if ( Property::STRING == valueType )
1382 std::string stringValue;
1383 colorValue->Get( stringValue );
1384 if ( stringValue == "red" )
1386 colorMatched = true;
1389 else if ( Property::VECTOR4 == valueType )
1391 Vector4 colorVector4;
1392 colorValue->Get( colorVector4 );
1393 if ( colorVector4 == Color::RED )
1395 colorMatched = true;
1400 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1405 int UtcDaliToolkitTextlabelMultiline(void)
1407 ToolkitTestApplication application;
1408 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1410 TextLabel label = TextLabel::New();
1411 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1412 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1413 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1414 Stage::GetCurrent().Add( label );
1416 application.SendNotification();
1417 application.Render();
1419 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1420 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1422 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1424 application.SendNotification();
1425 application.Render();
1427 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1428 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1434 int UtcDaliToolkitTextlabelTextDirection(void)
1436 ToolkitTestApplication application;
1437 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1439 TextLabel label = TextLabel::New();
1440 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1442 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1443 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1444 Stage::GetCurrent().Add( label );
1447 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1450 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1451 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1453 // Test RTL text starting with weak character
1454 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1455 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1457 // Test RTL text string with emoji and weak character
1458 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1459 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1464 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1466 ToolkitTestApplication application;
1467 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1469 TextLabel label = TextLabel::New();
1471 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1472 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1473 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1474 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1475 Stage::GetCurrent().Add( label );
1476 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1478 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1479 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1481 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1482 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1487 int UtcDaliToolkitTextLabelBitmapFont(void)
1489 ToolkitTestApplication application;
1490 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1492 DevelText::BitmapFontDescription fontDescription;
1493 fontDescription.name = "Digits";
1494 fontDescription.underlinePosition = 0.f;
1495 fontDescription.underlineThickness = 0.f;
1497 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1498 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1499 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1500 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1501 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1502 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1503 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1504 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1505 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1506 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1507 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1509 TextAbstraction::BitmapFont bitmapFont;
1510 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1512 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1513 fontClient.GetFontId( bitmapFont );
1515 TextLabel label = TextLabel::New();
1517 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1518 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1520 // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1521 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1523 Stage::GetCurrent().Add( label );
1525 application.SendNotification();
1526 application.Render();
1528 // The text has been rendered if the height of the text-label is the height of the line.
1529 DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1534 int ConvertPointToPixel( float point )
1536 unsigned int horizontalDpi = 0u;
1537 unsigned int verticalDpi = 0u;
1538 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1539 fontClient.GetDpi( horizontalDpi, verticalDpi );
1541 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1544 int UtcDaliToolkitTextlabelTextFit(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1548 TextLabel label = TextLabel::New();
1549 Vector2 size( 460.0f, 100.0f );
1550 label.SetProperty( Actor::Property::SIZE, size );
1551 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1554 Property::Map textFitMapSet;
1555 textFitMapSet["enable"] = true;
1556 textFitMapSet["minSize"] = 10.f;
1557 textFitMapSet["maxSize"] = 100.f;
1558 textFitMapSet["stepSize"] = -1.f;
1559 textFitMapSet["fontSizeType"] = "pointSize";
1561 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1562 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1564 Stage::GetCurrent().Add( label );
1566 application.SendNotification();
1567 application.Render();
1569 const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1570 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1573 textFitMapSet.Clear();
1574 textFitMapSet["enable"] = true;
1575 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1576 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1577 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1578 textFitMapSet["fontSizeType"] = "pixelSize";
1580 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1582 application.SendNotification();
1583 application.Render();
1585 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1590 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1592 ToolkitTestApplication application;
1593 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1595 DevelText::BitmapFontDescription fontDescription;
1596 fontDescription.name = "Digits";
1597 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1599 TextAbstraction::BitmapFont bitmapFont;
1600 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1602 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1603 fontClient.GetFontId( bitmapFont );
1605 TextLabel label = TextLabel::New();
1606 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1607 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1608 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1609 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1610 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1612 Property::Map underlineMapSet;
1613 underlineMapSet.Clear();
1614 underlineMapSet.Insert( "enable", true );
1615 underlineMapSet.Insert( "color", Color::RED );
1616 underlineMapSet.Insert( "height", 1 );
1617 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1618 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1620 Stage::GetCurrent().Add( label );
1622 application.SendNotification();
1623 application.Render();
1625 const int maxTextureSize = Dali::GetMaxTextureSize();
1626 // Whether the rendered text is greater than maxTextureSize
1627 DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1629 // Check if the number of renderers is greater than 1.
1630 DALI_TEST_CHECK( label.GetRendererCount() > 1u );