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/text/text-enumerations-devel.h>
28 using namespace Toolkit;
30 void dali_textlabel_startup(void)
32 test_return_value = TET_UNDEF;
35 void dali_textlabel_cleanup(void)
37 test_return_value = TET_PASS;
43 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
44 const char* const PROPERTY_NAME_TEXT = "text";
45 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
46 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
47 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
48 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
49 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
50 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
53 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
54 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
55 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
58 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
59 const char* const PROPERTY_NAME_UNDERLINE = "underline";
60 const char* const PROPERTY_NAME_SHADOW = "shadow";
61 const char* const PROPERTY_NAME_EMBOSS = "emboss";
62 const char* const PROPERTY_NAME_OUTLINE = "outline";
63 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
65 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
66 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
67 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
69 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
70 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
71 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
73 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
75 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
77 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
79 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
81 Property::Value* valueSet = NULL;
82 if ( valueGet.first.type == Property::Key::INDEX )
84 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
88 // Get Key is a string so searching Set Map for a string key
89 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
92 if( NULL != valueSet )
94 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
96 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
99 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
101 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
104 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
106 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
109 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
111 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
114 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
116 Vector2 vector2Get = valueGet.second.Get<Vector2>();
117 Vector2 vector2Set = valueSet->Get<Vector2>();
118 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
121 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
123 Vector4 vector4Get = valueGet.second.Get<Vector4>();
124 Vector4 vector4Set = valueSet->Get<Vector4>();
125 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 );
131 if ( valueGet.first.type == Property::Key::INDEX )
133 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
137 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
149 int UtcDaliToolkitTextLabelConstructorP(void)
151 ToolkitTestApplication application;
152 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
154 DALI_TEST_CHECK( !textLabel );
158 int UtcDaliToolkitTextLabelNewP(void)
160 ToolkitTestApplication application;
161 tet_infoline(" UtcDaliToolkitTextLabelNewP");
162 TextLabel textLabel = TextLabel::New( "Test Text" );
163 DALI_TEST_CHECK( textLabel );
167 int UtcDaliToolkitTextLabelDownCastP(void)
169 ToolkitTestApplication application;
170 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
171 TextLabel textLabel1 = TextLabel::New();
172 BaseHandle object( textLabel1 );
174 TextLabel textLabel2 = TextLabel::DownCast( object );
175 DALI_TEST_CHECK( textLabel2 );
177 TextLabel textLabel3 = DownCast< TextLabel >( object );
178 DALI_TEST_CHECK( textLabel3 );
182 int UtcDaliToolkitTextLabelDownCastN(void)
184 ToolkitTestApplication application;
185 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
186 BaseHandle uninitializedObject;
187 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
188 DALI_TEST_CHECK( !textLabel1 );
190 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
191 DALI_TEST_CHECK( !textLabel2 );
195 int UtcDaliToolkitTextLabelCopyConstructorP(void)
197 ToolkitTestApplication application;
198 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
199 TextLabel textLabel = TextLabel::New();
200 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
202 TextLabel copy( textLabel );
203 DALI_TEST_CHECK( copy );
204 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
208 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
210 ToolkitTestApplication application;
211 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
212 TextLabel textLabel = TextLabel::New();
213 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
215 TextLabel copy = textLabel;
216 DALI_TEST_CHECK( copy );
217 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
221 // Positive test case for a method
222 int UtcDaliToolkitTextLabelGetPropertyP(void)
224 ToolkitTestApplication application;
225 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
226 TextLabel label = TextLabel::New("Test Text");
227 DALI_TEST_CHECK( label );
229 // Check Property Indices are correct
230 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
231 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
232 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
233 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
234 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
235 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
236 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
237 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
238 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
239 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
240 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
241 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
242 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
243 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
244 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
245 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
246 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
247 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
248 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
249 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
250 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
251 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
257 int UtcDaliToolkitTextLabelSetPropertyP(void)
259 ToolkitTestApplication application;
260 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
261 TextLabel label = TextLabel::New();
262 DALI_TEST_CHECK( label );
264 Stage::GetCurrent().Add( label );
266 // Note - we can't check the defaults since the stylesheets are platform-specific
267 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
268 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
270 // Check that text can be correctly reset
271 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
272 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
274 // Check font properties.
275 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
276 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
278 Property::Map fontStyleMapSet;
279 Property::Map fontStyleMapGet;
281 fontStyleMapSet.Insert( "weight", "bold" );
282 fontStyleMapSet.Insert( "width", "condensed" );
283 fontStyleMapSet.Insert( "slant", "italic" );
284 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
286 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
287 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
288 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
290 // Check the old font style format.
291 fontStyleMapSet.Clear();
292 fontStyleMapSet.Insert( "weight", "thin" );
293 fontStyleMapSet.Insert( "width", "expanded" );
294 fontStyleMapSet.Insert( "slant", "oblique" );
295 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
297 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
298 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
299 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
301 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
302 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
305 fontStyleMapSet.Clear();
306 fontStyleMapSet.Insert( "weight", "normal" );
307 fontStyleMapSet.Insert( "slant", "oblique" );
309 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 fontStyleMapSet.Clear();
315 fontStyleMapSet.Insert( "slant", "roman" );
317 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
318 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
319 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
321 // Replace 'roman' for 'normal'.
322 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
323 if( NULL != slantValue )
325 if( "normal" == slantValue->Get<std::string>() )
327 fontStyleMapGet["slant"] = "roman";
330 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
332 fontStyleMapSet.Clear();
334 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
335 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
336 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
337 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
340 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
341 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
343 // Check that the Alignment properties can be correctly set
344 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
345 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
346 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
347 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
349 // Check that text color can be properly set
350 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
351 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
353 Property::Map underlineMapSet;
354 Property::Map underlineMapGet;
356 underlineMapSet.Insert( "enable", "false" );
357 underlineMapSet.Insert( "color", "blue" );
358 underlineMapSet.Insert( "height", "0" );
360 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
361 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
362 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
364 TextLabel label2 = TextLabel::New( "New text" );
365 DALI_TEST_CHECK( label2 );
366 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
368 // Check the enable markup property.
369 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
370 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
371 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
373 // Check the text property when markup is enabled
374 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
375 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
377 application.SendNotification();
378 application.Render();
380 // Check autoscroll properties
381 const int SCROLL_SPEED = 80;
382 const int SCROLL_LOOPS = 4;
383 const float SCROLL_GAP = 50.0f;
384 const float SCROLL_LOOP_DELAY = 0.3f;
385 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
386 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
388 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
389 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
390 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
391 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
392 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
393 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
394 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
395 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
396 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
397 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
398 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
399 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
401 //Check autoscroll stop type property
402 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
403 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
405 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
406 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
408 // test natural size with multi-line and line spacing
410 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
411 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
412 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
413 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
414 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
416 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
417 // The height of the text when multi-line is enabled will be larger
418 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
419 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
421 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
422 // Everything else will remain the same
423 int lineSpacing = 20;
424 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
425 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
426 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
427 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
430 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
432 TextLabel label3 = TextLabel::New("Some text here end there end here");
433 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
434 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
435 Vector3 textNaturalSize = label3.GetNaturalSize();
436 int lineSpacing = 20;
437 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
438 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
439 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
440 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
442 // Check the line spacing property
443 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
444 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
445 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
447 // Check the underline property
448 underlineMapSet.Clear();
449 underlineMapSet.Insert( "enable", "true" );
450 underlineMapSet.Insert( "color", "red" );
451 underlineMapSet.Insert( "height", "1" );
453 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
455 application.SendNotification();
456 application.Render();
458 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
459 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
460 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
462 underlineMapSet.Clear();
464 Property::Map underlineDisabledMapGet;
465 underlineDisabledMapGet.Insert( "enable", "false" );
466 underlineDisabledMapGet.Insert( "color", "red" );
467 underlineDisabledMapGet.Insert( "height", "1" );
469 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
470 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
471 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
472 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
474 // Check the shadow property
476 Property::Map shadowMapSet;
477 Property::Map shadowMapGet;
479 shadowMapSet.Insert( "color", Color::GREEN );
480 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
481 shadowMapSet.Insert( "blurRadius", 5.0f );
483 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
485 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
486 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
487 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
489 shadowMapSet.Clear();
490 Property::Map shadowDisabledMapGet;
491 shadowDisabledMapGet.Insert( "color", Color::GREEN );
492 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
493 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
495 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
497 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
498 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
499 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
501 // Check the emboss property
502 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
503 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
505 // Check the outline property
507 // Test string type first
508 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
509 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
510 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
512 // Then test the property map type
513 Property::Map outlineMapSet;
514 Property::Map outlineMapGet;
516 outlineMapSet["color"] = Color::RED;
517 outlineMapSet["width"] = 2.0f;
518 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
520 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
521 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
522 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
524 // Check the background property
525 Property::Map backgroundMapSet;
526 Property::Map backgroundMapGet;
528 backgroundMapSet["enable"] = true;
529 backgroundMapSet["color"] = Color::RED;
530 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
532 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
533 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
534 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
536 // Check the pixel size of font
537 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
538 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
540 // Check the ellipsis property
541 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
542 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
543 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
545 // Check the layout direction property
546 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
547 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
549 application.SendNotification();
550 application.Render();
555 int UtcDaliToolkitTextlabelAtlasRenderP(void)
557 ToolkitTestApplication application;
558 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
559 TextLabel label = TextLabel::New("Test Text");
560 DALI_TEST_CHECK( label );
562 // Avoid a crash when core load gl resources.
563 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
565 Stage::GetCurrent().Add( label );
567 // Turn on all the effects
568 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
569 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
571 Property::Map underlineMap;
572 underlineMap.Insert( "enable", "true" );
573 underlineMap.Insert( "color", "red" );
574 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
576 Property::Map shadowMap;
577 shadowMap.Insert( "color", Color::BLUE );
578 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
579 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
583 // Render some text with the shared atlas backend
584 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
585 application.SendNotification();
586 application.Render();
590 tet_result(TET_FAIL);
595 // Render some text with the shared atlas backend
596 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
597 application.SendNotification();
598 application.Render();
602 tet_result(TET_FAIL);
607 int UtcDaliToolkitTextLabelLanguagesP(void)
609 ToolkitTestApplication application;
610 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
611 TextLabel label = TextLabel::New();
612 DALI_TEST_CHECK( label );
614 Stage::GetCurrent().Add( label );
616 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
617 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
618 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
619 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
620 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
621 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
623 label.SetProperty( TextLabel::Property::TEXT, scripts );
624 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
626 application.SendNotification();
627 application.Render();
632 int UtcDaliToolkitTextLabelEmojisP(void)
634 ToolkitTestApplication application;
635 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
636 TextLabel label = TextLabel::New();
637 DALI_TEST_CHECK( label );
639 Stage::GetCurrent().Add( label );
641 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
643 char* pathNamePtr = get_current_dir_name();
644 const std::string pathName( pathNamePtr );
647 TextAbstraction::FontDescription fontDescription;
648 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
649 fontDescription.family = "BreezeColorEmoji";
650 fontDescription.width = TextAbstraction::FontWidth::NONE;
651 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
652 fontDescription.slant = TextAbstraction::FontSlant::NONE;
654 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
656 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>";
657 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
658 label.SetProperty( TextLabel::Property::TEXT, emojis );
660 Property::Map shadowMap;
661 shadowMap.Insert( "color", "green" );
662 shadowMap.Insert( "offset", "2 2" );
663 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
665 application.SendNotification();
666 application.Render();
671 int UtcDaliToolkitTextlabelScrollingP(void)
673 ToolkitTestApplication application;
674 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
675 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
676 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
678 DALI_TEST_CHECK( labelImmediate );
679 DALI_TEST_CHECK( labelFinished );
680 // Avoid a crash when core load gl resources.
681 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
682 Stage::GetCurrent().Add( labelImmediate );
683 // Turn on all the effects
684 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
685 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
686 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
687 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
688 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
690 Stage::GetCurrent().Add( labelFinished );
691 // Turn on all the effects
692 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
693 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
694 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
695 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
696 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
702 // Render some text with the shared atlas backend
703 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
704 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
706 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
707 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
709 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
710 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
711 application.SendNotification();
712 application.Render();
714 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
715 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
716 application.SendNotification();
717 application.Render();
722 tet_result(TET_FAIL);
728 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
730 ToolkitTestApplication application;
731 TextLabel labelShort = TextLabel::New("Some text to scroll");
732 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!");
734 DALI_TEST_CHECK( labelShort );
735 DALI_TEST_CHECK( labelLong );
736 // Avoid a crash when core load gl resources.
737 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
738 Stage::GetCurrent().Add( labelShort );
739 // Turn on all the effects
740 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
741 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
742 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
743 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
744 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
745 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
747 Stage::GetCurrent().Add( labelLong );
748 // Turn on all the effects
749 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
750 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
751 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
752 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
753 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
754 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
758 // Render some text with the shared atlas backend
759 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
760 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
761 application.SendNotification();
762 application.Render();
764 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
765 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
766 application.SendNotification();
767 application.Render();
772 tet_result(TET_FAIL);
778 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
780 ToolkitTestApplication application;
781 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
782 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
784 DALI_TEST_CHECK( labelShort );
785 DALI_TEST_CHECK( labelLong );
786 // Avoid a crash when core load gl resources.
787 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
788 Stage::GetCurrent().Add( labelShort );
789 // Turn on all the effects
790 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
791 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
792 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
793 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
794 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
795 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
797 Stage::GetCurrent().Add( labelLong );
798 // Turn on all the effects
799 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
800 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
801 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
802 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
803 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
804 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
808 // Render some text with the shared atlas backend
809 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
810 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
811 application.SendNotification();
812 application.Render();
814 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
815 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
816 application.SendNotification();
817 application.Render();
822 tet_result(TET_FAIL);
828 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
830 ToolkitTestApplication application;
831 TextLabel labelShort = TextLabel::New("Some text to scroll");
832 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!");
834 DALI_TEST_CHECK( labelShort );
835 DALI_TEST_CHECK( labelLong );
836 // Avoid a crash when core load gl resources.
837 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
838 Stage::GetCurrent().Add( labelShort );
839 // Turn on all the effects
840 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
841 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
842 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
843 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
844 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
845 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
847 Stage::GetCurrent().Add( labelLong );
848 // Turn on all the effects
849 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
850 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
851 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
852 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
853 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
854 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
858 // Render some text with the shared atlas backend
859 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
860 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
861 application.SendNotification();
862 application.Render();
864 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
865 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
866 application.SendNotification();
867 application.Render();
872 tet_result(TET_FAIL);
878 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
880 ToolkitTestApplication application;
881 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
882 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
884 DALI_TEST_CHECK( labelShort );
885 DALI_TEST_CHECK( labelLong );
886 // Avoid a crash when core load gl resources.
887 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
888 Stage::GetCurrent().Add( labelShort );
889 // Turn on all the effects
890 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
891 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
892 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
893 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
894 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
895 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
897 Stage::GetCurrent().Add( labelLong );
898 // Turn on all the effects
899 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
900 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
901 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
902 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
903 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
904 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
908 // Render some text with the shared atlas backend
909 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
910 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
911 application.SendNotification();
912 application.Render();
914 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
915 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
916 application.SendNotification();
917 application.Render();
922 tet_result(TET_FAIL);
928 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
930 ToolkitTestApplication application;
931 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
932 TextLabel label = TextLabel::New("Some text to scroll");
933 DALI_TEST_CHECK( label );
934 // Avoid a crash when core load gl resources.
935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
936 Stage::GetCurrent().Add( label );
937 label.SetSize( 360.0f, 20.f );
938 // Turn on all the effects
939 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
940 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
941 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
942 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
945 application.SendNotification();
946 application.Render();
948 unsigned int actorCount1 = label.GetChildCount();
949 tet_printf("Initial actor count is(%d)\n", actorCount1 );
953 // Render some text with the shared atlas backend
954 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
955 application.SendNotification();
956 application.Render(2000);
958 unsigned int actorCount1 = label.GetChildCount();
959 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
961 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
964 application.SendNotification();
965 application.Render();
967 unsigned int actorCount2 = label.GetChildCount();
968 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
970 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
975 tet_result(TET_FAIL);
981 int UtcDaliToolkitTextlabelScrollingN(void)
983 ToolkitTestApplication application;
984 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
986 TextLabel label = TextLabel::New("Some text to scroll");
987 DALI_TEST_CHECK( label );
989 Stage::GetCurrent().Add( label );
991 // Avoid a crash when core load gl resources.
992 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
994 // The text scrolling works only on single line text.
995 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
997 // Turn on all the effects.
998 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
999 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1000 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1002 // Enable the auto scrolling effect.
1003 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1005 // The auto scrolling shouldn't be enabled.
1006 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1007 DALI_TEST_CHECK( !enabled );
1012 int UtcDaliToolkitTextlabelEllipsis(void)
1014 ToolkitTestApplication application;
1015 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1017 TextLabel label = TextLabel::New("Hello world");
1018 DALI_TEST_CHECK( label );
1020 // Avoid a crash when core load gl resources.
1021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1023 Stage::GetCurrent().Add( label );
1025 // Turn on all the effects
1026 label.SetAnchorPoint( AnchorPoint::CENTER );
1027 label.SetParentOrigin( ParentOrigin::CENTER );
1028 label.SetSize( 360.0f, 10.f );
1033 application.SendNotification();
1034 application.Render();
1038 tet_result(TET_FAIL);
1041 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1042 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1043 label.SetSize( 400.0f, 10.f );
1048 application.SendNotification();
1049 application.Render();
1053 tet_result(TET_FAIL);
1057 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1058 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1059 label.SetSize( 400.0f, 10.f );
1064 application.SendNotification();
1065 application.Render();
1069 tet_result(TET_FAIL);
1075 int UtcDaliToolkitTextlabelTextWrapMode(void)
1077 ToolkitTestApplication application;
1078 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1082 TextLabel label = TextLabel::New();
1083 label.SetSize( 300.0f, 300.f );
1084 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1085 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1089 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1090 Stage::GetCurrent().Add( label );
1092 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1093 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1095 application.SendNotification();
1096 application.Render();
1098 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1099 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1101 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1102 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1104 application.SendNotification();
1105 application.Render();
1107 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1108 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1110 application.SendNotification();
1111 application.Render();
1113 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1114 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1116 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1117 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1119 application.SendNotification();
1120 application.Render();
1122 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1123 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1125 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1126 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1127 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1132 int UtcDaliToolkitTextLabelColorComponents(void)
1134 ToolkitTestApplication application;
1136 TextLabel label = TextLabel::New();
1137 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1138 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1139 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1140 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1141 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1143 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1144 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1145 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1146 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1147 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1149 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1150 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1151 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1152 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1153 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1155 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1156 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1157 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1158 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1160 // Test a transparent text - Rendering should be skipped.
1161 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1162 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1164 Stage::GetCurrent().Add( label );
1166 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1167 drawTrace.Enable( true );
1169 application.SendNotification();
1170 application.Render();
1172 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1174 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1178 application.SendNotification();
1179 application.Render();
1181 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1183 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1187 application.SendNotification();
1188 application.Render();
1190 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1195 int UtcDaliToolkitTextlabelTextStyle01(void)
1197 ToolkitTestApplication application;
1198 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1200 TextLabel label = TextLabel::New();
1201 label.SetSize( 300.0f, 300.f );
1202 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1203 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1204 Stage::GetCurrent().Add( label );
1206 Property::Map outlineMapSet;
1207 Property::Map outlineMapGet;
1209 outlineMapSet["color"] = Color::BLUE;
1210 outlineMapSet["width"] = 2.0f;
1211 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1213 application.SendNotification();
1214 application.Render();
1216 Property::Map shadowMapSet;
1217 shadowMapSet.Insert( "color", "green" );
1218 shadowMapSet.Insert( "offset", "2 2" );
1219 shadowMapSet.Insert( "blurRadius", "3" );
1220 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1222 outlineMapSet["color"] = Color::RED;
1223 outlineMapSet["width"] = 0.0f;
1224 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1226 application.SendNotification();
1227 application.Render();
1229 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1231 Property::Value* colorValue = outlineMapGet.Find("color");
1233 bool colorMatched( false );
1237 Property::Type valueType = colorValue->GetType();
1239 if ( Property::STRING == valueType )
1241 std::string stringValue;
1242 colorValue->Get( stringValue );
1243 if ( stringValue == "red" )
1245 colorMatched = true;
1248 else if ( Property::VECTOR4 == valueType )
1250 Vector4 colorVector4;
1251 colorValue->Get( colorVector4 );
1252 if ( colorVector4 == Color::RED )
1254 colorMatched = true;
1259 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1264 int UtcDaliToolkitTextlabelMultiline(void)
1266 ToolkitTestApplication application;
1267 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1269 TextLabel label = TextLabel::New();
1270 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1271 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1272 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1273 Stage::GetCurrent().Add( label );
1275 application.SendNotification();
1276 application.Render();
1278 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1279 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1281 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1283 application.SendNotification();
1284 application.Render();
1286 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1287 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1293 int UtcDaliToolkitTextlabelTextDirection(void)
1295 ToolkitTestApplication application;
1296 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1298 TextLabel label = TextLabel::New();
1299 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1301 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1302 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1303 Stage::GetCurrent().Add( label );
1306 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1309 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1310 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1312 // Test RTL text starting with weak character
1313 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1314 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1316 // Test RTL text string with emoji and weak character
1317 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1318 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1323 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1325 ToolkitTestApplication application;
1326 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1328 TextLabel label = TextLabel::New();
1330 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1331 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1332 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1333 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1334 Stage::GetCurrent().Add( label );
1335 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1337 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1338 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1340 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1341 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );