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
450 // Test string type first
451 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
452 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
453 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
455 // Then test the property map type
456 Property::Map outlineMapSet;
457 Property::Map outlineMapGet;
459 outlineMapSet["color"] = Color::RED;
460 outlineMapSet["width"] = 2.0f;
461 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
463 outlineMapSet["color"] = "red";
464 outlineMapSet["width"] = "2";
465 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
466 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
467 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
469 // Check the pixel size of font
470 label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
471 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
473 // Check the ellipsis property
474 DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
475 label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
476 DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
481 int UtcDaliToolkitTextlabelAtlasRenderP(void)
483 ToolkitTestApplication application;
484 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
485 TextLabel label = TextLabel::New("Test Text");
486 DALI_TEST_CHECK( label );
488 // Avoid a crash when core load gl resources.
489 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
491 Stage::GetCurrent().Add( label );
493 // Turn on all the effects
494 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
495 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
496 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
497 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
498 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
499 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
503 // Render some text with the shared atlas backend
504 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
505 application.SendNotification();
506 application.Render();
510 tet_result(TET_FAIL);
515 // Render some text with the shared atlas backend
516 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
517 application.SendNotification();
518 application.Render();
522 tet_result(TET_FAIL);
527 int UtcDaliToolkitTextLabelLanguagesP(void)
529 ToolkitTestApplication application;
530 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
531 TextLabel label = TextLabel::New();
532 DALI_TEST_CHECK( label );
534 Stage::GetCurrent().Add( label );
536 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
537 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
538 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
539 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
540 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
541 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
543 label.SetProperty( TextLabel::Property::TEXT, scripts );
544 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
546 application.SendNotification();
547 application.Render();
552 int UtcDaliToolkitTextLabelEmojisP(void)
554 ToolkitTestApplication application;
555 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
556 TextLabel label = TextLabel::New();
557 DALI_TEST_CHECK( label );
559 Stage::GetCurrent().Add( label );
561 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
563 char* pathNamePtr = get_current_dir_name();
564 const std::string pathName( pathNamePtr );
567 TextAbstraction::FontDescription fontDescription;
568 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
569 fontDescription.family = "BreezeColorEmoji";
570 fontDescription.width = TextAbstraction::FontWidth::NONE;
571 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
572 fontDescription.slant = TextAbstraction::FontSlant::NONE;
574 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
576 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>";
577 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
578 label.SetProperty( TextLabel::Property::TEXT, emojis );
580 Property::Map shadowMap;
581 shadowMap.Insert( "color", "green" );
582 shadowMap.Insert( "offset", "2 2" );
583 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
585 application.SendNotification();
586 application.Render();
591 int UtcDaliToolkitTextlabelScrollingP(void)
593 ToolkitTestApplication application;
594 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
595 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
596 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
598 DALI_TEST_CHECK( labelImmediate );
599 DALI_TEST_CHECK( labelFinished );
600 // Avoid a crash when core load gl resources.
601 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
602 Stage::GetCurrent().Add( labelImmediate );
603 // Turn on all the effects
604 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
605 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
606 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
607 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
608 labelImmediate.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
610 Stage::GetCurrent().Add( labelFinished );
611 // Turn on all the effects
612 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
613 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
614 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
615 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
616 labelFinished.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
622 // Render some text with the shared atlas backend
623 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
624 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
625 application.SendNotification();
626 application.Render();
628 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
629 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
630 application.SendNotification();
631 application.Render();
636 tet_result(TET_FAIL);
642 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
644 ToolkitTestApplication application;
645 TextLabel labelShort = TextLabel::New("Some text to scroll");
646 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!");
648 DALI_TEST_CHECK( labelShort );
649 DALI_TEST_CHECK( labelLong );
650 // Avoid a crash when core load gl resources.
651 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
652 Stage::GetCurrent().Add( labelShort );
653 // Turn on all the effects
654 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
655 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
656 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
657 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
658 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
659 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
661 Stage::GetCurrent().Add( labelLong );
662 // Turn on all the effects
663 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
664 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
665 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
666 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
667 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
668 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
672 // Render some text with the shared atlas backend
673 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
674 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
675 application.SendNotification();
676 application.Render();
678 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
679 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
680 application.SendNotification();
681 application.Render();
686 tet_result(TET_FAIL);
692 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
694 ToolkitTestApplication application;
695 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
696 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
698 DALI_TEST_CHECK( labelShort );
699 DALI_TEST_CHECK( labelLong );
700 // Avoid a crash when core load gl resources.
701 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
702 Stage::GetCurrent().Add( labelShort );
703 // Turn on all the effects
704 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
705 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
706 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
707 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
708 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
709 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
711 Stage::GetCurrent().Add( labelLong );
712 // Turn on all the effects
713 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
714 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
715 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
716 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
717 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
718 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
722 // Render some text with the shared atlas backend
723 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
724 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
725 application.SendNotification();
726 application.Render();
728 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
729 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
730 application.SendNotification();
731 application.Render();
736 tet_result(TET_FAIL);
742 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
744 ToolkitTestApplication application;
745 TextLabel labelShort = TextLabel::New("Some text to scroll");
746 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!");
748 DALI_TEST_CHECK( labelShort );
749 DALI_TEST_CHECK( labelLong );
750 // Avoid a crash when core load gl resources.
751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
752 Stage::GetCurrent().Add( labelShort );
753 // Turn on all the effects
754 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
755 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
756 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
757 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
758 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
759 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
761 Stage::GetCurrent().Add( labelLong );
762 // Turn on all the effects
763 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
764 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
765 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
766 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
767 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
768 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
772 // Render some text with the shared atlas backend
773 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
774 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
775 application.SendNotification();
776 application.Render();
778 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
779 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
780 application.SendNotification();
781 application.Render();
786 tet_result(TET_FAIL);
792 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
794 ToolkitTestApplication application;
795 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
796 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
798 DALI_TEST_CHECK( labelShort );
799 DALI_TEST_CHECK( labelLong );
800 // Avoid a crash when core load gl resources.
801 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
802 Stage::GetCurrent().Add( labelShort );
803 // Turn on all the effects
804 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
805 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
806 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
807 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
808 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
809 labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
811 Stage::GetCurrent().Add( labelLong );
812 // Turn on all the effects
813 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
814 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
815 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
816 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
817 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
818 labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
822 // Render some text with the shared atlas backend
823 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
824 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
825 application.SendNotification();
826 application.Render();
828 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
829 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
830 application.SendNotification();
831 application.Render();
836 tet_result(TET_FAIL);
842 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
844 ToolkitTestApplication application;
845 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
846 TextLabel label = TextLabel::New("Some text to scroll");
847 DALI_TEST_CHECK( label );
848 // Avoid a crash when core load gl resources.
849 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
850 Stage::GetCurrent().Add( label );
851 label.SetSize( 360.0f, 20.f );
852 // Turn on all the effects
853 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
854 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
855 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
856 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
859 application.SendNotification();
860 application.Render();
862 unsigned int actorCount1 = label.GetChildCount();
863 tet_printf("Initial actor count is(%d)\n", actorCount1 );
867 // Render some text with the shared atlas backend
868 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
869 application.SendNotification();
870 application.Render(2000);
872 unsigned int actorCount1 = label.GetChildCount();
873 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
875 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
878 application.SendNotification();
879 application.Render();
881 unsigned int actorCount2 = label.GetChildCount();
882 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
884 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
889 tet_result(TET_FAIL);
895 int UtcDaliToolkitTextlabelScrollingN(void)
897 ToolkitTestApplication application;
898 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
900 TextLabel label = TextLabel::New("Some text to scroll");
901 DALI_TEST_CHECK( label );
903 Stage::GetCurrent().Add( label );
905 // Avoid a crash when core load gl resources.
906 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
908 // The text scrolling works only on single line text.
909 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
911 // Turn on all the effects.
912 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
913 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
914 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
916 // Enable the auto scrolling effect.
917 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
919 // The auto scrolling shouldn't be enabled.
920 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
921 DALI_TEST_CHECK( !enabled );
926 int UtcDaliToolkitTextlabelEllipsis(void)
928 ToolkitTestApplication application;
929 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
931 TextLabel label = TextLabel::New("Hello world");
932 DALI_TEST_CHECK( label );
934 // Avoid a crash when core load gl resources.
935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
937 Stage::GetCurrent().Add( label );
939 // Turn on all the effects
940 label.SetAnchorPoint( AnchorPoint::CENTER );
941 label.SetParentOrigin( ParentOrigin::CENTER );
942 label.SetSize( 360.0f, 10.f );
947 application.SendNotification();
948 application.Render();
952 tet_result(TET_FAIL);
958 int UtcDaliToolkitTextlabelTextWarpMode(void)
960 ToolkitTestApplication application;
961 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
965 TextLabel label = TextLabel::New();
966 label.SetSize( 300.0f, 300.f );
967 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
968 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
972 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
973 Stage::GetCurrent().Add( label );
975 label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_WORD" );
977 application.SendNotification();
978 application.Render();
980 lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
981 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
985 label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_CHARACTER" );
987 application.SendNotification();
988 application.Render();
991 lineCount = label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
992 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
997 int UtcDaliToolkitTextLabelColorComponents(void)
999 ToolkitTestApplication application;
1001 TextLabel label = TextLabel::New();
1002 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::RED );
1003 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1005 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1006 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1008 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN );
1009 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1010 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1011 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1012 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1014 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
1015 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1016 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1017 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1018 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1020 label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1021 DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1022 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1023 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1028 int UtcDaliToolkitTextlabelTextStyle01(void)
1030 ToolkitTestApplication application;
1031 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1033 TextLabel label = TextLabel::New();
1034 label.SetSize( 300.0f, 300.f );
1035 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1036 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1037 Stage::GetCurrent().Add( label );
1039 Property::Map outlineMapSet;
1040 Property::Map outlineMapGet;
1042 outlineMapSet["color"] = Color::BLUE;
1043 outlineMapSet["width"] = 2.0f;
1044 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1046 application.SendNotification();
1047 application.Render();
1049 Property::Map shadowMapSet;
1050 shadowMapSet.Insert( "color", "green" );
1051 shadowMapSet.Insert( "offset", "2 2" );
1052 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1054 outlineMapSet["color"] = Color::RED;
1055 outlineMapSet["width"] = 0.0f;
1056 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1058 application.SendNotification();
1059 application.Render();
1061 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1063 Property::Value* colorValue = outlineMapGet.Find("color");
1065 bool colorMatched( false );
1069 Property::Type valueType = colorValue->GetType();
1071 if ( Property::STRING == valueType )
1073 std::string stringValue;
1074 colorValue->Get( stringValue );
1075 if ( stringValue == "red" )
1077 colorMatched = true;
1080 else if ( Property::VECTOR4 == valueType )
1082 Vector4 colorVector4;
1083 colorValue->Get( colorVector4 );
1084 if ( colorVector4 == Color::RED )
1086 colorMatched = true;
1091 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );