2 * Copyright (c) 2016 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 // Note - we can't check the defaults since the stylesheets are platform-specific
226 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
227 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
229 // Check that text can be correctly reset
230 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
231 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
233 // Check font properties.
234 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
235 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
237 Property::Map fontStyleMapSet;
238 Property::Map fontStyleMapGet;
240 fontStyleMapSet.Insert( "weight", "bold" );
241 fontStyleMapSet.Insert( "width", "condensed" );
242 fontStyleMapSet.Insert( "slant", "italic" );
243 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
245 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
246 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
247 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
249 // Check the old font style format.
250 fontStyleMapSet.Clear();
251 fontStyleMapSet.Insert( "weight", "thin" );
252 fontStyleMapSet.Insert( "width", "expanded" );
253 fontStyleMapSet.Insert( "slant", "oblique" );
255 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
256 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
257 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
258 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
260 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
261 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
264 fontStyleMapSet.Clear();
265 fontStyleMapSet.Insert( "weight", "normal" );
266 fontStyleMapSet.Insert( "slant", "oblique" );
268 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
269 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
270 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
271 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
273 fontStyleMapSet.Clear();
274 fontStyleMapSet.Insert( "slant", "roman" );
276 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
277 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
278 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
280 // Replace 'roman' for 'normal'.
281 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
282 if( NULL != slantValue )
284 if( "normal" == slantValue->Get<std::string>() )
286 fontStyleMapGet["slant"] = "roman";
289 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
291 fontStyleMapSet.Clear();
293 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
294 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
295 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
296 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
299 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
300 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
302 // Check that the Alignment properties can be correctly set
303 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
304 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
305 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
306 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
308 // Check that text color can be properly set
309 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
310 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
311 // The underline color is changed as well.
312 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
314 Property::Map underlineMapSet;
315 Property::Map underlineMapGet;
317 underlineMapSet.Insert( "enable", "false" );
318 underlineMapSet.Insert( "color", "blue" );
319 underlineMapSet.Insert( "height", "0" );
321 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
322 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
323 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
325 // Check that shadow parameters can be correctly set
326 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
327 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
328 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
329 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
331 // Check that underline parameters can be correctly set
332 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
333 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
334 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
335 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
336 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
337 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
339 TextLabel label2 = TextLabel::New( "New text" );
340 DALI_TEST_CHECK( label2 );
341 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
343 // Check the enable markup property.
344 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
345 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
346 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
348 // Check autoscroll properties
349 const int SCROLL_SPEED = 80;
350 const int SCROLL_LOOPS = 4;
351 const float SCROLL_GAP = 50.0f;
352 const float SCROLL_LOOP_DELAY = 0.3f;
353 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
354 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
356 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
357 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
358 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
359 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
360 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
361 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
362 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
363 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
364 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
365 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
366 label.SetProperty(DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
367 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
369 //Check autoscroll stop type property
370 label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
371 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
373 label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
374 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
377 // Check the line spacing property
378 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
379 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
380 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
382 // Check the underline property
384 underlineMapSet.Clear();
385 underlineMapSet.Insert( "enable", "true" );
386 underlineMapSet.Insert( "color", "red" );
387 underlineMapSet.Insert( "height", "1" );
389 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
391 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
392 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
393 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
395 underlineMapSet.Clear();
397 Property::Map underlineDisabledMapGet;
398 underlineDisabledMapGet.Insert( "enable", "false" );
399 underlineDisabledMapGet.Insert( "color", "red" );
400 underlineDisabledMapGet.Insert( "height", "1" );
402 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
403 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
404 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
405 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
407 // Check the shadow property
409 Property::Map shadowMapSet;
410 Property::Map shadowMapGet;
412 shadowMapSet.Insert( "color", "green" );
413 shadowMapSet.Insert( "offset", "2 2" );
415 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
417 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
418 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
419 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
421 shadowMapSet.Clear();
422 Property::Map shadowDisabledMapGet;
423 shadowDisabledMapGet.Insert( "color", "green" );
424 shadowDisabledMapGet.Insert( "offset", "0 0" );
426 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
428 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
429 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
430 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
432 // Check the emboss property
433 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
434 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
436 // Check the outline property
437 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
438 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
440 // Check the pixel size of font
441 label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
442 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
444 // Check the ellipsis property
445 DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
446 label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
447 DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
452 int UtcDaliToolkitTextlabelAtlasRenderP(void)
454 ToolkitTestApplication application;
455 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
456 TextLabel label = TextLabel::New("Test Text");
457 DALI_TEST_CHECK( label );
459 // Avoid a crash when core load gl resources.
460 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
462 Stage::GetCurrent().Add( label );
464 // Turn on all the effects
465 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
466 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
467 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
468 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
469 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
470 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
474 // Render some text with the shared atlas backend
475 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
476 application.SendNotification();
477 application.Render();
481 tet_result(TET_FAIL);
486 // Render some text with the shared atlas backend
487 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
488 application.SendNotification();
489 application.Render();
493 tet_result(TET_FAIL);
498 int UtcDaliToolkitTextLabelLanguagesP(void)
500 ToolkitTestApplication application;
501 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
502 TextLabel label = TextLabel::New();
503 DALI_TEST_CHECK( label );
505 Stage::GetCurrent().Add( label );
507 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
508 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
509 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
510 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
511 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
512 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
514 label.SetProperty( TextLabel::Property::TEXT, scripts );
515 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
517 application.SendNotification();
518 application.Render();
523 int UtcDaliToolkitTextLabelEmojisP(void)
525 ToolkitTestApplication application;
526 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
527 TextLabel label = TextLabel::New();
528 DALI_TEST_CHECK( label );
530 Stage::GetCurrent().Add( label );
532 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
534 char* pathNamePtr = get_current_dir_name();
535 const std::string pathName( pathNamePtr );
538 TextAbstraction::FontDescription fontDescription;
539 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
540 fontDescription.family = "BreezeColorEmoji";
541 fontDescription.width = TextAbstraction::FontWidth::NONE;
542 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
543 fontDescription.slant = TextAbstraction::FontSlant::NONE;
545 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
547 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>";
548 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
549 label.SetProperty( TextLabel::Property::TEXT, emojis );
551 application.SendNotification();
552 application.Render();
557 int UtcDaliToolkitTextlabelScrollingP(void)
559 ToolkitTestApplication application;
560 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
561 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
562 TextLabel labelFinished = TextLabel::New("Some text to scroll");
564 DALI_TEST_CHECK( labelImmediate );
565 DALI_TEST_CHECK( labelFinished );
566 // Avoid a crash when core load gl resources.
567 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
568 Stage::GetCurrent().Add( labelImmediate );
569 // Turn on all the effects
570 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
571 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
572 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
573 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
574 labelImmediate.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
576 Stage::GetCurrent().Add( labelFinished );
577 // Turn on all the effects
578 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
579 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
580 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
581 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
582 labelFinished.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
588 // Render some text with the shared atlas backend
589 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
590 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
591 application.SendNotification();
592 application.Render();
594 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
595 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
596 application.SendNotification();
597 application.Render();
602 tet_result(TET_FAIL);
608 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
610 ToolkitTestApplication application;
611 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
612 TextLabel label = TextLabel::New("Some text to scroll");
613 DALI_TEST_CHECK( label );
614 // Avoid a crash when core load gl resources.
615 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
616 Stage::GetCurrent().Add( label );
617 label.SetSize( 360.0f, 20.f );
618 // Turn on all the effects
619 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
620 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
621 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
622 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
625 application.SendNotification();
626 application.Render();
628 unsigned int actorCount1 = label.GetChildCount();
629 tet_printf("Initial actor count is(%d)\n", actorCount1 );
633 // Render some text with the shared atlas backend
634 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
635 application.SendNotification();
636 application.Render(2000);
638 unsigned int actorCount1 = label.GetChildCount();
639 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
641 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
644 application.SendNotification();
645 application.Render();
647 unsigned int actorCount2 = label.GetChildCount();
648 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
650 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
655 tet_result(TET_FAIL);
661 int UtcDaliToolkitTextlabelScrollingN(void)
663 ToolkitTestApplication application;
664 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
666 TextLabel label = TextLabel::New("Some text to scroll");
667 DALI_TEST_CHECK( label );
669 Stage::GetCurrent().Add( label );
671 // Avoid a crash when core load gl resources.
672 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
674 // The text scrolling works only on single line text.
675 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
677 // Turn on all the effects.
678 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
679 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
680 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
682 // Enable the auto scrolling effect.
683 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
685 // The auto scrolling shouldn't be enabled.
686 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
687 DALI_TEST_CHECK( !enabled );
692 int UtcDaliToolkitTextlabelEllipsis(void)
694 ToolkitTestApplication application;
695 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
697 TextLabel label = TextLabel::New("Hello world");
698 DALI_TEST_CHECK( label );
700 // Avoid a crash when core load gl resources.
701 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
703 Stage::GetCurrent().Add( label );
705 // Turn on all the effects
706 label.SetAnchorPoint( AnchorPoint::CENTER );
707 label.SetParentOrigin( ParentOrigin::CENTER );
708 label.SetSize( 360.0f, 10.f );
713 application.SendNotification();
714 application.Render();
718 tet_result(TET_FAIL);