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 = fontStyleMapSet.Find( valueGet.first.stringKey );
86 if( NULL != valueSet )
88 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
90 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
96 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
107 int UtcDaliToolkitTextLabelConstructorP(void)
109 ToolkitTestApplication application;
110 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
112 DALI_TEST_CHECK( !textLabel );
116 int UtcDaliToolkitTextLabelNewP(void)
118 ToolkitTestApplication application;
119 tet_infoline(" UtcDaliToolkitTextLabelNewP");
120 TextLabel textLabel = TextLabel::New( "Test Text" );
121 DALI_TEST_CHECK( textLabel );
125 int UtcDaliToolkitTextLabelDownCastP(void)
127 ToolkitTestApplication application;
128 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
129 TextLabel textLabel1 = TextLabel::New();
130 BaseHandle object( textLabel1 );
132 TextLabel textLabel2 = TextLabel::DownCast( object );
133 DALI_TEST_CHECK( textLabel2 );
135 TextLabel textLabel3 = DownCast< TextLabel >( object );
136 DALI_TEST_CHECK( textLabel3 );
140 int UtcDaliToolkitTextLabelDownCastN(void)
142 ToolkitTestApplication application;
143 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
144 BaseHandle uninitializedObject;
145 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
146 DALI_TEST_CHECK( !textLabel1 );
148 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
149 DALI_TEST_CHECK( !textLabel2 );
153 int UtcDaliToolkitTextLabelCopyConstructorP(void)
155 ToolkitTestApplication application;
156 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
157 TextLabel textLabel = TextLabel::New();
158 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
160 TextLabel copy( textLabel );
161 DALI_TEST_CHECK( copy );
162 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
166 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
168 ToolkitTestApplication application;
169 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
170 TextLabel textLabel = TextLabel::New();
171 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
173 TextLabel copy = textLabel;
174 DALI_TEST_CHECK( copy );
175 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
179 // Positive test case for a method
180 int UtcDaliToolkitTextLabelGetPropertyP(void)
182 ToolkitTestApplication application;
183 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
184 TextLabel label = TextLabel::New("Test Text");
185 DALI_TEST_CHECK( label );
187 // Check Property Indices are correct
188 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
189 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
190 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
191 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
192 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
193 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
194 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
195 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
196 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
197 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
198 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
199 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
200 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
201 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
202 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
203 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
204 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
205 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
206 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
207 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
208 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
209 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
210 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
211 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
212 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
213 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
214 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
219 int UtcDaliToolkitTextLabelSetPropertyP(void)
221 ToolkitTestApplication application;
222 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
223 TextLabel label = TextLabel::New();
224 DALI_TEST_CHECK( label );
226 Stage::GetCurrent().Add( label );
228 // Note - we can't check the defaults since the stylesheets are platform-specific
229 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
230 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
232 // Check that text can be correctly reset
233 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
234 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
236 // Check font properties.
237 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
238 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
240 Property::Map fontStyleMapSet;
241 Property::Map fontStyleMapGet;
243 fontStyleMapSet.Insert( "weight", "bold" );
244 fontStyleMapSet.Insert( "width", "condensed" );
245 fontStyleMapSet.Insert( "slant", "italic" );
246 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
248 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
249 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
250 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
252 // Check the old font style format.
253 fontStyleMapSet.Clear();
254 fontStyleMapSet.Insert( "weight", "thin" );
255 fontStyleMapSet.Insert( "width", "expanded" );
256 fontStyleMapSet.Insert( "slant", "oblique" );
257 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
259 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
260 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
261 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
263 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
264 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
267 fontStyleMapSet.Clear();
268 fontStyleMapSet.Insert( "weight", "normal" );
269 fontStyleMapSet.Insert( "slant", "oblique" );
271 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
272 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
273 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
274 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
276 fontStyleMapSet.Clear();
277 fontStyleMapSet.Insert( "slant", "roman" );
279 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
280 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
281 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
283 // Replace 'roman' for 'normal'.
284 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
285 if( NULL != slantValue )
287 if( "normal" == slantValue->Get<std::string>() )
289 fontStyleMapGet["slant"] = "roman";
292 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
294 fontStyleMapSet.Clear();
296 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
297 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
298 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
299 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
302 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
303 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
305 // Check that the Alignment properties can be correctly set
306 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
307 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
308 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
309 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
311 // Check that text color can be properly set
312 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
313 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
314 // The underline color is changed as well.
315 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
317 Property::Map underlineMapSet;
318 Property::Map underlineMapGet;
320 underlineMapSet.Insert( "enable", "false" );
321 underlineMapSet.Insert( "color", "blue" );
322 underlineMapSet.Insert( "height", "0" );
324 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
325 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
326 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
328 // Check that shadow parameters can be correctly set
329 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
330 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
331 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
332 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
334 // Check that underline parameters can be correctly set
335 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
336 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
337 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
338 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
339 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
340 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
342 TextLabel label2 = TextLabel::New( "New text" );
343 DALI_TEST_CHECK( label2 );
344 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
346 // Check the enable markup property.
347 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
348 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
349 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
351 // Check the text property when markup is enabled
352 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
353 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
355 application.SendNotification();
356 application.Render();
358 // Check autoscroll properties
359 const int SCROLL_SPEED = 80;
360 const int SCROLL_LOOPS = 4;
361 const float SCROLL_GAP = 50.0f;
362 const float SCROLL_LOOP_DELAY = 0.3f;
363 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
364 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
366 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
367 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
368 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
369 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
370 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
371 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
372 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
373 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
374 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
375 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
376 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
377 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
379 //Check autoscroll stop type property
380 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
381 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
383 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
384 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
387 // Check the line spacing property
388 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
389 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
390 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
392 // Check the underline property
394 underlineMapSet.Clear();
395 underlineMapSet.Insert( "enable", "true" );
396 underlineMapSet.Insert( "color", "red" );
397 underlineMapSet.Insert( "height", "1" );
399 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
401 application.SendNotification();
402 application.Render();
404 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
405 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
406 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
408 underlineMapSet.Clear();
410 Property::Map underlineDisabledMapGet;
411 underlineDisabledMapGet.Insert( "enable", "false" );
412 underlineDisabledMapGet.Insert( "color", "red" );
413 underlineDisabledMapGet.Insert( "height", "1" );
415 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
416 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
417 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
418 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
420 // Check the shadow property
422 Property::Map shadowMapSet;
423 Property::Map shadowMapGet;
425 shadowMapSet.Insert( "color", Color::GREEN );
426 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
427 shadowMapSet.Insert( "blurRadius", 5.0f );
429 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
431 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
432 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
433 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
435 shadowMapSet.Clear();
436 Property::Map shadowDisabledMapGet;
437 shadowDisabledMapGet.Insert( "color", Color::GREEN );
438 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
439 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
441 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
443 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
444 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
445 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
447 // Check the emboss property
448 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
449 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
451 // Check the outline property
453 // Test string type first
454 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
455 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
456 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
458 // Then test the property map type
459 Property::Map outlineMapSet;
460 Property::Map outlineMapGet;
462 outlineMapSet["color"] = Color::RED;
463 outlineMapSet["width"] = 2.0f;
464 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
466 outlineMapSet["color"] = "red";
467 outlineMapSet["width"] = "2";
468 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
469 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
470 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
472 // Check the pixel size of font
473 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
474 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
476 // Check the ellipsis property
477 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
478 label.SetProperty( TextLabel::Property::ELLIPSIS, true );
479 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
481 // Check the layout direction property
482 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
483 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
485 application.SendNotification();
486 application.Render();
491 int UtcDaliToolkitTextlabelAtlasRenderP(void)
493 ToolkitTestApplication application;
494 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
495 TextLabel label = TextLabel::New("Test Text");
496 DALI_TEST_CHECK( label );
498 // Avoid a crash when core load gl resources.
499 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
501 Stage::GetCurrent().Add( label );
503 // Turn on all the effects
504 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
505 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
506 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
507 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
508 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
509 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
513 // Render some text with the shared atlas backend
514 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
515 application.SendNotification();
516 application.Render();
520 tet_result(TET_FAIL);
525 // Render some text with the shared atlas backend
526 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
527 application.SendNotification();
528 application.Render();
532 tet_result(TET_FAIL);
537 int UtcDaliToolkitTextLabelLanguagesP(void)
539 ToolkitTestApplication application;
540 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
541 TextLabel label = TextLabel::New();
542 DALI_TEST_CHECK( label );
544 Stage::GetCurrent().Add( label );
546 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
547 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
548 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
549 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
550 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
551 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
553 label.SetProperty( TextLabel::Property::TEXT, scripts );
554 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
556 application.SendNotification();
557 application.Render();
562 int UtcDaliToolkitTextLabelEmojisP(void)
564 ToolkitTestApplication application;
565 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
566 TextLabel label = TextLabel::New();
567 DALI_TEST_CHECK( label );
569 Stage::GetCurrent().Add( label );
571 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
573 char* pathNamePtr = get_current_dir_name();
574 const std::string pathName( pathNamePtr );
577 TextAbstraction::FontDescription fontDescription;
578 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
579 fontDescription.family = "BreezeColorEmoji";
580 fontDescription.width = TextAbstraction::FontWidth::NONE;
581 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
582 fontDescription.slant = TextAbstraction::FontSlant::NONE;
584 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
586 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>";
587 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
588 label.SetProperty( TextLabel::Property::TEXT, emojis );
590 Property::Map shadowMap;
591 shadowMap.Insert( "color", "green" );
592 shadowMap.Insert( "offset", "2 2" );
593 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
595 application.SendNotification();
596 application.Render();
601 int UtcDaliToolkitTextlabelScrollingP(void)
603 ToolkitTestApplication application;
604 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
605 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
606 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
608 DALI_TEST_CHECK( labelImmediate );
609 DALI_TEST_CHECK( labelFinished );
610 // Avoid a crash when core load gl resources.
611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
612 Stage::GetCurrent().Add( labelImmediate );
613 // Turn on all the effects
614 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
615 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
616 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
617 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
618 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
620 Stage::GetCurrent().Add( labelFinished );
621 // Turn on all the effects
622 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
623 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
624 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
625 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
626 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
632 // Render some text with the shared atlas backend
633 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
634 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
636 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
637 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
639 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
640 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
641 application.SendNotification();
642 application.Render();
644 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
645 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
646 application.SendNotification();
647 application.Render();
652 tet_result(TET_FAIL);
658 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
660 ToolkitTestApplication application;
661 TextLabel labelShort = TextLabel::New("Some text to scroll");
662 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!");
664 DALI_TEST_CHECK( labelShort );
665 DALI_TEST_CHECK( labelLong );
666 // Avoid a crash when core load gl resources.
667 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
668 Stage::GetCurrent().Add( labelShort );
669 // Turn on all the effects
670 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
671 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
672 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
673 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
674 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
675 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
677 Stage::GetCurrent().Add( labelLong );
678 // Turn on all the effects
679 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
680 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
681 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
682 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
683 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
684 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
688 // Render some text with the shared atlas backend
689 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
690 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
691 application.SendNotification();
692 application.Render();
694 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
695 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
696 application.SendNotification();
697 application.Render();
702 tet_result(TET_FAIL);
708 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
710 ToolkitTestApplication application;
711 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
712 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
714 DALI_TEST_CHECK( labelShort );
715 DALI_TEST_CHECK( labelLong );
716 // Avoid a crash when core load gl resources.
717 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
718 Stage::GetCurrent().Add( labelShort );
719 // Turn on all the effects
720 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
721 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
722 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
723 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
724 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
725 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
727 Stage::GetCurrent().Add( labelLong );
728 // Turn on all the effects
729 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
730 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
731 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
732 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
733 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
734 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
738 // Render some text with the shared atlas backend
739 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
740 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
741 application.SendNotification();
742 application.Render();
744 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
745 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
746 application.SendNotification();
747 application.Render();
752 tet_result(TET_FAIL);
758 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
760 ToolkitTestApplication application;
761 TextLabel labelShort = TextLabel::New("Some text to scroll");
762 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!");
764 DALI_TEST_CHECK( labelShort );
765 DALI_TEST_CHECK( labelLong );
766 // Avoid a crash when core load gl resources.
767 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
768 Stage::GetCurrent().Add( labelShort );
769 // Turn on all the effects
770 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
771 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
772 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
773 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
774 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
775 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
777 Stage::GetCurrent().Add( labelLong );
778 // Turn on all the effects
779 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
780 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
781 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
782 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
783 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
784 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
788 // Render some text with the shared atlas backend
789 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
790 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
791 application.SendNotification();
792 application.Render();
794 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
795 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
796 application.SendNotification();
797 application.Render();
802 tet_result(TET_FAIL);
808 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
810 ToolkitTestApplication application;
811 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
812 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
814 DALI_TEST_CHECK( labelShort );
815 DALI_TEST_CHECK( labelLong );
816 // Avoid a crash when core load gl resources.
817 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
818 Stage::GetCurrent().Add( labelShort );
819 // Turn on all the effects
820 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
821 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
822 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
823 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
824 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
825 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
827 Stage::GetCurrent().Add( labelLong );
828 // Turn on all the effects
829 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
830 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
831 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
832 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
833 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
834 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
838 // Render some text with the shared atlas backend
839 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
840 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
841 application.SendNotification();
842 application.Render();
844 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
845 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
846 application.SendNotification();
847 application.Render();
852 tet_result(TET_FAIL);
858 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
860 ToolkitTestApplication application;
861 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
862 TextLabel label = TextLabel::New("Some text to scroll");
863 DALI_TEST_CHECK( label );
864 // Avoid a crash when core load gl resources.
865 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
866 Stage::GetCurrent().Add( label );
867 label.SetSize( 360.0f, 20.f );
868 // Turn on all the effects
869 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
870 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
871 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
872 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
875 application.SendNotification();
876 application.Render();
878 unsigned int actorCount1 = label.GetChildCount();
879 tet_printf("Initial actor count is(%d)\n", actorCount1 );
883 // Render some text with the shared atlas backend
884 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
885 application.SendNotification();
886 application.Render(2000);
888 unsigned int actorCount1 = label.GetChildCount();
889 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
891 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
894 application.SendNotification();
895 application.Render();
897 unsigned int actorCount2 = label.GetChildCount();
898 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
900 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
905 tet_result(TET_FAIL);
911 int UtcDaliToolkitTextlabelScrollingN(void)
913 ToolkitTestApplication application;
914 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
916 TextLabel label = TextLabel::New("Some text to scroll");
917 DALI_TEST_CHECK( label );
919 Stage::GetCurrent().Add( label );
921 // Avoid a crash when core load gl resources.
922 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
924 // The text scrolling works only on single line text.
925 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
927 // Turn on all the effects.
928 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
929 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
930 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
932 // Enable the auto scrolling effect.
933 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
935 // The auto scrolling shouldn't be enabled.
936 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
937 DALI_TEST_CHECK( !enabled );
942 int UtcDaliToolkitTextlabelEllipsis(void)
944 ToolkitTestApplication application;
945 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
947 TextLabel label = TextLabel::New("Hello world");
948 DALI_TEST_CHECK( label );
950 // Avoid a crash when core load gl resources.
951 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
953 Stage::GetCurrent().Add( label );
955 // Turn on all the effects
956 label.SetAnchorPoint( AnchorPoint::CENTER );
957 label.SetParentOrigin( ParentOrigin::CENTER );
958 label.SetSize( 360.0f, 10.f );
963 application.SendNotification();
964 application.Render();
968 tet_result(TET_FAIL);
974 int UtcDaliToolkitTextlabelTextWrapMode(void)
976 ToolkitTestApplication application;
977 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
981 TextLabel label = TextLabel::New();
982 label.SetSize( 300.0f, 300.f );
983 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
984 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
988 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
989 Stage::GetCurrent().Add( label );
991 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
992 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
994 application.SendNotification();
995 application.Render();
997 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
998 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1000 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1001 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1003 application.SendNotification();
1004 application.Render();
1006 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1007 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1009 application.SendNotification();
1010 application.Render();
1012 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1013 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1015 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1016 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1018 application.SendNotification();
1019 application.Render();
1021 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1022 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1024 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1025 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1026 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1031 int UtcDaliToolkitTextLabelColorComponents(void)
1033 ToolkitTestApplication application;
1035 TextLabel label = TextLabel::New();
1036 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1037 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1038 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1039 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1040 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1042 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1043 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1044 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1045 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1046 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1048 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1049 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1050 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1051 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1052 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1054 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1055 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1056 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1057 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1062 int UtcDaliToolkitTextlabelTextStyle01(void)
1064 ToolkitTestApplication application;
1065 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1067 TextLabel label = TextLabel::New();
1068 label.SetSize( 300.0f, 300.f );
1069 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1070 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1071 Stage::GetCurrent().Add( label );
1073 Property::Map outlineMapSet;
1074 Property::Map outlineMapGet;
1076 outlineMapSet["color"] = Color::BLUE;
1077 outlineMapSet["width"] = 2.0f;
1078 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1080 application.SendNotification();
1081 application.Render();
1083 Property::Map shadowMapSet;
1084 shadowMapSet.Insert( "color", "green" );
1085 shadowMapSet.Insert( "offset", "2 2" );
1086 shadowMapSet.Insert( "blurRadius", "3" );
1087 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1089 outlineMapSet["color"] = Color::RED;
1090 outlineMapSet["width"] = 0.0f;
1091 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1093 application.SendNotification();
1094 application.Render();
1096 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1098 Property::Value* colorValue = outlineMapGet.Find("color");
1100 bool colorMatched( false );
1104 Property::Type valueType = colorValue->GetType();
1106 if ( Property::STRING == valueType )
1108 std::string stringValue;
1109 colorValue->Get( stringValue );
1110 if ( stringValue == "red" )
1112 colorMatched = true;
1115 else if ( Property::VECTOR4 == valueType )
1117 Vector4 colorVector4;
1118 colorValue->Get( colorVector4 );
1119 if ( colorVector4 == Color::RED )
1121 colorMatched = true;
1126 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1131 int UtcDaliToolkitTextlabelMultiline(void)
1133 ToolkitTestApplication application;
1134 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1136 TextLabel label = TextLabel::New();
1137 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1138 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1139 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1140 Stage::GetCurrent().Add( label );
1142 application.SendNotification();
1143 application.Render();
1145 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1146 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1148 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1150 application.SendNotification();
1151 application.Render();
1153 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1154 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1160 int UtcDaliToolkitTextlabelTextDirection(void)
1162 ToolkitTestApplication application;
1163 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1165 TextLabel label = TextLabel::New();
1166 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1168 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1169 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1170 Stage::GetCurrent().Add( label );
1172 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1174 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1175 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );