2 * Copyright (c) 2018 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>
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
28 using namespace Toolkit;
30 void dali_textlabel_startup(void)
32 test_return_value = TET_UNDEF;
35 void dali_textlabel_cleanup(void)
37 test_return_value = TET_PASS;
43 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
44 const char* const PROPERTY_NAME_TEXT = "text";
45 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
46 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
47 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
48 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
49 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
50 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
53 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
54 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
55 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
58 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
59 const char* const PROPERTY_NAME_UNDERLINE = "underline";
60 const char* const PROPERTY_NAME_SHADOW = "shadow";
61 const char* const PROPERTY_NAME_EMBOSS = "emboss";
62 const char* const PROPERTY_NAME_OUTLINE = "outline";
63 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
65 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
66 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
67 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
69 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
70 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
71 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
73 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
75 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
77 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
79 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
81 Property::Value* valueSet = NULL;
82 if ( valueGet.first.type == Property::Key::INDEX )
84 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
88 // Get Key is a string so searching Set Map for a string key
89 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
92 if( NULL != valueSet )
94 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
96 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
99 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
101 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
104 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
106 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
109 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
111 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
114 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
116 Vector2 vector2Get = valueGet.second.Get<Vector2>();
117 Vector2 vector2Set = valueSet->Get<Vector2>();
118 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
121 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
123 Vector4 vector4Get = valueGet.second.Get<Vector4>();
124 Vector4 vector4Set = valueSet->Get<Vector4>();
125 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
131 if ( valueGet.first.type == Property::Key::INDEX )
133 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
137 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
149 int UtcDaliToolkitTextLabelConstructorP(void)
151 ToolkitTestApplication application;
152 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
154 DALI_TEST_CHECK( !textLabel );
158 int UtcDaliToolkitTextLabelNewP(void)
160 ToolkitTestApplication application;
161 tet_infoline(" UtcDaliToolkitTextLabelNewP");
162 TextLabel textLabel = TextLabel::New( "Test Text" );
163 DALI_TEST_CHECK( textLabel );
167 int UtcDaliToolkitTextLabelDownCastP(void)
169 ToolkitTestApplication application;
170 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
171 TextLabel textLabel1 = TextLabel::New();
172 BaseHandle object( textLabel1 );
174 TextLabel textLabel2 = TextLabel::DownCast( object );
175 DALI_TEST_CHECK( textLabel2 );
177 TextLabel textLabel3 = DownCast< TextLabel >( object );
178 DALI_TEST_CHECK( textLabel3 );
182 int UtcDaliToolkitTextLabelDownCastN(void)
184 ToolkitTestApplication application;
185 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
186 BaseHandle uninitializedObject;
187 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
188 DALI_TEST_CHECK( !textLabel1 );
190 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
191 DALI_TEST_CHECK( !textLabel2 );
195 int UtcDaliToolkitTextLabelCopyConstructorP(void)
197 ToolkitTestApplication application;
198 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
199 TextLabel textLabel = TextLabel::New();
200 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
202 TextLabel copy( textLabel );
203 DALI_TEST_CHECK( copy );
204 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
208 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
210 ToolkitTestApplication application;
211 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
212 TextLabel textLabel = TextLabel::New();
213 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
215 TextLabel copy = textLabel;
216 DALI_TEST_CHECK( copy );
217 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
221 // Positive test case for a method
222 int UtcDaliToolkitTextLabelGetPropertyP(void)
224 ToolkitTestApplication application;
225 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
226 TextLabel label = TextLabel::New("Test Text");
227 DALI_TEST_CHECK( label );
229 // Check Property Indices are correct
230 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
231 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
232 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
233 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
234 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
235 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
236 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
237 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
238 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
239 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
240 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
241 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
242 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
243 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
244 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
245 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
246 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
247 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
248 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
249 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
250 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
251 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
257 int UtcDaliToolkitTextLabelSetPropertyP(void)
259 ToolkitTestApplication application;
260 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
261 TextLabel label = TextLabel::New();
262 DALI_TEST_CHECK( label );
264 Stage::GetCurrent().Add( label );
266 // Note - we can't check the defaults since the stylesheets are platform-specific
267 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
268 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
270 // Check that text can be correctly reset
271 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
272 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
274 // Check font properties.
275 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
276 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
278 Property::Map fontStyleMapSet;
279 Property::Map fontStyleMapGet;
281 fontStyleMapSet.Insert( "weight", "bold" );
282 fontStyleMapSet.Insert( "width", "condensed" );
283 fontStyleMapSet.Insert( "slant", "italic" );
284 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 );
290 // Check the old font style format.
291 fontStyleMapSet.Clear();
292 fontStyleMapSet.Insert( "weight", "thin" );
293 fontStyleMapSet.Insert( "width", "expanded" );
294 fontStyleMapSet.Insert( "slant", "oblique" );
295 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
297 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
298 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
299 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
301 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
302 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
305 fontStyleMapSet.Clear();
306 fontStyleMapSet.Insert( "weight", "normal" );
307 fontStyleMapSet.Insert( "slant", "oblique" );
309 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
310 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
311 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
312 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
314 fontStyleMapSet.Clear();
315 fontStyleMapSet.Insert( "slant", "roman" );
317 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
318 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
319 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
321 // Replace 'roman' for 'normal'.
322 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
323 if( NULL != slantValue )
325 if( "normal" == slantValue->Get<std::string>() )
327 fontStyleMapGet["slant"] = "roman";
330 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
332 fontStyleMapSet.Clear();
334 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
335 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
336 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
337 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
340 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
341 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
343 // Check that the Alignment properties can be correctly set
344 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
345 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
346 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
347 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
349 // Check that text color can be properly set
350 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
351 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
353 Property::Map underlineMapSet;
354 Property::Map underlineMapGet;
356 underlineMapSet.Insert( "enable", "false" );
357 underlineMapSet.Insert( "color", "blue" );
358 underlineMapSet.Insert( "height", "0" );
360 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
361 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
362 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
364 TextLabel label2 = TextLabel::New( "New text" );
365 DALI_TEST_CHECK( label2 );
366 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
368 // Check the enable markup property.
369 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
370 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
371 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
373 // Check the text property when markup is enabled
374 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
375 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
377 application.SendNotification();
378 application.Render();
380 // Check autoscroll properties
381 const int SCROLL_SPEED = 80;
382 const int SCROLL_LOOPS = 4;
383 const float SCROLL_GAP = 50.0f;
384 const float SCROLL_LOOP_DELAY = 0.3f;
385 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
386 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
388 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
389 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
390 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
391 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
392 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
393 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
394 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
395 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
396 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
397 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
398 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
399 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
401 //Check autoscroll stop type property
402 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
403 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
405 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
406 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
408 // test natural size with multi-line and line spacing
410 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
411 Vector3 expected0(414.f, 192.f, 0.0f);
412 Vector3 expected1(414.f, 252.f, 0.0f);
413 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
414 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
415 DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
416 label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
417 DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
420 // single line, line spacing must not affect natural size
422 const Vector3 expected0(948.f, 64.f, 0.0f);
423 const Vector3 expected1(948.f, 84.f, 0.0f);
424 TextLabel label3 = TextLabel::New("Some text here end there end here");
425 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
426 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
427 DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
428 label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
429 DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
431 // Check the line spacing property
432 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
433 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
434 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
436 // Check the underline property
437 underlineMapSet.Clear();
438 underlineMapSet.Insert( "enable", "true" );
439 underlineMapSet.Insert( "color", "red" );
440 underlineMapSet.Insert( "height", "1" );
442 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
444 application.SendNotification();
445 application.Render();
447 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
448 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
449 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
451 underlineMapSet.Clear();
453 Property::Map underlineDisabledMapGet;
454 underlineDisabledMapGet.Insert( "enable", "false" );
455 underlineDisabledMapGet.Insert( "color", "red" );
456 underlineDisabledMapGet.Insert( "height", "1" );
458 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
459 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
460 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
461 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
463 // Check the shadow property
465 Property::Map shadowMapSet;
466 Property::Map shadowMapGet;
468 shadowMapSet.Insert( "color", Color::GREEN );
469 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
470 shadowMapSet.Insert( "blurRadius", 5.0f );
472 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
474 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
475 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
476 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
478 shadowMapSet.Clear();
479 Property::Map shadowDisabledMapGet;
480 shadowDisabledMapGet.Insert( "color", Color::GREEN );
481 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
482 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
484 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
486 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
487 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
488 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
490 // Check the emboss property
491 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
492 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
494 // Check the outline property
496 // Test string type first
497 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
498 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
499 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
501 // Then test the property map type
502 Property::Map outlineMapSet;
503 Property::Map outlineMapGet;
505 outlineMapSet["color"] = Color::RED;
506 outlineMapSet["width"] = 2.0f;
507 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
509 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
510 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
511 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
513 // Check the background property
514 Property::Map backgroundMapSet;
515 Property::Map backgroundMapGet;
517 backgroundMapSet["enable"] = true;
518 backgroundMapSet["color"] = Color::RED;
519 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
521 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
522 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
523 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
525 // Check the pixel size of font
526 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
527 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
529 // Check the ellipsis property
530 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
531 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
532 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
534 // Check the layout direction property
535 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
536 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
538 application.SendNotification();
539 application.Render();
544 int UtcDaliToolkitTextlabelAtlasRenderP(void)
546 ToolkitTestApplication application;
547 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
548 TextLabel label = TextLabel::New("Test Text");
549 DALI_TEST_CHECK( label );
551 // Avoid a crash when core load gl resources.
552 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
554 Stage::GetCurrent().Add( label );
556 // Turn on all the effects
557 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
558 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
560 Property::Map underlineMap;
561 underlineMap.Insert( "enable", "true" );
562 underlineMap.Insert( "color", "red" );
563 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
565 Property::Map shadowMap;
566 shadowMap.Insert( "color", Color::BLUE );
567 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
568 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
572 // Render some text with the shared atlas backend
573 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
574 application.SendNotification();
575 application.Render();
579 tet_result(TET_FAIL);
584 // Render some text with the shared atlas backend
585 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
586 application.SendNotification();
587 application.Render();
591 tet_result(TET_FAIL);
596 int UtcDaliToolkitTextLabelLanguagesP(void)
598 ToolkitTestApplication application;
599 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
600 TextLabel label = TextLabel::New();
601 DALI_TEST_CHECK( label );
603 Stage::GetCurrent().Add( label );
605 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
606 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
607 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
608 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
609 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
610 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
612 label.SetProperty( TextLabel::Property::TEXT, scripts );
613 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
615 application.SendNotification();
616 application.Render();
621 int UtcDaliToolkitTextLabelEmojisP(void)
623 ToolkitTestApplication application;
624 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
625 TextLabel label = TextLabel::New();
626 DALI_TEST_CHECK( label );
628 Stage::GetCurrent().Add( label );
630 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
632 char* pathNamePtr = get_current_dir_name();
633 const std::string pathName( pathNamePtr );
636 TextAbstraction::FontDescription fontDescription;
637 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
638 fontDescription.family = "BreezeColorEmoji";
639 fontDescription.width = TextAbstraction::FontWidth::NONE;
640 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
641 fontDescription.slant = TextAbstraction::FontSlant::NONE;
643 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
645 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>";
646 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
647 label.SetProperty( TextLabel::Property::TEXT, emojis );
649 Property::Map shadowMap;
650 shadowMap.Insert( "color", "green" );
651 shadowMap.Insert( "offset", "2 2" );
652 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
654 application.SendNotification();
655 application.Render();
660 int UtcDaliToolkitTextlabelScrollingP(void)
662 ToolkitTestApplication application;
663 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
664 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
665 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
667 DALI_TEST_CHECK( labelImmediate );
668 DALI_TEST_CHECK( labelFinished );
669 // Avoid a crash when core load gl resources.
670 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
671 Stage::GetCurrent().Add( labelImmediate );
672 // Turn on all the effects
673 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
674 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
675 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
676 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
677 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
679 Stage::GetCurrent().Add( labelFinished );
680 // Turn on all the effects
681 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
682 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
683 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
684 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
685 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
691 // Render some text with the shared atlas backend
692 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
693 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
695 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
696 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
698 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
699 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
700 application.SendNotification();
701 application.Render();
703 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
704 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
705 application.SendNotification();
706 application.Render();
711 tet_result(TET_FAIL);
717 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
719 ToolkitTestApplication application;
720 TextLabel labelShort = TextLabel::New("Some text to scroll");
721 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!");
723 DALI_TEST_CHECK( labelShort );
724 DALI_TEST_CHECK( labelLong );
725 // Avoid a crash when core load gl resources.
726 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
727 Stage::GetCurrent().Add( labelShort );
728 // Turn on all the effects
729 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
730 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
731 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
732 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
733 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
734 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
736 Stage::GetCurrent().Add( labelLong );
737 // Turn on all the effects
738 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
739 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
740 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
741 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
742 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
743 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
747 // Render some text with the shared atlas backend
748 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
749 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
750 application.SendNotification();
751 application.Render();
753 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
754 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
755 application.SendNotification();
756 application.Render();
761 tet_result(TET_FAIL);
767 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
769 ToolkitTestApplication application;
770 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
771 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
773 DALI_TEST_CHECK( labelShort );
774 DALI_TEST_CHECK( labelLong );
775 // Avoid a crash when core load gl resources.
776 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
777 Stage::GetCurrent().Add( labelShort );
778 // Turn on all the effects
779 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
780 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
781 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
782 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
783 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
784 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
786 Stage::GetCurrent().Add( labelLong );
787 // Turn on all the effects
788 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
789 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
790 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
791 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
792 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
793 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
797 // Render some text with the shared atlas backend
798 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
799 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
800 application.SendNotification();
801 application.Render();
803 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
804 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805 application.SendNotification();
806 application.Render();
811 tet_result(TET_FAIL);
817 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
819 ToolkitTestApplication application;
820 TextLabel labelShort = TextLabel::New("Some text to scroll");
821 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!");
823 DALI_TEST_CHECK( labelShort );
824 DALI_TEST_CHECK( labelLong );
825 // Avoid a crash when core load gl resources.
826 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
827 Stage::GetCurrent().Add( labelShort );
828 // Turn on all the effects
829 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
830 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
831 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
832 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
833 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
834 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
836 Stage::GetCurrent().Add( labelLong );
837 // Turn on all the effects
838 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
839 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
840 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
841 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
842 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
843 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
847 // Render some text with the shared atlas backend
848 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
849 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
850 application.SendNotification();
851 application.Render();
853 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
854 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
855 application.SendNotification();
856 application.Render();
861 tet_result(TET_FAIL);
867 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
869 ToolkitTestApplication application;
870 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
871 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
873 DALI_TEST_CHECK( labelShort );
874 DALI_TEST_CHECK( labelLong );
875 // Avoid a crash when core load gl resources.
876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
877 Stage::GetCurrent().Add( labelShort );
878 // Turn on all the effects
879 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
880 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
881 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
882 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
883 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
884 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
886 Stage::GetCurrent().Add( labelLong );
887 // Turn on all the effects
888 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
889 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
890 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
891 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
892 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
893 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
897 // Render some text with the shared atlas backend
898 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
899 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
900 application.SendNotification();
901 application.Render();
903 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
904 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
905 application.SendNotification();
906 application.Render();
911 tet_result(TET_FAIL);
917 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
919 ToolkitTestApplication application;
920 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
921 TextLabel label = TextLabel::New("Some text to scroll");
922 DALI_TEST_CHECK( label );
923 // Avoid a crash when core load gl resources.
924 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
925 Stage::GetCurrent().Add( label );
926 label.SetSize( 360.0f, 20.f );
927 // Turn on all the effects
928 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
929 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
930 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
931 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
934 application.SendNotification();
935 application.Render();
937 unsigned int actorCount1 = label.GetChildCount();
938 tet_printf("Initial actor count is(%d)\n", actorCount1 );
942 // Render some text with the shared atlas backend
943 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
944 application.SendNotification();
945 application.Render(2000);
947 unsigned int actorCount1 = label.GetChildCount();
948 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
950 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
953 application.SendNotification();
954 application.Render();
956 unsigned int actorCount2 = label.GetChildCount();
957 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
959 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
964 tet_result(TET_FAIL);
970 int UtcDaliToolkitTextlabelScrollingN(void)
972 ToolkitTestApplication application;
973 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
975 TextLabel label = TextLabel::New("Some text to scroll");
976 DALI_TEST_CHECK( label );
978 Stage::GetCurrent().Add( label );
980 // Avoid a crash when core load gl resources.
981 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
983 // The text scrolling works only on single line text.
984 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
986 // Turn on all the effects.
987 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
988 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
989 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
991 // Enable the auto scrolling effect.
992 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
994 // The auto scrolling shouldn't be enabled.
995 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
996 DALI_TEST_CHECK( !enabled );
1001 int UtcDaliToolkitTextlabelEllipsis(void)
1003 ToolkitTestApplication application;
1004 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1006 TextLabel label = TextLabel::New("Hello world");
1007 DALI_TEST_CHECK( label );
1009 // Avoid a crash when core load gl resources.
1010 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1012 Stage::GetCurrent().Add( label );
1014 // Turn on all the effects
1015 label.SetAnchorPoint( AnchorPoint::CENTER );
1016 label.SetParentOrigin( ParentOrigin::CENTER );
1017 label.SetSize( 360.0f, 10.f );
1022 application.SendNotification();
1023 application.Render();
1027 tet_result(TET_FAIL);
1030 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1031 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1032 label.SetSize( 400.0f, 10.f );
1037 application.SendNotification();
1038 application.Render();
1042 tet_result(TET_FAIL);
1046 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1047 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1048 label.SetSize( 400.0f, 10.f );
1053 application.SendNotification();
1054 application.Render();
1058 tet_result(TET_FAIL);
1064 int UtcDaliToolkitTextlabelTextWrapMode(void)
1066 ToolkitTestApplication application;
1067 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1071 TextLabel label = TextLabel::New();
1072 label.SetSize( 300.0f, 300.f );
1073 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1074 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1078 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1079 Stage::GetCurrent().Add( label );
1081 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1082 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1084 application.SendNotification();
1085 application.Render();
1087 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1088 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1090 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1091 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1093 application.SendNotification();
1094 application.Render();
1096 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1097 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1099 application.SendNotification();
1100 application.Render();
1102 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1103 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1105 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1106 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1108 application.SendNotification();
1109 application.Render();
1111 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1112 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1114 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1115 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1116 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1121 int UtcDaliToolkitTextLabelColorComponents(void)
1123 ToolkitTestApplication application;
1125 TextLabel label = TextLabel::New();
1126 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1127 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1128 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1129 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1130 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1132 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1133 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1134 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1135 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1136 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1138 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1139 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1140 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1141 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1142 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1144 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1145 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1146 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1147 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1149 // Test a transparent text - Rendering should be skipped.
1150 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1151 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1153 Stage::GetCurrent().Add( label );
1155 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1156 drawTrace.Enable( true );
1158 application.SendNotification();
1159 application.Render();
1161 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1163 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1167 application.SendNotification();
1168 application.Render();
1170 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1172 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1176 application.SendNotification();
1177 application.Render();
1179 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1184 int UtcDaliToolkitTextlabelTextStyle01(void)
1186 ToolkitTestApplication application;
1187 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1189 TextLabel label = TextLabel::New();
1190 label.SetSize( 300.0f, 300.f );
1191 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1192 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1193 Stage::GetCurrent().Add( label );
1195 Property::Map outlineMapSet;
1196 Property::Map outlineMapGet;
1198 outlineMapSet["color"] = Color::BLUE;
1199 outlineMapSet["width"] = 2.0f;
1200 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1202 application.SendNotification();
1203 application.Render();
1205 Property::Map shadowMapSet;
1206 shadowMapSet.Insert( "color", "green" );
1207 shadowMapSet.Insert( "offset", "2 2" );
1208 shadowMapSet.Insert( "blurRadius", "3" );
1209 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1211 outlineMapSet["color"] = Color::RED;
1212 outlineMapSet["width"] = 0.0f;
1213 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1215 application.SendNotification();
1216 application.Render();
1218 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1220 Property::Value* colorValue = outlineMapGet.Find("color");
1222 bool colorMatched( false );
1226 Property::Type valueType = colorValue->GetType();
1228 if ( Property::STRING == valueType )
1230 std::string stringValue;
1231 colorValue->Get( stringValue );
1232 if ( stringValue == "red" )
1234 colorMatched = true;
1237 else if ( Property::VECTOR4 == valueType )
1239 Vector4 colorVector4;
1240 colorValue->Get( colorVector4 );
1241 if ( colorVector4 == Color::RED )
1243 colorMatched = true;
1248 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1253 int UtcDaliToolkitTextlabelMultiline(void)
1255 ToolkitTestApplication application;
1256 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1258 TextLabel label = TextLabel::New();
1259 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1260 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1261 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1262 Stage::GetCurrent().Add( label );
1264 application.SendNotification();
1265 application.Render();
1267 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1268 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1270 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1272 application.SendNotification();
1273 application.Render();
1275 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1276 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1282 int UtcDaliToolkitTextlabelTextDirection(void)
1284 ToolkitTestApplication application;
1285 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1287 TextLabel label = TextLabel::New();
1288 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1290 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1291 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1292 Stage::GetCurrent().Add( label );
1295 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1298 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1299 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1301 // Test RTL text starting with weak character
1302 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1303 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1305 // Test RTL text string with emoji and weak character
1306 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1307 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1312 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1314 ToolkitTestApplication application;
1315 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1317 TextLabel label = TextLabel::New();
1319 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1320 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1321 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1322 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1323 Stage::GetCurrent().Add( label );
1324 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1326 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1327 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1329 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1330 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );