2 * Copyright (c) 2017 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_SHADOW_OFFSET = "shadowOffset";
53 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
54 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
55 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
56 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
57 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
63 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
64 const char* const PROPERTY_NAME_UNDERLINE = "underline";
65 const char* const PROPERTY_NAME_SHADOW = "shadow";
66 const char* const PROPERTY_NAME_EMBOSS = "emboss";
67 const char* const PROPERTY_NAME_OUTLINE = "outline";
69 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
70 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
71 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
73 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
74 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
75 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
77 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
79 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
81 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
83 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
85 Property::Value* valueSet = NULL;
86 if ( valueGet.first.type == Property::Key::INDEX )
88 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
92 // Get Key is a string so searching Set Map for a string key
93 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
96 if( NULL != valueSet )
98 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
100 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
103 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
105 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
108 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
110 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
113 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
115 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
118 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
120 Vector2 vector2Get = valueGet.second.Get<Vector2>();
121 Vector2 vector2Set = valueSet->Get<Vector2>();
122 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
125 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
127 Vector4 vector4Get = valueGet.second.Get<Vector4>();
128 Vector4 vector4Set = valueSet->Get<Vector4>();
129 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 );
135 if ( valueGet.first.type == Property::Key::INDEX )
137 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
141 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
153 int UtcDaliToolkitTextLabelConstructorP(void)
155 ToolkitTestApplication application;
156 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
158 DALI_TEST_CHECK( !textLabel );
162 int UtcDaliToolkitTextLabelNewP(void)
164 ToolkitTestApplication application;
165 tet_infoline(" UtcDaliToolkitTextLabelNewP");
166 TextLabel textLabel = TextLabel::New( "Test Text" );
167 DALI_TEST_CHECK( textLabel );
171 int UtcDaliToolkitTextLabelDownCastP(void)
173 ToolkitTestApplication application;
174 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
175 TextLabel textLabel1 = TextLabel::New();
176 BaseHandle object( textLabel1 );
178 TextLabel textLabel2 = TextLabel::DownCast( object );
179 DALI_TEST_CHECK( textLabel2 );
181 TextLabel textLabel3 = DownCast< TextLabel >( object );
182 DALI_TEST_CHECK( textLabel3 );
186 int UtcDaliToolkitTextLabelDownCastN(void)
188 ToolkitTestApplication application;
189 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
190 BaseHandle uninitializedObject;
191 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
192 DALI_TEST_CHECK( !textLabel1 );
194 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
195 DALI_TEST_CHECK( !textLabel2 );
199 int UtcDaliToolkitTextLabelCopyConstructorP(void)
201 ToolkitTestApplication application;
202 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
203 TextLabel textLabel = TextLabel::New();
204 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
206 TextLabel copy( textLabel );
207 DALI_TEST_CHECK( copy );
208 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
212 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
214 ToolkitTestApplication application;
215 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
216 TextLabel textLabel = TextLabel::New();
217 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
219 TextLabel copy = textLabel;
220 DALI_TEST_CHECK( copy );
221 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
225 // Positive test case for a method
226 int UtcDaliToolkitTextLabelGetPropertyP(void)
228 ToolkitTestApplication application;
229 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
230 TextLabel label = TextLabel::New("Test Text");
231 DALI_TEST_CHECK( label );
233 // Check Property Indices are correct
234 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
235 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
236 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
237 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
238 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
239 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
240 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
241 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
242 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
243 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
244 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
245 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
246 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
247 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
248 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
249 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
250 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
251 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
265 int UtcDaliToolkitTextLabelSetPropertyP(void)
267 ToolkitTestApplication application;
268 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
269 TextLabel label = TextLabel::New();
270 DALI_TEST_CHECK( label );
272 Stage::GetCurrent().Add( label );
274 // Note - we can't check the defaults since the stylesheets are platform-specific
275 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
276 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
278 // Check that text can be correctly reset
279 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
280 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
282 // Check font properties.
283 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
284 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
286 Property::Map fontStyleMapSet;
287 Property::Map fontStyleMapGet;
289 fontStyleMapSet.Insert( "weight", "bold" );
290 fontStyleMapSet.Insert( "width", "condensed" );
291 fontStyleMapSet.Insert( "slant", "italic" );
292 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
294 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
295 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
296 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
298 // Check the old font style format.
299 fontStyleMapSet.Clear();
300 fontStyleMapSet.Insert( "weight", "thin" );
301 fontStyleMapSet.Insert( "width", "expanded" );
302 fontStyleMapSet.Insert( "slant", "oblique" );
303 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
305 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
306 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
307 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
309 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
310 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 fontStyleMapSet.Clear();
314 fontStyleMapSet.Insert( "weight", "normal" );
315 fontStyleMapSet.Insert( "slant", "oblique" );
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 );
320 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
322 fontStyleMapSet.Clear();
323 fontStyleMapSet.Insert( "slant", "roman" );
325 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
326 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
327 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
329 // Replace 'roman' for 'normal'.
330 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
331 if( NULL != slantValue )
333 if( "normal" == slantValue->Get<std::string>() )
335 fontStyleMapGet["slant"] = "roman";
338 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
340 fontStyleMapSet.Clear();
342 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
343 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
344 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
345 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
348 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
349 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
351 // Check that the Alignment properties can be correctly set
352 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
353 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
354 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
355 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
357 // Check that text color can be properly set
358 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
359 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
360 // The underline color is changed as well.
361 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
363 Property::Map underlineMapSet;
364 Property::Map underlineMapGet;
366 underlineMapSet.Insert( "enable", "false" );
367 underlineMapSet.Insert( "color", "blue" );
368 underlineMapSet.Insert( "height", "0" );
370 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
371 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
372 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
374 // Check that shadow parameters can be correctly set
375 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
376 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
377 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
378 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
380 // Check that underline parameters can be correctly set
381 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
382 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
383 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
384 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
385 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
386 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, 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 application.SendNotification();
402 application.Render();
404 // Check autoscroll properties
405 const int SCROLL_SPEED = 80;
406 const int SCROLL_LOOPS = 4;
407 const float SCROLL_GAP = 50.0f;
408 const float SCROLL_LOOP_DELAY = 0.3f;
409 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
410 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
412 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
413 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
414 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
415 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
416 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
417 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
418 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
419 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
420 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
421 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
422 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
423 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
425 //Check autoscroll stop type property
426 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
427 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
429 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
430 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
433 // Check the line spacing property
434 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
435 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
436 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
438 // Check the underline property
440 underlineMapSet.Clear();
441 underlineMapSet.Insert( "enable", "true" );
442 underlineMapSet.Insert( "color", "red" );
443 underlineMapSet.Insert( "height", "1" );
445 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
447 application.SendNotification();
448 application.Render();
450 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
451 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
452 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
454 underlineMapSet.Clear();
456 Property::Map underlineDisabledMapGet;
457 underlineDisabledMapGet.Insert( "enable", "false" );
458 underlineDisabledMapGet.Insert( "color", "red" );
459 underlineDisabledMapGet.Insert( "height", "1" );
461 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
462 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
463 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
464 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
466 // Check the shadow property
468 Property::Map shadowMapSet;
469 Property::Map shadowMapGet;
471 shadowMapSet.Insert( "color", Color::GREEN );
472 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
473 shadowMapSet.Insert( "blurRadius", 5.0f );
475 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
477 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
478 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
479 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
481 shadowMapSet.Clear();
482 Property::Map shadowDisabledMapGet;
483 shadowDisabledMapGet.Insert( "color", Color::GREEN );
484 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
485 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
487 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
489 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
490 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
491 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
493 // Check the emboss property
494 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
495 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
497 // Check the outline property
499 // Test string type first
500 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
501 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
502 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
504 // Then test the property map type
505 Property::Map outlineMapSet;
506 Property::Map outlineMapGet;
508 outlineMapSet["color"] = Color::RED;
509 outlineMapSet["width"] = 2.0f;
510 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
512 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
513 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
514 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
516 // Check the pixel size of font
517 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
518 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
520 // Check the ellipsis property
521 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
522 label.SetProperty( TextLabel::Property::ELLIPSIS, true );
523 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
525 // Check the layout direction property
526 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
527 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
529 application.SendNotification();
530 application.Render();
535 int UtcDaliToolkitTextlabelAtlasRenderP(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
539 TextLabel label = TextLabel::New("Test Text");
540 DALI_TEST_CHECK( label );
542 // Avoid a crash when core load gl resources.
543 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
545 Stage::GetCurrent().Add( label );
547 // Turn on all the effects
548 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
549 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
550 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
551 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
552 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
553 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
557 // Render some text with the shared atlas backend
558 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
559 application.SendNotification();
560 application.Render();
564 tet_result(TET_FAIL);
569 // Render some text with the shared atlas backend
570 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
571 application.SendNotification();
572 application.Render();
576 tet_result(TET_FAIL);
581 int UtcDaliToolkitTextLabelLanguagesP(void)
583 ToolkitTestApplication application;
584 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
585 TextLabel label = TextLabel::New();
586 DALI_TEST_CHECK( label );
588 Stage::GetCurrent().Add( label );
590 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
591 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
592 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
593 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
594 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
595 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
597 label.SetProperty( TextLabel::Property::TEXT, scripts );
598 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
600 application.SendNotification();
601 application.Render();
606 int UtcDaliToolkitTextLabelEmojisP(void)
608 ToolkitTestApplication application;
609 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
610 TextLabel label = TextLabel::New();
611 DALI_TEST_CHECK( label );
613 Stage::GetCurrent().Add( label );
615 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
617 char* pathNamePtr = get_current_dir_name();
618 const std::string pathName( pathNamePtr );
621 TextAbstraction::FontDescription fontDescription;
622 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
623 fontDescription.family = "BreezeColorEmoji";
624 fontDescription.width = TextAbstraction::FontWidth::NONE;
625 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
626 fontDescription.slant = TextAbstraction::FontSlant::NONE;
628 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
630 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>";
631 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
632 label.SetProperty( TextLabel::Property::TEXT, emojis );
634 Property::Map shadowMap;
635 shadowMap.Insert( "color", "green" );
636 shadowMap.Insert( "offset", "2 2" );
637 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
639 application.SendNotification();
640 application.Render();
645 int UtcDaliToolkitTextlabelScrollingP(void)
647 ToolkitTestApplication application;
648 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
649 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
650 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
652 DALI_TEST_CHECK( labelImmediate );
653 DALI_TEST_CHECK( labelFinished );
654 // Avoid a crash when core load gl resources.
655 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
656 Stage::GetCurrent().Add( labelImmediate );
657 // Turn on all the effects
658 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
659 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
660 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
661 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
662 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
664 Stage::GetCurrent().Add( labelFinished );
665 // Turn on all the effects
666 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
667 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
668 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
669 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
670 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
676 // Render some text with the shared atlas backend
677 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
678 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
680 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
681 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
683 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
684 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
685 application.SendNotification();
686 application.Render();
688 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
689 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
690 application.SendNotification();
691 application.Render();
696 tet_result(TET_FAIL);
702 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
704 ToolkitTestApplication application;
705 TextLabel labelShort = TextLabel::New("Some text to scroll");
706 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!");
708 DALI_TEST_CHECK( labelShort );
709 DALI_TEST_CHECK( labelLong );
710 // Avoid a crash when core load gl resources.
711 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
712 Stage::GetCurrent().Add( labelShort );
713 // Turn on all the effects
714 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
715 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
716 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
717 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
718 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
719 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
721 Stage::GetCurrent().Add( labelLong );
722 // Turn on all the effects
723 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
724 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
725 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
726 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
727 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
728 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
732 // Render some text with the shared atlas backend
733 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
734 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
735 application.SendNotification();
736 application.Render();
738 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
739 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
740 application.SendNotification();
741 application.Render();
746 tet_result(TET_FAIL);
752 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
754 ToolkitTestApplication application;
755 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
756 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
758 DALI_TEST_CHECK( labelShort );
759 DALI_TEST_CHECK( labelLong );
760 // Avoid a crash when core load gl resources.
761 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
762 Stage::GetCurrent().Add( labelShort );
763 // Turn on all the effects
764 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
765 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
766 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
767 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
768 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
769 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
771 Stage::GetCurrent().Add( labelLong );
772 // Turn on all the effects
773 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
774 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
775 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
776 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
777 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
778 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
782 // Render some text with the shared atlas backend
783 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
784 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
785 application.SendNotification();
786 application.Render();
788 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
789 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
790 application.SendNotification();
791 application.Render();
796 tet_result(TET_FAIL);
802 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
804 ToolkitTestApplication application;
805 TextLabel labelShort = TextLabel::New("Some text to scroll");
806 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!");
808 DALI_TEST_CHECK( labelShort );
809 DALI_TEST_CHECK( labelLong );
810 // Avoid a crash when core load gl resources.
811 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
812 Stage::GetCurrent().Add( labelShort );
813 // Turn on all the effects
814 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
815 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
816 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
817 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
818 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
819 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
821 Stage::GetCurrent().Add( labelLong );
822 // Turn on all the effects
823 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
824 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
825 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
826 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
827 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
828 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
832 // Render some text with the shared atlas backend
833 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
834 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
835 application.SendNotification();
836 application.Render();
838 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
839 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
840 application.SendNotification();
841 application.Render();
846 tet_result(TET_FAIL);
852 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
854 ToolkitTestApplication application;
855 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
856 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
858 DALI_TEST_CHECK( labelShort );
859 DALI_TEST_CHECK( labelLong );
860 // Avoid a crash when core load gl resources.
861 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
862 Stage::GetCurrent().Add( labelShort );
863 // Turn on all the effects
864 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
865 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
866 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
867 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
868 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
869 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
871 Stage::GetCurrent().Add( labelLong );
872 // Turn on all the effects
873 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
874 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
875 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
876 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
877 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
878 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
882 // Render some text with the shared atlas backend
883 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
884 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
885 application.SendNotification();
886 application.Render();
888 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
889 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
890 application.SendNotification();
891 application.Render();
896 tet_result(TET_FAIL);
902 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
904 ToolkitTestApplication application;
905 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
906 TextLabel label = TextLabel::New("Some text to scroll");
907 DALI_TEST_CHECK( label );
908 // Avoid a crash when core load gl resources.
909 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
910 Stage::GetCurrent().Add( label );
911 label.SetSize( 360.0f, 20.f );
912 // Turn on all the effects
913 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
914 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
915 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
916 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
919 application.SendNotification();
920 application.Render();
922 unsigned int actorCount1 = label.GetChildCount();
923 tet_printf("Initial actor count is(%d)\n", actorCount1 );
927 // Render some text with the shared atlas backend
928 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
929 application.SendNotification();
930 application.Render(2000);
932 unsigned int actorCount1 = label.GetChildCount();
933 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
935 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
938 application.SendNotification();
939 application.Render();
941 unsigned int actorCount2 = label.GetChildCount();
942 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
944 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
949 tet_result(TET_FAIL);
955 int UtcDaliToolkitTextlabelScrollingN(void)
957 ToolkitTestApplication application;
958 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
960 TextLabel label = TextLabel::New("Some text to scroll");
961 DALI_TEST_CHECK( label );
963 Stage::GetCurrent().Add( label );
965 // Avoid a crash when core load gl resources.
966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
968 // The text scrolling works only on single line text.
969 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
971 // Turn on all the effects.
972 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
973 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
974 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
976 // Enable the auto scrolling effect.
977 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
979 // The auto scrolling shouldn't be enabled.
980 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
981 DALI_TEST_CHECK( !enabled );
986 int UtcDaliToolkitTextlabelEllipsis(void)
988 ToolkitTestApplication application;
989 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
991 TextLabel label = TextLabel::New("Hello world");
992 DALI_TEST_CHECK( label );
994 // Avoid a crash when core load gl resources.
995 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
997 Stage::GetCurrent().Add( label );
999 // Turn on all the effects
1000 label.SetAnchorPoint( AnchorPoint::CENTER );
1001 label.SetParentOrigin( ParentOrigin::CENTER );
1002 label.SetSize( 360.0f, 10.f );
1007 application.SendNotification();
1008 application.Render();
1012 tet_result(TET_FAIL);
1018 int UtcDaliToolkitTextlabelTextWrapMode(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1025 TextLabel label = TextLabel::New();
1026 label.SetSize( 300.0f, 300.f );
1027 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1028 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1032 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1033 Stage::GetCurrent().Add( label );
1035 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1036 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1038 application.SendNotification();
1039 application.Render();
1041 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1042 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1044 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1045 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1047 application.SendNotification();
1048 application.Render();
1050 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1051 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1053 application.SendNotification();
1054 application.Render();
1056 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1057 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1059 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1060 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1062 application.SendNotification();
1063 application.Render();
1065 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1066 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1068 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1069 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1070 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1075 int UtcDaliToolkitTextLabelColorComponents(void)
1077 ToolkitTestApplication application;
1079 TextLabel label = TextLabel::New();
1080 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1081 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1082 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1083 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1084 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1086 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1087 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1088 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1089 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1090 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1092 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1093 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1094 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1095 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1096 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1098 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1099 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1101 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1106 int UtcDaliToolkitTextlabelTextStyle01(void)
1108 ToolkitTestApplication application;
1109 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1111 TextLabel label = TextLabel::New();
1112 label.SetSize( 300.0f, 300.f );
1113 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1114 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1115 Stage::GetCurrent().Add( label );
1117 Property::Map outlineMapSet;
1118 Property::Map outlineMapGet;
1120 outlineMapSet["color"] = Color::BLUE;
1121 outlineMapSet["width"] = 2.0f;
1122 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1124 application.SendNotification();
1125 application.Render();
1127 Property::Map shadowMapSet;
1128 shadowMapSet.Insert( "color", "green" );
1129 shadowMapSet.Insert( "offset", "2 2" );
1130 shadowMapSet.Insert( "blurRadius", "3" );
1131 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1133 outlineMapSet["color"] = Color::RED;
1134 outlineMapSet["width"] = 0.0f;
1135 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1137 application.SendNotification();
1138 application.Render();
1140 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1142 Property::Value* colorValue = outlineMapGet.Find("color");
1144 bool colorMatched( false );
1148 Property::Type valueType = colorValue->GetType();
1150 if ( Property::STRING == valueType )
1152 std::string stringValue;
1153 colorValue->Get( stringValue );
1154 if ( stringValue == "red" )
1156 colorMatched = true;
1159 else if ( Property::VECTOR4 == valueType )
1161 Vector4 colorVector4;
1162 colorValue->Get( colorVector4 );
1163 if ( colorVector4 == Color::RED )
1165 colorMatched = true;
1170 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1175 int UtcDaliToolkitTextlabelMultiline(void)
1177 ToolkitTestApplication application;
1178 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1180 TextLabel label = TextLabel::New();
1181 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1182 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1183 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1184 Stage::GetCurrent().Add( label );
1186 application.SendNotification();
1187 application.Render();
1189 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1190 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1192 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1194 application.SendNotification();
1195 application.Render();
1197 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1198 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1204 int UtcDaliToolkitTextlabelTextDirection(void)
1206 ToolkitTestApplication application;
1207 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1209 TextLabel label = TextLabel::New();
1210 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1212 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1213 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1214 Stage::GetCurrent().Add( label );
1216 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1218 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1219 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );