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>
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 int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
68 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
69 const unsigned int EMOJI_FONT_SIZE = 3968u;
71 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
73 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
75 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
77 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
79 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
80 if( NULL != valueSet )
82 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
84 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
90 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
101 int UtcDaliToolkitTextLabelConstructorP(void)
103 ToolkitTestApplication application;
104 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
106 DALI_TEST_CHECK( !textLabel );
110 int UtcDaliToolkitTextLabelNewP(void)
112 ToolkitTestApplication application;
113 tet_infoline(" UtcDaliToolkitTextLabelNewP");
114 TextLabel textLabel = TextLabel::New( "Test Text" );
115 DALI_TEST_CHECK( textLabel );
119 int UtcDaliToolkitTextLabelDownCastP(void)
121 ToolkitTestApplication application;
122 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
123 TextLabel textLabel1 = TextLabel::New();
124 BaseHandle object( textLabel1 );
126 TextLabel textLabel2 = TextLabel::DownCast( object );
127 DALI_TEST_CHECK( textLabel2 );
129 TextLabel textLabel3 = DownCast< TextLabel >( object );
130 DALI_TEST_CHECK( textLabel3 );
134 int UtcDaliToolkitTextLabelDownCastN(void)
136 ToolkitTestApplication application;
137 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
138 BaseHandle uninitializedObject;
139 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
140 DALI_TEST_CHECK( !textLabel1 );
142 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
143 DALI_TEST_CHECK( !textLabel2 );
147 int UtcDaliToolkitTextLabelCopyConstructorP(void)
149 ToolkitTestApplication application;
150 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
151 TextLabel textLabel = TextLabel::New();
152 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
154 TextLabel copy( textLabel );
155 DALI_TEST_CHECK( copy );
156 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
160 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
162 ToolkitTestApplication application;
163 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
164 TextLabel textLabel = TextLabel::New();
165 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
167 TextLabel copy = textLabel;
168 DALI_TEST_CHECK( copy );
169 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
173 // Positive test case for a method
174 int UtcDaliToolkitTextLabelGetPropertyP(void)
176 ToolkitTestApplication application;
177 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
178 TextLabel label = TextLabel::New("Test Text");
179 DALI_TEST_CHECK( label );
181 // Check Property Indices are correct
182 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
183 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
184 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
185 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
186 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
187 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
188 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
189 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
190 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
191 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
192 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
193 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
194 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
195 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
196 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
197 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
198 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
199 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
200 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
201 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
202 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
203 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
204 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
205 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
210 int UtcDaliToolkitTextLabelSetPropertyP(void)
212 ToolkitTestApplication application;
213 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
214 TextLabel label = TextLabel::New();
215 DALI_TEST_CHECK( label );
217 // Note - we can't check the defaults since the stylesheets are platform-specific
218 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
219 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
221 // Check that text can be correctly reset
222 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
223 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
225 // Check font properties.
226 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
227 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
229 Property::Map fontStyleMapSet;
230 Property::Map fontStyleMapGet;
232 fontStyleMapSet.Insert( "weight", "bold" );
233 fontStyleMapSet.Insert( "width", "condensed" );
234 fontStyleMapSet.Insert( "slant", "italic" );
235 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
237 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
238 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
239 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
241 // Check the old font style format.
242 fontStyleMapSet.Clear();
243 fontStyleMapSet.Insert( "weight", "thin" );
244 fontStyleMapSet.Insert( "width", "expanded" );
245 fontStyleMapSet.Insert( "slant", "oblique" );
247 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
248 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
249 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
250 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
252 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
253 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
256 fontStyleMapSet.Clear();
257 fontStyleMapSet.Insert( "weight", "normal" );
258 fontStyleMapSet.Insert( "slant", "oblique" );
260 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
261 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
262 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
263 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
265 fontStyleMapSet.Clear();
266 fontStyleMapSet.Insert( "slant", "roman" );
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 );
272 // Replace 'roman' for 'normal'.
273 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
274 if( NULL != slantValue )
276 if( "normal" == slantValue->Get<std::string>() )
278 fontStyleMapGet["slant"] = "roman";
281 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
283 fontStyleMapSet.Clear();
285 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
286 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
287 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
288 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
291 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
292 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
294 // Check that the Alignment properties can be correctly set
295 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
296 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
297 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
298 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
300 // Check that text color can be properly set
301 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
302 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
303 // The underline color is changed as well.
304 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
306 Property::Map underlineMapSet;
307 Property::Map underlineMapGet;
309 underlineMapSet.Insert( "enable", "false" );
310 underlineMapSet.Insert( "color", "blue" );
311 underlineMapSet.Insert( "height", "0" );
313 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
314 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
315 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
317 // Check that shadow parameters can be correctly set
318 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
319 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
320 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
321 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
323 // Check that underline parameters can be correctly set
324 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
325 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
326 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
327 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
328 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
329 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
331 TextLabel label2 = TextLabel::New( "New text" );
332 DALI_TEST_CHECK( label2 );
333 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
335 // Check the enable markup property.
336 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
337 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
338 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
340 // Check autoscroll properties
341 const int SCROLL_SPEED = 80;
342 const int SCROLL_LOOPS = 4;
343 const float SCROLL_GAP = 50.0f;
344 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
345 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
346 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
347 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
348 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
349 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
350 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
351 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
352 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
353 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
355 // Check the line spacing property
356 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
357 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
358 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
360 // Check the underline property
362 underlineMapSet.Clear();
363 underlineMapSet.Insert( "enable", "true" );
364 underlineMapSet.Insert( "color", "red" );
365 underlineMapSet.Insert( "height", "1" );
367 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
369 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
370 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
371 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
373 underlineMapSet.Clear();
375 Property::Map underlineDisabledMapGet;
376 underlineDisabledMapGet.Insert( "enable", "false" );
377 underlineDisabledMapGet.Insert( "color", "red" );
378 underlineDisabledMapGet.Insert( "height", "1" );
380 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
381 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
382 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
383 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
385 // Check the shadow property
387 Property::Map shadowMapSet;
388 Property::Map shadowMapGet;
390 shadowMapSet.Insert( "color", "green" );
391 shadowMapSet.Insert( "offset", "2 2" );
393 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
395 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
396 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
397 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
399 shadowMapSet.Clear();
400 Property::Map shadowDisabledMapGet;
401 shadowDisabledMapGet.Insert( "color", "green" );
402 shadowDisabledMapGet.Insert( "offset", "0 0" );
404 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
406 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
407 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
408 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
410 // Check the emboss property
411 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
412 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
414 // Check the outline property
415 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
416 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
421 int UtcDaliToolkitTextlabelAtlasRenderP(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
425 TextLabel label = TextLabel::New("Test Text");
426 DALI_TEST_CHECK( label );
428 // Avoid a crash when core load gl resources.
429 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
431 Stage::GetCurrent().Add( label );
433 // Turn on all the effects
434 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
435 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
436 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
437 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
438 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
439 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
443 // Render some text with the shared atlas backend
444 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
445 application.SendNotification();
446 application.Render();
450 tet_result(TET_FAIL);
456 int UtcDaliToolkitTextLabelLanguagesP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
460 TextLabel label = TextLabel::New();
461 DALI_TEST_CHECK( label );
463 Stage::GetCurrent().Add( label );
465 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
466 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
467 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
468 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
469 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
470 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
472 label.SetProperty( TextLabel::Property::TEXT, scripts );
473 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
475 application.SendNotification();
476 application.Render();
478 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
480 char* pathNamePtr = get_current_dir_name();
481 const std::string pathName( pathNamePtr );
484 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
486 const std::string emojis = "<font family='TizenColorEmoji'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
487 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
488 label.SetProperty( TextLabel::Property::TEXT, emojis );
490 application.SendNotification();
491 application.Render();
496 int UtcDaliToolkitTextlabelScrollingP(void)
498 ToolkitTestApplication application;
499 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
500 TextLabel label = TextLabel::New("Some text to scroll");
501 DALI_TEST_CHECK( label );
502 // Avoid a crash when core load gl resources.
503 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
504 Stage::GetCurrent().Add( label );
505 // Turn on all the effects
506 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
507 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
508 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
509 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
513 // Render some text with the shared atlas backend
514 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
515 application.SendNotification();
516 application.Render();
520 tet_result(TET_FAIL);
526 int UtcDaliToolkitTextlabelScrollingN(void)
528 ToolkitTestApplication application;
529 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
531 TextLabel label = TextLabel::New("Some text to scroll");
532 DALI_TEST_CHECK( label );
534 Stage::GetCurrent().Add( label );
536 // Avoid a crash when core load gl resources.
537 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
539 // The text scrolling works only on single line text.
540 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
542 // Turn on all the effects.
543 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
544 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
545 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
547 // Enable the auto scrolling effect.
548 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
550 // The auto scrolling shouldn't be enabled.
551 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
552 DALI_TEST_CHECK( !enabled );
557 int UtcDaliToolkitTextlabelEllipsis(void)
559 ToolkitTestApplication application;
560 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
562 TextLabel label = TextLabel::New("Hello world");
563 DALI_TEST_CHECK( label );
565 // Avoid a crash when core load gl resources.
566 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
568 Stage::GetCurrent().Add( label );
570 // Turn on all the effects
571 label.SetAnchorPoint( AnchorPoint::CENTER );
572 label.SetParentOrigin( ParentOrigin::CENTER );
573 label.SetSize( 360.0f, 10.f );
578 application.SendNotification();
579 application.Render();
583 tet_result(TET_FAIL);