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";
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 ) == DevelTextLabel::Property::PIXEL_SIZE );
211 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextLabel::Property::ELLIPSIS );
216 int UtcDaliToolkitTextLabelSetPropertyP(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
220 TextLabel label = TextLabel::New();
221 DALI_TEST_CHECK( label );
223 // Note - we can't check the defaults since the stylesheets are platform-specific
224 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
225 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
227 // Check that text can be correctly reset
228 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
229 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
231 // Check font properties.
232 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
233 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
235 Property::Map fontStyleMapSet;
236 Property::Map fontStyleMapGet;
238 fontStyleMapSet.Insert( "weight", "bold" );
239 fontStyleMapSet.Insert( "width", "condensed" );
240 fontStyleMapSet.Insert( "slant", "italic" );
241 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
243 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
244 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
245 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
247 // Check the old font style format.
248 fontStyleMapSet.Clear();
249 fontStyleMapSet.Insert( "weight", "thin" );
250 fontStyleMapSet.Insert( "width", "expanded" );
251 fontStyleMapSet.Insert( "slant", "oblique" );
253 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
254 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
255 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
256 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
258 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
259 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
262 fontStyleMapSet.Clear();
263 fontStyleMapSet.Insert( "weight", "normal" );
264 fontStyleMapSet.Insert( "slant", "oblique" );
266 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
267 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
268 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
269 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
271 fontStyleMapSet.Clear();
272 fontStyleMapSet.Insert( "slant", "roman" );
274 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
275 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
276 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
278 // Replace 'roman' for 'normal'.
279 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
280 if( NULL != slantValue )
282 if( "normal" == slantValue->Get<std::string>() )
284 fontStyleMapGet["slant"] = "roman";
287 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
289 fontStyleMapSet.Clear();
291 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
292 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
293 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
294 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
297 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
298 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
300 // Check that the Alignment properties can be correctly set
301 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
302 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
303 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
304 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
306 // Check that text color can be properly set
307 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
308 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
309 // The underline color is changed as well.
310 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
312 Property::Map underlineMapSet;
313 Property::Map underlineMapGet;
315 underlineMapSet.Insert( "enable", "false" );
316 underlineMapSet.Insert( "color", "blue" );
317 underlineMapSet.Insert( "height", "0" );
319 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
320 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
321 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
323 // Check that shadow parameters can be correctly set
324 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
325 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
326 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
327 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
329 // Check that underline parameters can be correctly set
330 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
331 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
332 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
333 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
334 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
335 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
337 TextLabel label2 = TextLabel::New( "New text" );
338 DALI_TEST_CHECK( label2 );
339 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
341 // Check the enable markup property.
342 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
343 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
344 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
346 // Check autoscroll properties
347 const int SCROLL_SPEED = 80;
348 const int SCROLL_LOOPS = 4;
349 const float SCROLL_GAP = 50.0f;
350 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
351 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
352 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
353 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
354 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
355 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
356 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
357 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
358 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
359 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
361 // Check the line spacing property
362 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
363 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
364 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
366 // Check the underline property
368 underlineMapSet.Clear();
369 underlineMapSet.Insert( "enable", "true" );
370 underlineMapSet.Insert( "color", "red" );
371 underlineMapSet.Insert( "height", "1" );
373 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
375 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
376 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
377 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
379 underlineMapSet.Clear();
381 Property::Map underlineDisabledMapGet;
382 underlineDisabledMapGet.Insert( "enable", "false" );
383 underlineDisabledMapGet.Insert( "color", "red" );
384 underlineDisabledMapGet.Insert( "height", "1" );
386 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
387 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
388 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
389 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
391 // Check the shadow property
393 Property::Map shadowMapSet;
394 Property::Map shadowMapGet;
396 shadowMapSet.Insert( "color", "green" );
397 shadowMapSet.Insert( "offset", "2 2" );
399 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
401 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
402 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
403 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
405 shadowMapSet.Clear();
406 Property::Map shadowDisabledMapGet;
407 shadowDisabledMapGet.Insert( "color", "green" );
408 shadowDisabledMapGet.Insert( "offset", "0 0" );
410 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
412 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
413 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
414 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
416 // Check the emboss property
417 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
418 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
420 // Check the outline property
421 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
422 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
424 // Check the pixel size of font
425 label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
426 DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
428 // Check the ellipsis property
429 DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
430 label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
431 DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
436 int UtcDaliToolkitTextlabelAtlasRenderP(void)
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
440 TextLabel label = TextLabel::New("Test Text");
441 DALI_TEST_CHECK( label );
443 // Avoid a crash when core load gl resources.
444 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
446 Stage::GetCurrent().Add( label );
448 // Turn on all the effects
449 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
450 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
451 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
452 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
453 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
454 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
458 // Render some text with the shared atlas backend
459 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
460 application.SendNotification();
461 application.Render();
465 tet_result(TET_FAIL);
470 // Render some text with the shared atlas backend
471 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
472 application.SendNotification();
473 application.Render();
477 tet_result(TET_FAIL);
482 int UtcDaliToolkitTextLabelLanguagesP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
486 TextLabel label = TextLabel::New();
487 DALI_TEST_CHECK( label );
489 Stage::GetCurrent().Add( label );
491 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
492 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
493 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
494 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
495 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
496 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
498 label.SetProperty( TextLabel::Property::TEXT, scripts );
499 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
501 application.SendNotification();
502 application.Render();
507 int UtcDaliToolkitTextLabelEmojisP(void)
509 ToolkitTestApplication application;
510 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
511 TextLabel label = TextLabel::New();
512 DALI_TEST_CHECK( label );
514 Stage::GetCurrent().Add( label );
516 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
518 char* pathNamePtr = get_current_dir_name();
519 const std::string pathName( pathNamePtr );
522 TextAbstraction::FontDescription fontDescription;
523 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
524 fontDescription.family = "BreezeColorEmoji";
525 fontDescription.width = TextAbstraction::FontWidth::NONE;
526 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
527 fontDescription.slant = TextAbstraction::FontSlant::NONE;
529 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
531 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>";
532 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
533 label.SetProperty( TextLabel::Property::TEXT, emojis );
535 application.SendNotification();
536 application.Render();
541 int UtcDaliToolkitTextlabelScrollingP(void)
543 ToolkitTestApplication application;
544 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
545 TextLabel label = TextLabel::New("Some text to scroll");
546 DALI_TEST_CHECK( label );
547 // Avoid a crash when core load gl resources.
548 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
549 Stage::GetCurrent().Add( label );
550 // Turn on all the effects
551 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
552 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
553 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
554 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
558 // Render some text with the shared atlas backend
559 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
560 application.SendNotification();
561 application.Render();
565 tet_result(TET_FAIL);
571 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
573 ToolkitTestApplication application;
574 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
575 TextLabel label = TextLabel::New("Some text to scroll");
576 DALI_TEST_CHECK( label );
577 // Avoid a crash when core load gl resources.
578 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
579 Stage::GetCurrent().Add( label );
580 label.SetSize( 360.0f, 20.f );
581 // Turn on all the effects
582 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
583 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
584 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
585 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
588 application.SendNotification();
589 application.Render();
591 unsigned int actorCount1 = label.GetChildCount();
592 tet_printf("Initial actor count is(%d)\n", actorCount1 );
596 // Render some text with the shared atlas backend
597 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
598 application.SendNotification();
599 application.Render(2000);
601 unsigned int actorCount1 = label.GetChildCount();
602 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
604 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
607 application.SendNotification();
608 application.Render();
610 unsigned int actorCount2 = label.GetChildCount();
611 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
613 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
618 tet_result(TET_FAIL);
624 int UtcDaliToolkitTextlabelScrollingN(void)
626 ToolkitTestApplication application;
627 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
629 TextLabel label = TextLabel::New("Some text to scroll");
630 DALI_TEST_CHECK( label );
632 Stage::GetCurrent().Add( label );
634 // Avoid a crash when core load gl resources.
635 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
637 // The text scrolling works only on single line text.
638 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
640 // Turn on all the effects.
641 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
642 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
643 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
645 // Enable the auto scrolling effect.
646 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
648 // The auto scrolling shouldn't be enabled.
649 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
650 DALI_TEST_CHECK( !enabled );
655 int UtcDaliToolkitTextlabelEllipsis(void)
657 ToolkitTestApplication application;
658 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
660 TextLabel label = TextLabel::New("Hello world");
661 DALI_TEST_CHECK( label );
663 // Avoid a crash when core load gl resources.
664 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
666 Stage::GetCurrent().Add( label );
668 // Turn on all the effects
669 label.SetAnchorPoint( AnchorPoint::CENTER );
670 label.SetParentOrigin( ParentOrigin::CENTER );
671 label.SetSize( 360.0f, 10.f );
676 application.SendNotification();
677 application.Render();
681 tet_result(TET_FAIL);