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>
27 using namespace Toolkit;
29 void dali_textlabel_startup(void)
31 test_return_value = TET_UNDEF;
34 void dali_textlabel_cleanup(void)
36 test_return_value = TET_PASS;
42 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
43 const char* const PROPERTY_NAME_TEXT = "text";
44 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
45 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
46 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
47 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
48 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
49 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
52 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
53 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
54 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
55 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
56 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
62 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
63 const char* const PROPERTY_NAME_UNDERLINE = "underline";
64 const char* const PROPERTY_NAME_SHADOW = "shadow";
65 const char* const PROPERTY_NAME_EMBOSS = "emboss";
66 const char* const PROPERTY_NAME_OUTLINE = "outline";
68 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
69 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
70 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
72 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
73 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
74 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
76 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
78 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
80 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
82 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
84 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
85 if( NULL != valueSet )
87 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
89 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
95 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
106 int UtcDaliToolkitTextLabelConstructorP(void)
108 ToolkitTestApplication application;
109 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
111 DALI_TEST_CHECK( !textLabel );
115 int UtcDaliToolkitTextLabelNewP(void)
117 ToolkitTestApplication application;
118 tet_infoline(" UtcDaliToolkitTextLabelNewP");
119 TextLabel textLabel = TextLabel::New( "Test Text" );
120 DALI_TEST_CHECK( textLabel );
124 int UtcDaliToolkitTextLabelDownCastP(void)
126 ToolkitTestApplication application;
127 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
128 TextLabel textLabel1 = TextLabel::New();
129 BaseHandle object( textLabel1 );
131 TextLabel textLabel2 = TextLabel::DownCast( object );
132 DALI_TEST_CHECK( textLabel2 );
134 TextLabel textLabel3 = DownCast< TextLabel >( object );
135 DALI_TEST_CHECK( textLabel3 );
139 int UtcDaliToolkitTextLabelDownCastN(void)
141 ToolkitTestApplication application;
142 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
143 BaseHandle uninitializedObject;
144 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
145 DALI_TEST_CHECK( !textLabel1 );
147 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
148 DALI_TEST_CHECK( !textLabel2 );
152 int UtcDaliToolkitTextLabelCopyConstructorP(void)
154 ToolkitTestApplication application;
155 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
156 TextLabel textLabel = TextLabel::New();
157 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
159 TextLabel copy( textLabel );
160 DALI_TEST_CHECK( copy );
161 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
165 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
167 ToolkitTestApplication application;
168 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
169 TextLabel textLabel = TextLabel::New();
170 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
172 TextLabel copy = textLabel;
173 DALI_TEST_CHECK( copy );
174 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
178 // Positive test case for a method
179 int UtcDaliToolkitTextLabelGetPropertyP(void)
181 ToolkitTestApplication application;
182 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
183 TextLabel label = TextLabel::New("Test Text");
184 DALI_TEST_CHECK( label );
186 // Check Property Indices are correct
187 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
188 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
189 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
190 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
191 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
192 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
193 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
194 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
195 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
196 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
197 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
198 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
199 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
200 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
201 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
202 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
203 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
204 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
205 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
206 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
207 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
208 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
209 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
210 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
211 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextLabel::Property::PIXEL_SIZE );
212 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextLabel::Property::ELLIPSIS );
213 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
218 int UtcDaliToolkitTextLabelSetPropertyP(void)
220 ToolkitTestApplication application;
221 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
222 TextLabel label = TextLabel::New();
223 DALI_TEST_CHECK( label );
225 Stage::GetCurrent().Add( label );
227 // Note - we can't check the defaults since the stylesheets are platform-specific
228 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
229 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
231 // Check that text can be correctly reset
232 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
233 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
235 // Check font properties.
236 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
237 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
239 Property::Map fontStyleMapSet;
240 Property::Map fontStyleMapGet;
242 fontStyleMapSet.Insert( "weight", "bold" );
243 fontStyleMapSet.Insert( "width", "condensed" );
244 fontStyleMapSet.Insert( "slant", "italic" );
245 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
247 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
248 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
249 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
251 // Check the old font style format.
252 fontStyleMapSet.Clear();
253 fontStyleMapSet.Insert( "weight", "thin" );
254 fontStyleMapSet.Insert( "width", "expanded" );
255 fontStyleMapSet.Insert( "slant", "oblique" );
256 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
258 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
259 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
260 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
262 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
263 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
266 fontStyleMapSet.Clear();
267 fontStyleMapSet.Insert( "weight", "normal" );
268 fontStyleMapSet.Insert( "slant", "oblique" );
270 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
271 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
272 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
273 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
275 fontStyleMapSet.Clear();
276 fontStyleMapSet.Insert( "slant", "roman" );
278 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
279 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
280 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
282 // Replace 'roman' for 'normal'.
283 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
284 if( NULL != slantValue )
286 if( "normal" == slantValue->Get<std::string>() )
288 fontStyleMapGet["slant"] = "roman";
291 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
293 fontStyleMapSet.Clear();
295 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
296 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
297 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
298 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
301 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
302 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
304 // Check that the Alignment properties can be correctly set
305 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
306 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
307 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
308 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
310 // Check that text color can be properly set
311 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
312 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
313 // The underline color is changed as well.
314 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
316 Property::Map underlineMapSet;
317 Property::Map underlineMapGet;
319 underlineMapSet.Insert( "enable", "false" );
320 underlineMapSet.Insert( "color", "blue" );
321 underlineMapSet.Insert( "height", "0" );
323 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
324 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
325 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
327 // Check that shadow parameters can be correctly set
328 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
329 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
330 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
331 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
333 // Check that underline parameters can be correctly set
334 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
335 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
336 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
337 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
338 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
339 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
341 TextLabel label2 = TextLabel::New( "New text" );
342 DALI_TEST_CHECK( label2 );
343 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
345 // Check the enable markup property.
346 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
347 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
348 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
350 // Check the text property when markup is enabled
351 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
352 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
354 application.SendNotification();
355 application.Render();
357 // Check autoscroll properties
358 const int SCROLL_SPEED = 80;
359 const int SCROLL_LOOPS = 4;
360 const float SCROLL_GAP = 50.0f;
361 const float SCROLL_LOOP_DELAY = 0.3f;
362 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
363 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
365 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
366 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
367 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
368 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
369 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
370 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
371 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
372 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
373 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
374 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
375 label.SetProperty(DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
376 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
378 //Check autoscroll stop type property
379 label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
380 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
382 label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
383 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
386 // Check the line spacing property
387 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
388 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
389 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
391 // Check the underline property
393 underlineMapSet.Clear();
394 underlineMapSet.Insert( "enable", "true" );
395 underlineMapSet.Insert( "color", "red" );
396 underlineMapSet.Insert( "height", "1" );
398 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
400 application.SendNotification();
401 application.Render();
403 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
404 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
405 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
407 underlineMapSet.Clear();
409 Property::Map underlineDisabledMapGet;
410 underlineDisabledMapGet.Insert( "enable", "false" );
411 underlineDisabledMapGet.Insert( "color", "red" );
412 underlineDisabledMapGet.Insert( "height", "1" );
414 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
415 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
416 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
417 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
419 // Check the shadow property
421 Property::Map shadowMapSet;
422 Property::Map shadowMapGet;
424 shadowMapSet.Insert( "color", "green" );
425 shadowMapSet.Insert( "offset", "2 2" );
427 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
429 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
430 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
431 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
433 shadowMapSet.Clear();
434 Property::Map shadowDisabledMapGet;
435 shadowDisabledMapGet.Insert( "color", "green" );
436 shadowDisabledMapGet.Insert( "offset", "0 0" );
438 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
440 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
441 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
442 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
444 // Check the emboss property
445 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
446 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
448 // Check the outline property
449 Property::Map outlineMapSet;
450 Property::Map outlineMapGet;
452 outlineMapSet["color"] = Color::RED;
453 outlineMapSet["width"] = 2.0f;
454 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
456 outlineMapSet["color"] = "red";
457 outlineMapSet["width"] = "2";
458 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
459 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
460 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
462 // Check the pixel size of font
463 label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
464 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
466 // Check the ellipsis property
467 DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
468 label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
469 DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
474 int UtcDaliToolkitTextlabelAtlasRenderP(void)
476 ToolkitTestApplication application;
477 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
478 TextLabel label = TextLabel::New("Test Text");
479 DALI_TEST_CHECK( label );
481 // Avoid a crash when core load gl resources.
482 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
484 Stage::GetCurrent().Add( label );
486 // Turn on all the effects
487 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
488 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
489 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
490 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
491 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
492 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
496 // Render some text with the shared atlas backend
497 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
498 application.SendNotification();
499 application.Render();
503 tet_result(TET_FAIL);
508 // Render some text with the shared atlas backend
509 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
510 application.SendNotification();
511 application.Render();
515 tet_result(TET_FAIL);
520 int UtcDaliToolkitTextLabelLanguagesP(void)
522 ToolkitTestApplication application;
523 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
524 TextLabel label = TextLabel::New();
525 DALI_TEST_CHECK( label );
527 Stage::GetCurrent().Add( label );
529 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
530 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
531 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
532 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
533 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
534 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
536 label.SetProperty( TextLabel::Property::TEXT, scripts );
537 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
539 application.SendNotification();
540 application.Render();
545 int UtcDaliToolkitTextLabelEmojisP(void)
547 ToolkitTestApplication application;
548 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
549 TextLabel label = TextLabel::New();
550 DALI_TEST_CHECK( label );
552 Stage::GetCurrent().Add( label );
554 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
556 char* pathNamePtr = get_current_dir_name();
557 const std::string pathName( pathNamePtr );
560 TextAbstraction::FontDescription fontDescription;
561 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
562 fontDescription.family = "BreezeColorEmoji";
563 fontDescription.width = TextAbstraction::FontWidth::NONE;
564 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
565 fontDescription.slant = TextAbstraction::FontSlant::NONE;
567 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
569 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>";
570 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
571 label.SetProperty( TextLabel::Property::TEXT, emojis );
573 Property::Map shadowMap;
574 shadowMap.Insert( "color", "green" );
575 shadowMap.Insert( "offset", "2 2" );
576 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
578 application.SendNotification();
579 application.Render();
584 int UtcDaliToolkitTextlabelScrollingP(void)
586 ToolkitTestApplication application;
587 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
588 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
589 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
591 DALI_TEST_CHECK( labelImmediate );
592 DALI_TEST_CHECK( labelFinished );
593 // Avoid a crash when core load gl resources.
594 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
595 Stage::GetCurrent().Add( labelImmediate );
596 // Turn on all the effects
597 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
598 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
599 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
600 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
601 labelImmediate.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
603 Stage::GetCurrent().Add( labelFinished );
604 // Turn on all the effects
605 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
606 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
607 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
608 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
609 labelFinished.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
615 // Render some text with the shared atlas backend
616 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
617 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
618 application.SendNotification();
619 application.Render();
621 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
622 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
623 application.SendNotification();
624 application.Render();
629 tet_result(TET_FAIL);
635 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
637 ToolkitTestApplication application;
638 TextLabel labelShort = TextLabel::New("Some text to scroll");
639 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!");
641 DALI_TEST_CHECK( labelShort );
642 DALI_TEST_CHECK( labelLong );
643 // Avoid a crash when core load gl resources.
644 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
645 Stage::GetCurrent().Add( labelShort );
646 // Turn on all the effects
647 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
648 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
649 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
650 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
651 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
652 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
654 Stage::GetCurrent().Add( labelLong );
655 // Turn on all the effects
656 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
657 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
658 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
659 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
660 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
661 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
665 // Render some text with the shared atlas backend
666 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
667 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
668 application.SendNotification();
669 application.Render();
671 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
672 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
673 application.SendNotification();
674 application.Render();
679 tet_result(TET_FAIL);
685 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
687 ToolkitTestApplication application;
688 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
689 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
691 DALI_TEST_CHECK( labelShort );
692 DALI_TEST_CHECK( labelLong );
693 // Avoid a crash when core load gl resources.
694 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
695 Stage::GetCurrent().Add( labelShort );
696 // Turn on all the effects
697 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
698 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
699 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
700 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
701 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
702 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
704 Stage::GetCurrent().Add( labelLong );
705 // Turn on all the effects
706 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
707 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
708 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
709 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
710 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
711 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
715 // Render some text with the shared atlas backend
716 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
717 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
718 application.SendNotification();
719 application.Render();
721 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
722 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
723 application.SendNotification();
724 application.Render();
729 tet_result(TET_FAIL);
735 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
737 ToolkitTestApplication application;
738 TextLabel labelShort = TextLabel::New("Some text to scroll");
739 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!");
741 DALI_TEST_CHECK( labelShort );
742 DALI_TEST_CHECK( labelLong );
743 // Avoid a crash when core load gl resources.
744 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
745 Stage::GetCurrent().Add( labelShort );
746 // Turn on all the effects
747 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
748 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
749 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
750 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
751 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
752 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
754 Stage::GetCurrent().Add( labelLong );
755 // Turn on all the effects
756 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
757 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
758 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
759 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
760 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
761 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
765 // Render some text with the shared atlas backend
766 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
767 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
768 application.SendNotification();
769 application.Render();
771 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
772 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
773 application.SendNotification();
774 application.Render();
779 tet_result(TET_FAIL);
785 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
787 ToolkitTestApplication application;
788 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
789 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
791 DALI_TEST_CHECK( labelShort );
792 DALI_TEST_CHECK( labelLong );
793 // Avoid a crash when core load gl resources.
794 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
795 Stage::GetCurrent().Add( labelShort );
796 // Turn on all the effects
797 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
798 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
799 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
800 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
801 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
802 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
804 Stage::GetCurrent().Add( labelLong );
805 // Turn on all the effects
806 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
807 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
808 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
809 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
810 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
811 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
815 // Render some text with the shared atlas backend
816 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
817 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
818 application.SendNotification();
819 application.Render();
821 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
822 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
823 application.SendNotification();
824 application.Render();
829 tet_result(TET_FAIL);
835 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
837 ToolkitTestApplication application;
838 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
839 TextLabel label = TextLabel::New("Some text to scroll");
840 DALI_TEST_CHECK( label );
841 // Avoid a crash when core load gl resources.
842 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
843 Stage::GetCurrent().Add( label );
844 label.SetSize( 360.0f, 20.f );
845 // Turn on all the effects
846 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
847 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
848 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
849 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
852 application.SendNotification();
853 application.Render();
855 unsigned int actorCount1 = label.GetChildCount();
856 tet_printf("Initial actor count is(%d)\n", actorCount1 );
860 // Render some text with the shared atlas backend
861 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
862 application.SendNotification();
863 application.Render(2000);
865 unsigned int actorCount1 = label.GetChildCount();
866 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
868 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
871 application.SendNotification();
872 application.Render();
874 unsigned int actorCount2 = label.GetChildCount();
875 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
877 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
882 tet_result(TET_FAIL);
888 int UtcDaliToolkitTextlabelScrollingN(void)
890 ToolkitTestApplication application;
891 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
893 TextLabel label = TextLabel::New("Some text to scroll");
894 DALI_TEST_CHECK( label );
896 Stage::GetCurrent().Add( label );
898 // Avoid a crash when core load gl resources.
899 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
901 // The text scrolling works only on single line text.
902 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
904 // Turn on all the effects.
905 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
906 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
907 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
909 // Enable the auto scrolling effect.
910 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
912 // The auto scrolling shouldn't be enabled.
913 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
914 DALI_TEST_CHECK( !enabled );
919 int UtcDaliToolkitTextlabelEllipsis(void)
921 ToolkitTestApplication application;
922 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
924 TextLabel label = TextLabel::New("Hello world");
925 DALI_TEST_CHECK( label );
927 // Avoid a crash when core load gl resources.
928 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
930 Stage::GetCurrent().Add( label );
932 // Turn on all the effects
933 label.SetAnchorPoint( AnchorPoint::CENTER );
934 label.SetParentOrigin( ParentOrigin::CENTER );
935 label.SetSize( 360.0f, 10.f );
940 application.SendNotification();
941 application.Render();
945 tet_result(TET_FAIL);
951 int UtcDaliToolkitTextlabelTextWarpMode(void)
953 ToolkitTestApplication application;
954 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
958 TextLabel label = TextLabel::New();
959 label.SetSize( 300.0f, 300.f );
960 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
961 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
965 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
966 Stage::GetCurrent().Add( label );
968 label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_WORD" );
970 application.SendNotification();
971 application.Render();
973 lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
974 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
978 label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_CHARACTER" );
980 application.SendNotification();
981 application.Render();
984 lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
985 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
990 int UtcDaliToolkitTextLabelColorComponents(void)
992 ToolkitTestApplication application;
994 TextLabel label = TextLabel::New();
995 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::RED );
996 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
997 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
998 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
999 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1001 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN );
1002 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1003 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1005 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1007 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
1008 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1009 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1010 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1011 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1013 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1014 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1015 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1016 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1021 int UtcDaliToolkitTextlabelTextStyle01(void)
1023 ToolkitTestApplication application;
1024 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1026 TextLabel label = TextLabel::New();
1027 label.SetSize( 300.0f, 300.f );
1028 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1029 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1030 Stage::GetCurrent().Add( label );
1032 Property::Map outlineMapSet;
1033 Property::Map outlineMapGet;
1035 outlineMapSet["color"] = Color::BLUE;
1036 outlineMapSet["width"] = 2.0f;
1037 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1039 application.SendNotification();
1040 application.Render();
1042 Property::Map shadowMapSet;
1043 shadowMapSet.Insert( "color", "green" );
1044 shadowMapSet.Insert( "offset", "2 2" );
1045 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1047 outlineMapSet["color"] = Color::RED;
1048 outlineMapSet["width"] = 0.0f;
1049 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1051 application.SendNotification();
1052 application.Render();
1054 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1056 Property::Value* colorValue = outlineMapGet.Find("color");
1058 bool colorMatched( false );
1062 Property::Type valueType = colorValue->GetType();
1064 if ( Property::STRING == valueType )
1066 std::string stringValue;
1067 colorValue->Get( stringValue );
1068 if ( stringValue == "red" )
1070 colorMatched = true;
1073 else if ( Property::VECTOR4 == valueType )
1075 Vector4 colorVector4;
1076 colorValue->Get( colorVector4 );
1077 if ( colorVector4 == Color::RED )
1079 colorMatched = true;
1084 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );