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>
26 using namespace Toolkit;
28 void dali_textlabel_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_textlabel_cleanup(void)
35 test_return_value = TET_PASS;
41 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
42 const char* const PROPERTY_NAME_TEXT = "text";
43 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
44 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
45 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
46 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
47 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
48 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
49 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
50 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
51 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
52 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
53 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
54 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
55 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
61 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
62 const char* const PROPERTY_NAME_UNDERLINE = "underline";
63 const char* const PROPERTY_NAME_SHADOW = "shadow";
64 const char* const PROPERTY_NAME_EMBOSS = "emboss";
65 const char* const PROPERTY_NAME_OUTLINE = "outline";
67 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
68 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
69 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
71 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
72 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
73 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
75 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
77 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
79 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
81 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
83 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
84 if( NULL != valueSet )
86 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
88 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
94 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
105 int UtcDaliToolkitTextLabelConstructorP(void)
107 ToolkitTestApplication application;
108 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
110 DALI_TEST_CHECK( !textLabel );
114 int UtcDaliToolkitTextLabelNewP(void)
116 ToolkitTestApplication application;
117 tet_infoline(" UtcDaliToolkitTextLabelNewP");
118 TextLabel textLabel = TextLabel::New( "Test Text" );
119 DALI_TEST_CHECK( textLabel );
123 int UtcDaliToolkitTextLabelDownCastP(void)
125 ToolkitTestApplication application;
126 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
127 TextLabel textLabel1 = TextLabel::New();
128 BaseHandle object( textLabel1 );
130 TextLabel textLabel2 = TextLabel::DownCast( object );
131 DALI_TEST_CHECK( textLabel2 );
133 TextLabel textLabel3 = DownCast< TextLabel >( object );
134 DALI_TEST_CHECK( textLabel3 );
138 int UtcDaliToolkitTextLabelDownCastN(void)
140 ToolkitTestApplication application;
141 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
142 BaseHandle uninitializedObject;
143 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
144 DALI_TEST_CHECK( !textLabel1 );
146 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
147 DALI_TEST_CHECK( !textLabel2 );
151 int UtcDaliToolkitTextLabelCopyConstructorP(void)
153 ToolkitTestApplication application;
154 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
155 TextLabel textLabel = TextLabel::New();
156 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
158 TextLabel copy( textLabel );
159 DALI_TEST_CHECK( copy );
160 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
164 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
166 ToolkitTestApplication application;
167 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
168 TextLabel textLabel = TextLabel::New();
169 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
171 TextLabel copy = textLabel;
172 DALI_TEST_CHECK( copy );
173 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
177 // Positive test case for a method
178 int UtcDaliToolkitTextLabelGetPropertyP(void)
180 ToolkitTestApplication application;
181 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
182 TextLabel label = TextLabel::New("Test Text");
183 DALI_TEST_CHECK( label );
185 // Check Property Indices are correct
186 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
187 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
188 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
189 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
190 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
191 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
192 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
193 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
194 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
195 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
196 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
197 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
198 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
199 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
200 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
201 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
202 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
203 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
204 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
205 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
206 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
207 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
208 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
209 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
210 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
211 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
212 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
217 int UtcDaliToolkitTextLabelSetPropertyP(void)
219 ToolkitTestApplication application;
220 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
221 TextLabel label = TextLabel::New();
222 DALI_TEST_CHECK( label );
224 Stage::GetCurrent().Add( label );
226 // Note - we can't check the defaults since the stylesheets are platform-specific
227 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
228 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
230 // Check that text can be correctly reset
231 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
232 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
234 // Check font properties.
235 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
236 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
238 Property::Map fontStyleMapSet;
239 Property::Map fontStyleMapGet;
241 fontStyleMapSet.Insert( "weight", "bold" );
242 fontStyleMapSet.Insert( "width", "condensed" );
243 fontStyleMapSet.Insert( "slant", "italic" );
244 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
246 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
247 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
248 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
250 // Check the old font style format.
251 fontStyleMapSet.Clear();
252 fontStyleMapSet.Insert( "weight", "thin" );
253 fontStyleMapSet.Insert( "width", "expanded" );
254 fontStyleMapSet.Insert( "slant", "oblique" );
255 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
257 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
258 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
259 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
261 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
262 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
265 fontStyleMapSet.Clear();
266 fontStyleMapSet.Insert( "weight", "normal" );
267 fontStyleMapSet.Insert( "slant", "oblique" );
269 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
270 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
271 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
272 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
274 fontStyleMapSet.Clear();
275 fontStyleMapSet.Insert( "slant", "roman" );
277 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
278 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
279 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
281 // Replace 'roman' for 'normal'.
282 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
283 if( NULL != slantValue )
285 if( "normal" == slantValue->Get<std::string>() )
287 fontStyleMapGet["slant"] = "roman";
290 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
292 fontStyleMapSet.Clear();
294 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
295 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
296 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
297 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
300 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
301 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
303 // Check that the Alignment properties can be correctly set
304 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
305 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
306 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
307 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
309 // Check that text color can be properly set
310 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
311 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
312 // The underline color is changed as well.
313 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
315 Property::Map underlineMapSet;
316 Property::Map underlineMapGet;
318 underlineMapSet.Insert( "enable", "false" );
319 underlineMapSet.Insert( "color", "blue" );
320 underlineMapSet.Insert( "height", "0" );
322 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
323 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
324 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
326 // Check that shadow parameters can be correctly set
327 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
328 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
329 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
330 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
332 // Check that underline parameters can be correctly set
333 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
334 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
335 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
336 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
337 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
338 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
340 TextLabel label2 = TextLabel::New( "New text" );
341 DALI_TEST_CHECK( label2 );
342 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
344 // Check the enable markup property.
345 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
346 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
347 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
349 // Check the text property when markup is enabled
350 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
351 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
353 application.SendNotification();
354 application.Render();
356 // Check autoscroll properties
357 const int SCROLL_SPEED = 80;
358 const int SCROLL_LOOPS = 4;
359 const float SCROLL_GAP = 50.0f;
360 const float SCROLL_LOOP_DELAY = 0.3f;
361 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
362 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
364 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
365 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
366 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
367 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
368 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
369 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
370 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
371 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
372 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
373 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
374 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
375 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
377 //Check autoscroll stop type property
378 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
379 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
381 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
382 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
385 // Check the line spacing property
386 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
387 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
388 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
390 // Check the underline property
392 underlineMapSet.Clear();
393 underlineMapSet.Insert( "enable", "true" );
394 underlineMapSet.Insert( "color", "red" );
395 underlineMapSet.Insert( "height", "1" );
397 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
399 application.SendNotification();
400 application.Render();
402 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
403 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
404 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
406 underlineMapSet.Clear();
408 Property::Map underlineDisabledMapGet;
409 underlineDisabledMapGet.Insert( "enable", "false" );
410 underlineDisabledMapGet.Insert( "color", "red" );
411 underlineDisabledMapGet.Insert( "height", "1" );
413 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
414 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
415 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
416 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
418 // Check the shadow property
420 Property::Map shadowMapSet;
421 Property::Map shadowMapGet;
423 shadowMapSet.Insert( "color", Color::GREEN );
424 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
425 shadowMapSet.Insert( "blurRadius", 5.0f );
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", Color::GREEN );
436 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
437 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
439 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
441 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
442 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
443 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
445 // Check the emboss property
446 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
447 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
449 // Check the outline property
451 // Test string type first
452 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
453 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
454 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
456 // Then test the property map type
457 Property::Map outlineMapSet;
458 Property::Map outlineMapGet;
460 outlineMapSet["color"] = Color::RED;
461 outlineMapSet["width"] = 2.0f;
462 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
464 outlineMapSet["color"] = "red";
465 outlineMapSet["width"] = "2";
466 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
467 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
468 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
470 // Check the pixel size of font
471 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
472 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
474 // Check the ellipsis property
475 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
476 label.SetProperty( TextLabel::Property::ELLIPSIS, true );
477 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
479 // Check the layout direction property
480 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
481 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
483 application.SendNotification();
484 application.Render();
489 int UtcDaliToolkitTextlabelAtlasRenderP(void)
491 ToolkitTestApplication application;
492 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
493 TextLabel label = TextLabel::New("Test Text");
494 DALI_TEST_CHECK( label );
496 // Avoid a crash when core load gl resources.
497 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
499 Stage::GetCurrent().Add( label );
501 // Turn on all the effects
502 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
503 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
504 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
505 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
506 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
507 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
511 // Render some text with the shared atlas backend
512 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
513 application.SendNotification();
514 application.Render();
518 tet_result(TET_FAIL);
523 // Render some text with the shared atlas backend
524 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
525 application.SendNotification();
526 application.Render();
530 tet_result(TET_FAIL);
535 int UtcDaliToolkitTextLabelLanguagesP(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
539 TextLabel label = TextLabel::New();
540 DALI_TEST_CHECK( label );
542 Stage::GetCurrent().Add( label );
544 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
545 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
546 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
547 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
548 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
549 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
551 label.SetProperty( TextLabel::Property::TEXT, scripts );
552 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
554 application.SendNotification();
555 application.Render();
560 int UtcDaliToolkitTextLabelEmojisP(void)
562 ToolkitTestApplication application;
563 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
564 TextLabel label = TextLabel::New();
565 DALI_TEST_CHECK( label );
567 Stage::GetCurrent().Add( label );
569 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
571 char* pathNamePtr = get_current_dir_name();
572 const std::string pathName( pathNamePtr );
575 TextAbstraction::FontDescription fontDescription;
576 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
577 fontDescription.family = "BreezeColorEmoji";
578 fontDescription.width = TextAbstraction::FontWidth::NONE;
579 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
580 fontDescription.slant = TextAbstraction::FontSlant::NONE;
582 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
584 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>";
585 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
586 label.SetProperty( TextLabel::Property::TEXT, emojis );
588 Property::Map shadowMap;
589 shadowMap.Insert( "color", "green" );
590 shadowMap.Insert( "offset", "2 2" );
591 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
593 application.SendNotification();
594 application.Render();
599 int UtcDaliToolkitTextlabelScrollingP(void)
601 ToolkitTestApplication application;
602 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
603 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
604 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
606 DALI_TEST_CHECK( labelImmediate );
607 DALI_TEST_CHECK( labelFinished );
608 // Avoid a crash when core load gl resources.
609 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
610 Stage::GetCurrent().Add( labelImmediate );
611 // Turn on all the effects
612 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
613 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
614 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
615 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
616 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
618 Stage::GetCurrent().Add( labelFinished );
619 // Turn on all the effects
620 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
621 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
622 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
623 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
624 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
630 // Render some text with the shared atlas backend
631 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
632 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
634 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
635 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
637 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
638 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
639 application.SendNotification();
640 application.Render();
642 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
643 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
644 application.SendNotification();
645 application.Render();
650 tet_result(TET_FAIL);
656 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
658 ToolkitTestApplication application;
659 TextLabel labelShort = TextLabel::New("Some text to scroll");
660 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!");
662 DALI_TEST_CHECK( labelShort );
663 DALI_TEST_CHECK( labelLong );
664 // Avoid a crash when core load gl resources.
665 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
666 Stage::GetCurrent().Add( labelShort );
667 // Turn on all the effects
668 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
669 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
670 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
671 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
672 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
673 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
675 Stage::GetCurrent().Add( labelLong );
676 // Turn on all the effects
677 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
678 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
679 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
680 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
681 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
682 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
686 // Render some text with the shared atlas backend
687 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
688 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
689 application.SendNotification();
690 application.Render();
692 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
693 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
694 application.SendNotification();
695 application.Render();
700 tet_result(TET_FAIL);
706 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
708 ToolkitTestApplication application;
709 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
710 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
712 DALI_TEST_CHECK( labelShort );
713 DALI_TEST_CHECK( labelLong );
714 // Avoid a crash when core load gl resources.
715 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
716 Stage::GetCurrent().Add( labelShort );
717 // Turn on all the effects
718 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
719 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
720 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
721 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
722 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
723 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
725 Stage::GetCurrent().Add( labelLong );
726 // Turn on all the effects
727 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
728 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
729 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
730 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
731 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
732 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
736 // Render some text with the shared atlas backend
737 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
738 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
739 application.SendNotification();
740 application.Render();
742 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
743 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
744 application.SendNotification();
745 application.Render();
750 tet_result(TET_FAIL);
756 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
758 ToolkitTestApplication application;
759 TextLabel labelShort = TextLabel::New("Some text to scroll");
760 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!");
762 DALI_TEST_CHECK( labelShort );
763 DALI_TEST_CHECK( labelLong );
764 // Avoid a crash when core load gl resources.
765 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
766 Stage::GetCurrent().Add( labelShort );
767 // Turn on all the effects
768 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
769 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
770 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
771 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
772 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
773 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
775 Stage::GetCurrent().Add( labelLong );
776 // Turn on all the effects
777 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
778 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
779 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
780 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
781 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
782 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
786 // Render some text with the shared atlas backend
787 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
788 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
789 application.SendNotification();
790 application.Render();
792 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
793 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
794 application.SendNotification();
795 application.Render();
800 tet_result(TET_FAIL);
806 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
808 ToolkitTestApplication application;
809 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
810 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
812 DALI_TEST_CHECK( labelShort );
813 DALI_TEST_CHECK( labelLong );
814 // Avoid a crash when core load gl resources.
815 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
816 Stage::GetCurrent().Add( labelShort );
817 // Turn on all the effects
818 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
819 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
820 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
821 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
822 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
823 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
825 Stage::GetCurrent().Add( labelLong );
826 // Turn on all the effects
827 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
828 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
829 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
830 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
831 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
832 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
836 // Render some text with the shared atlas backend
837 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
838 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
839 application.SendNotification();
840 application.Render();
842 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
843 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
844 application.SendNotification();
845 application.Render();
850 tet_result(TET_FAIL);
856 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
858 ToolkitTestApplication application;
859 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
860 TextLabel label = TextLabel::New("Some text to scroll");
861 DALI_TEST_CHECK( label );
862 // Avoid a crash when core load gl resources.
863 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
864 Stage::GetCurrent().Add( label );
865 label.SetSize( 360.0f, 20.f );
866 // Turn on all the effects
867 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
868 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
869 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
870 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
873 application.SendNotification();
874 application.Render();
876 unsigned int actorCount1 = label.GetChildCount();
877 tet_printf("Initial actor count is(%d)\n", actorCount1 );
881 // Render some text with the shared atlas backend
882 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
883 application.SendNotification();
884 application.Render(2000);
886 unsigned int actorCount1 = label.GetChildCount();
887 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
889 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
892 application.SendNotification();
893 application.Render();
895 unsigned int actorCount2 = label.GetChildCount();
896 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
898 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
903 tet_result(TET_FAIL);
909 int UtcDaliToolkitTextlabelScrollingN(void)
911 ToolkitTestApplication application;
912 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
914 TextLabel label = TextLabel::New("Some text to scroll");
915 DALI_TEST_CHECK( label );
917 Stage::GetCurrent().Add( label );
919 // Avoid a crash when core load gl resources.
920 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
922 // The text scrolling works only on single line text.
923 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
925 // Turn on all the effects.
926 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
927 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
928 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
930 // Enable the auto scrolling effect.
931 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
933 // The auto scrolling shouldn't be enabled.
934 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
935 DALI_TEST_CHECK( !enabled );
940 int UtcDaliToolkitTextlabelEllipsis(void)
942 ToolkitTestApplication application;
943 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
945 TextLabel label = TextLabel::New("Hello world");
946 DALI_TEST_CHECK( label );
948 // Avoid a crash when core load gl resources.
949 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
951 Stage::GetCurrent().Add( label );
953 // Turn on all the effects
954 label.SetAnchorPoint( AnchorPoint::CENTER );
955 label.SetParentOrigin( ParentOrigin::CENTER );
956 label.SetSize( 360.0f, 10.f );
961 application.SendNotification();
962 application.Render();
966 tet_result(TET_FAIL);
972 int UtcDaliToolkitTextlabelTextWrapMode(void)
974 ToolkitTestApplication application;
975 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
979 TextLabel label = TextLabel::New();
980 label.SetSize( 300.0f, 300.f );
981 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
982 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
986 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
987 Stage::GetCurrent().Add( label );
989 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
990 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
992 application.SendNotification();
993 application.Render();
995 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
996 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
998 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
999 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1001 application.SendNotification();
1002 application.Render();
1004 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1005 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1007 application.SendNotification();
1008 application.Render();
1010 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1011 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1013 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1014 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1016 application.SendNotification();
1017 application.Render();
1019 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1020 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1022 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1023 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1024 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1029 int UtcDaliToolkitTextLabelColorComponents(void)
1031 ToolkitTestApplication application;
1033 TextLabel label = TextLabel::New();
1034 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1035 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1036 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1037 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1038 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1040 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1041 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1042 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1043 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1044 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1046 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1047 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1048 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1049 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1050 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1052 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1053 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1054 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1055 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1060 int UtcDaliToolkitTextlabelTextStyle01(void)
1062 ToolkitTestApplication application;
1063 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1065 TextLabel label = TextLabel::New();
1066 label.SetSize( 300.0f, 300.f );
1067 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1068 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1069 Stage::GetCurrent().Add( label );
1071 Property::Map outlineMapSet;
1072 Property::Map outlineMapGet;
1074 outlineMapSet["color"] = Color::BLUE;
1075 outlineMapSet["width"] = 2.0f;
1076 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1078 application.SendNotification();
1079 application.Render();
1081 Property::Map shadowMapSet;
1082 shadowMapSet.Insert( "color", "green" );
1083 shadowMapSet.Insert( "offset", "2 2" );
1084 shadowMapSet.Insert( "blurRadius", "3" );
1085 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1087 outlineMapSet["color"] = Color::RED;
1088 outlineMapSet["width"] = 0.0f;
1089 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1091 application.SendNotification();
1092 application.Render();
1094 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1096 Property::Value* colorValue = outlineMapGet.Find("color");
1098 bool colorMatched( false );
1102 Property::Type valueType = colorValue->GetType();
1104 if ( Property::STRING == valueType )
1106 std::string stringValue;
1107 colorValue->Get( stringValue );
1108 if ( stringValue == "red" )
1110 colorMatched = true;
1113 else if ( Property::VECTOR4 == valueType )
1115 Vector4 colorVector4;
1116 colorValue->Get( colorVector4 );
1117 if ( colorVector4 == Color::RED )
1119 colorMatched = true;
1124 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1129 int UtcDaliToolkitTextlabelMultiline(void)
1131 ToolkitTestApplication application;
1132 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1134 TextLabel label = TextLabel::New();
1135 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1136 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1137 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1138 Stage::GetCurrent().Add( label );
1140 application.SendNotification();
1141 application.Render();
1143 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1144 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1146 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1148 application.SendNotification();
1149 application.Render();
1151 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1152 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );