2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
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_SHADOW_OFFSET = "shadowOffset";
53 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
54 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
55 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
56 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
57 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
63 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
64 const char* const PROPERTY_NAME_UNDERLINE = "underline";
65 const char* const PROPERTY_NAME_SHADOW = "shadow";
66 const char* const PROPERTY_NAME_EMBOSS = "emboss";
67 const char* const PROPERTY_NAME_OUTLINE = "outline";
69 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
70 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
71 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
73 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
74 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
75 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
77 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
79 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
81 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
83 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
85 Property::Value* valueSet = NULL;
86 if ( valueGet.first.type == Property::Key::INDEX )
88 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
92 // Get Key is a string so searching Set Map for a string key
93 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
96 if( NULL != valueSet )
98 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
100 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
103 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
105 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
108 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
110 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
113 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
115 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
118 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
120 Vector2 vector2Get = valueGet.second.Get<Vector2>();
121 Vector2 vector2Set = valueSet->Get<Vector2>();
122 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
125 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
127 Vector4 vector4Get = valueGet.second.Get<Vector4>();
128 Vector4 vector4Set = valueSet->Get<Vector4>();
129 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 );
135 if ( valueGet.first.type == Property::Key::INDEX )
137 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
141 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
153 int UtcDaliToolkitTextLabelConstructorP(void)
155 ToolkitTestApplication application;
156 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
158 DALI_TEST_CHECK( !textLabel );
162 int UtcDaliToolkitTextLabelNewP(void)
164 ToolkitTestApplication application;
165 tet_infoline(" UtcDaliToolkitTextLabelNewP");
166 TextLabel textLabel = TextLabel::New( "Test Text" );
167 DALI_TEST_CHECK( textLabel );
171 int UtcDaliToolkitTextLabelDownCastP(void)
173 ToolkitTestApplication application;
174 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
175 TextLabel textLabel1 = TextLabel::New();
176 BaseHandle object( textLabel1 );
178 TextLabel textLabel2 = TextLabel::DownCast( object );
179 DALI_TEST_CHECK( textLabel2 );
181 TextLabel textLabel3 = DownCast< TextLabel >( object );
182 DALI_TEST_CHECK( textLabel3 );
186 int UtcDaliToolkitTextLabelDownCastN(void)
188 ToolkitTestApplication application;
189 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
190 BaseHandle uninitializedObject;
191 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
192 DALI_TEST_CHECK( !textLabel1 );
194 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
195 DALI_TEST_CHECK( !textLabel2 );
199 int UtcDaliToolkitTextLabelCopyConstructorP(void)
201 ToolkitTestApplication application;
202 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
203 TextLabel textLabel = TextLabel::New();
204 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
206 TextLabel copy( textLabel );
207 DALI_TEST_CHECK( copy );
208 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
212 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
214 ToolkitTestApplication application;
215 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
216 TextLabel textLabel = TextLabel::New();
217 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
219 TextLabel copy = textLabel;
220 DALI_TEST_CHECK( copy );
221 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
225 // Positive test case for a method
226 int UtcDaliToolkitTextLabelGetPropertyP(void)
228 ToolkitTestApplication application;
229 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
230 TextLabel label = TextLabel::New("Test Text");
231 DALI_TEST_CHECK( label );
233 // Check Property Indices are correct
234 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
235 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
236 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
237 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
238 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
239 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
240 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
241 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
242 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
243 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
244 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
245 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
246 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
247 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
248 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
249 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
250 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
251 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
252 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
265 int UtcDaliToolkitTextLabelSetPropertyP(void)
267 ToolkitTestApplication application;
268 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
269 TextLabel label = TextLabel::New();
270 DALI_TEST_CHECK( label );
272 Stage::GetCurrent().Add( label );
274 // Note - we can't check the defaults since the stylesheets are platform-specific
275 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
276 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
278 // Check that text can be correctly reset
279 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
280 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
282 // Check font properties.
283 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
284 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
286 Property::Map fontStyleMapSet;
287 Property::Map fontStyleMapGet;
289 fontStyleMapSet.Insert( "weight", "bold" );
290 fontStyleMapSet.Insert( "width", "condensed" );
291 fontStyleMapSet.Insert( "slant", "italic" );
292 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
294 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
295 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
296 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
298 // Check the old font style format.
299 fontStyleMapSet.Clear();
300 fontStyleMapSet.Insert( "weight", "thin" );
301 fontStyleMapSet.Insert( "width", "expanded" );
302 fontStyleMapSet.Insert( "slant", "oblique" );
303 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
305 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
306 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
307 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
309 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
310 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 fontStyleMapSet.Clear();
314 fontStyleMapSet.Insert( "weight", "normal" );
315 fontStyleMapSet.Insert( "slant", "oblique" );
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 );
320 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
322 fontStyleMapSet.Clear();
323 fontStyleMapSet.Insert( "slant", "roman" );
325 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
326 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
327 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
329 // Replace 'roman' for 'normal'.
330 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
331 if( NULL != slantValue )
333 if( "normal" == slantValue->Get<std::string>() )
335 fontStyleMapGet["slant"] = "roman";
338 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
340 fontStyleMapSet.Clear();
342 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
343 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
344 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
345 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
348 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
349 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
351 // Check that the Alignment properties can be correctly set
352 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
353 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
354 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
355 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
357 // Check that text color can be properly set
358 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
359 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
360 // The underline color is changed as well.
361 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
363 Property::Map underlineMapSet;
364 Property::Map underlineMapGet;
366 underlineMapSet.Insert( "enable", "false" );
367 underlineMapSet.Insert( "color", "blue" );
368 underlineMapSet.Insert( "height", "0" );
370 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
371 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
372 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
374 // Check that shadow parameters can be correctly set
375 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
376 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
377 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
378 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
380 // Check that underline parameters can be correctly set
381 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
382 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
383 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
384 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
385 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
386 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
388 TextLabel label2 = TextLabel::New( "New text" );
389 DALI_TEST_CHECK( label2 );
390 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
392 // Check the enable markup property.
393 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
394 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
395 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
397 // Check the text property when markup is enabled
398 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
399 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
401 application.SendNotification();
402 application.Render();
404 // Check autoscroll properties
405 const int SCROLL_SPEED = 80;
406 const int SCROLL_LOOPS = 4;
407 const float SCROLL_GAP = 50.0f;
408 const float SCROLL_LOOP_DELAY = 0.3f;
409 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
410 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
412 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
413 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
414 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
415 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
416 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
417 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
418 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
419 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
420 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
421 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
422 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
423 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
425 //Check autoscroll stop type property
426 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
427 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
429 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
430 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
432 // test natural size with multi-line and line spacing
434 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
435 Vector3 expected0(414.f, 192.f, 0.0f);
436 Vector3 expected1(414.f, 252.f, 0.0f);
437 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
438 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
439 DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
440 label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
441 DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
444 // single line, line spacing must not affect natural size
446 const Vector3 expected0(948.f, 64.f, 0.0f);
447 const Vector3 expected1(948.f, 84.f, 0.0f);
448 TextLabel label3 = TextLabel::New("Some text here end there end here");
449 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
450 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
451 DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
452 label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
453 DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
455 // Check the line spacing property
456 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
457 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
458 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
460 // Check the underline property
461 underlineMapSet.Clear();
462 underlineMapSet.Insert( "enable", "true" );
463 underlineMapSet.Insert( "color", "red" );
464 underlineMapSet.Insert( "height", "1" );
466 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
468 application.SendNotification();
469 application.Render();
471 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
472 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
473 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
475 underlineMapSet.Clear();
477 Property::Map underlineDisabledMapGet;
478 underlineDisabledMapGet.Insert( "enable", "false" );
479 underlineDisabledMapGet.Insert( "color", "red" );
480 underlineDisabledMapGet.Insert( "height", "1" );
482 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
483 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
484 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
485 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
487 // Check the shadow property
489 Property::Map shadowMapSet;
490 Property::Map shadowMapGet;
492 shadowMapSet.Insert( "color", Color::GREEN );
493 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
494 shadowMapSet.Insert( "blurRadius", 5.0f );
496 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
498 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
499 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
500 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
502 shadowMapSet.Clear();
503 Property::Map shadowDisabledMapGet;
504 shadowDisabledMapGet.Insert( "color", Color::GREEN );
505 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
506 shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
508 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
510 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
511 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
512 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
514 // Check the emboss property
515 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
516 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
518 // Check the outline property
520 // Test string type first
521 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
522 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
523 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
525 // Then test the property map type
526 Property::Map outlineMapSet;
527 Property::Map outlineMapGet;
529 outlineMapSet["color"] = Color::RED;
530 outlineMapSet["width"] = 2.0f;
531 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
533 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
534 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
535 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
537 // Check the pixel size of font
538 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
539 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
541 // Check the ellipsis property
542 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
543 label.SetProperty( TextLabel::Property::ELLIPSIS, true );
544 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
546 // Check the layout direction property
547 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
548 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
550 application.SendNotification();
551 application.Render();
556 int UtcDaliToolkitTextlabelAtlasRenderP(void)
558 ToolkitTestApplication application;
559 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
560 TextLabel label = TextLabel::New("Test Text");
561 DALI_TEST_CHECK( label );
563 // Avoid a crash when core load gl resources.
564 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
566 Stage::GetCurrent().Add( label );
568 // Turn on all the effects
569 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
570 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
571 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
572 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
573 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
574 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
578 // Render some text with the shared atlas backend
579 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
580 application.SendNotification();
581 application.Render();
585 tet_result(TET_FAIL);
590 // Render some text with the shared atlas backend
591 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
592 application.SendNotification();
593 application.Render();
597 tet_result(TET_FAIL);
602 int UtcDaliToolkitTextLabelLanguagesP(void)
604 ToolkitTestApplication application;
605 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
606 TextLabel label = TextLabel::New();
607 DALI_TEST_CHECK( label );
609 Stage::GetCurrent().Add( label );
611 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
612 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
613 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
614 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
615 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
616 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
618 label.SetProperty( TextLabel::Property::TEXT, scripts );
619 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
621 application.SendNotification();
622 application.Render();
627 int UtcDaliToolkitTextLabelEmojisP(void)
629 ToolkitTestApplication application;
630 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
631 TextLabel label = TextLabel::New();
632 DALI_TEST_CHECK( label );
634 Stage::GetCurrent().Add( label );
636 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
638 char* pathNamePtr = get_current_dir_name();
639 const std::string pathName( pathNamePtr );
642 TextAbstraction::FontDescription fontDescription;
643 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
644 fontDescription.family = "BreezeColorEmoji";
645 fontDescription.width = TextAbstraction::FontWidth::NONE;
646 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
647 fontDescription.slant = TextAbstraction::FontSlant::NONE;
649 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
651 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>";
652 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
653 label.SetProperty( TextLabel::Property::TEXT, emojis );
655 Property::Map shadowMap;
656 shadowMap.Insert( "color", "green" );
657 shadowMap.Insert( "offset", "2 2" );
658 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
660 application.SendNotification();
661 application.Render();
666 int UtcDaliToolkitTextlabelScrollingP(void)
668 ToolkitTestApplication application;
669 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
670 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
671 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
673 DALI_TEST_CHECK( labelImmediate );
674 DALI_TEST_CHECK( labelFinished );
675 // Avoid a crash when core load gl resources.
676 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
677 Stage::GetCurrent().Add( labelImmediate );
678 // Turn on all the effects
679 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
680 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
681 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
682 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
683 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
685 Stage::GetCurrent().Add( labelFinished );
686 // Turn on all the effects
687 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
688 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
689 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
690 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
691 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
697 // Render some text with the shared atlas backend
698 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
699 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
701 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
702 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
704 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
705 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
706 application.SendNotification();
707 application.Render();
709 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
710 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
711 application.SendNotification();
712 application.Render();
717 tet_result(TET_FAIL);
723 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
725 ToolkitTestApplication application;
726 TextLabel labelShort = TextLabel::New("Some text to scroll");
727 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!");
729 DALI_TEST_CHECK( labelShort );
730 DALI_TEST_CHECK( labelLong );
731 // Avoid a crash when core load gl resources.
732 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
733 Stage::GetCurrent().Add( labelShort );
734 // Turn on all the effects
735 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
736 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
737 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
738 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
739 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
740 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
742 Stage::GetCurrent().Add( labelLong );
743 // Turn on all the effects
744 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
745 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
746 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
747 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
748 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
749 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
753 // Render some text with the shared atlas backend
754 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
755 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
756 application.SendNotification();
757 application.Render();
759 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
760 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
761 application.SendNotification();
762 application.Render();
767 tet_result(TET_FAIL);
773 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
775 ToolkitTestApplication application;
776 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
777 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
779 DALI_TEST_CHECK( labelShort );
780 DALI_TEST_CHECK( labelLong );
781 // Avoid a crash when core load gl resources.
782 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
783 Stage::GetCurrent().Add( labelShort );
784 // Turn on all the effects
785 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
786 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
787 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
788 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
789 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
790 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
792 Stage::GetCurrent().Add( labelLong );
793 // Turn on all the effects
794 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
795 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
796 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
797 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
798 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
799 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
803 // Render some text with the shared atlas backend
804 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
805 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
806 application.SendNotification();
807 application.Render();
809 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
810 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
811 application.SendNotification();
812 application.Render();
817 tet_result(TET_FAIL);
823 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
825 ToolkitTestApplication application;
826 TextLabel labelShort = TextLabel::New("Some text to scroll");
827 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!");
829 DALI_TEST_CHECK( labelShort );
830 DALI_TEST_CHECK( labelLong );
831 // Avoid a crash when core load gl resources.
832 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
833 Stage::GetCurrent().Add( labelShort );
834 // Turn on all the effects
835 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
836 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
837 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
838 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
839 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
840 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
842 Stage::GetCurrent().Add( labelLong );
843 // Turn on all the effects
844 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
845 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
846 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
847 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
848 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
849 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
853 // Render some text with the shared atlas backend
854 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
855 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
856 application.SendNotification();
857 application.Render();
859 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
860 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
861 application.SendNotification();
862 application.Render();
867 tet_result(TET_FAIL);
873 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
875 ToolkitTestApplication application;
876 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
877 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
879 DALI_TEST_CHECK( labelShort );
880 DALI_TEST_CHECK( labelLong );
881 // Avoid a crash when core load gl resources.
882 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
883 Stage::GetCurrent().Add( labelShort );
884 // Turn on all the effects
885 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
886 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
887 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
888 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
889 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
890 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
892 Stage::GetCurrent().Add( labelLong );
893 // Turn on all the effects
894 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
895 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
896 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
897 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
898 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
899 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
903 // Render some text with the shared atlas backend
904 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
905 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
906 application.SendNotification();
907 application.Render();
909 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
910 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
911 application.SendNotification();
912 application.Render();
917 tet_result(TET_FAIL);
923 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
925 ToolkitTestApplication application;
926 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
927 TextLabel label = TextLabel::New("Some text to scroll");
928 DALI_TEST_CHECK( label );
929 // Avoid a crash when core load gl resources.
930 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
931 Stage::GetCurrent().Add( label );
932 label.SetSize( 360.0f, 20.f );
933 // Turn on all the effects
934 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
935 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
936 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
937 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
940 application.SendNotification();
941 application.Render();
943 unsigned int actorCount1 = label.GetChildCount();
944 tet_printf("Initial actor count is(%d)\n", actorCount1 );
948 // Render some text with the shared atlas backend
949 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
950 application.SendNotification();
951 application.Render(2000);
953 unsigned int actorCount1 = label.GetChildCount();
954 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
956 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
959 application.SendNotification();
960 application.Render();
962 unsigned int actorCount2 = label.GetChildCount();
963 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
965 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
970 tet_result(TET_FAIL);
976 int UtcDaliToolkitTextlabelScrollingN(void)
978 ToolkitTestApplication application;
979 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
981 TextLabel label = TextLabel::New("Some text to scroll");
982 DALI_TEST_CHECK( label );
984 Stage::GetCurrent().Add( label );
986 // Avoid a crash when core load gl resources.
987 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
989 // The text scrolling works only on single line text.
990 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
992 // Turn on all the effects.
993 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
994 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
995 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
997 // Enable the auto scrolling effect.
998 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1000 // The auto scrolling shouldn't be enabled.
1001 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1002 DALI_TEST_CHECK( !enabled );
1007 int UtcDaliToolkitTextlabelEllipsis(void)
1009 ToolkitTestApplication application;
1010 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1012 TextLabel label = TextLabel::New("Hello world");
1013 DALI_TEST_CHECK( label );
1015 // Avoid a crash when core load gl resources.
1016 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1018 Stage::GetCurrent().Add( label );
1020 // Turn on all the effects
1021 label.SetAnchorPoint( AnchorPoint::CENTER );
1022 label.SetParentOrigin( ParentOrigin::CENTER );
1023 label.SetSize( 360.0f, 10.f );
1028 application.SendNotification();
1029 application.Render();
1033 tet_result(TET_FAIL);
1039 int UtcDaliToolkitTextlabelTextWrapMode(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1046 TextLabel label = TextLabel::New();
1047 label.SetSize( 300.0f, 300.f );
1048 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1049 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1053 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1054 Stage::GetCurrent().Add( label );
1056 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1057 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1059 application.SendNotification();
1060 application.Render();
1062 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1063 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1065 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1066 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1068 application.SendNotification();
1069 application.Render();
1071 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1072 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1074 application.SendNotification();
1075 application.Render();
1077 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1078 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
1080 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1081 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1083 application.SendNotification();
1084 application.Render();
1086 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1087 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1089 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1090 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1091 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1096 int UtcDaliToolkitTextLabelColorComponents(void)
1098 ToolkitTestApplication application;
1100 TextLabel label = TextLabel::New();
1101 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1102 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1103 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1104 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1105 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1107 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1108 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1109 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1110 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1111 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1113 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1114 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1115 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1116 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1117 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1119 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1120 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1121 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1122 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1127 int UtcDaliToolkitTextlabelTextStyle01(void)
1129 ToolkitTestApplication application;
1130 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1132 TextLabel label = TextLabel::New();
1133 label.SetSize( 300.0f, 300.f );
1134 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1135 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1136 Stage::GetCurrent().Add( label );
1138 Property::Map outlineMapSet;
1139 Property::Map outlineMapGet;
1141 outlineMapSet["color"] = Color::BLUE;
1142 outlineMapSet["width"] = 2.0f;
1143 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1145 application.SendNotification();
1146 application.Render();
1148 Property::Map shadowMapSet;
1149 shadowMapSet.Insert( "color", "green" );
1150 shadowMapSet.Insert( "offset", "2 2" );
1151 shadowMapSet.Insert( "blurRadius", "3" );
1152 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1154 outlineMapSet["color"] = Color::RED;
1155 outlineMapSet["width"] = 0.0f;
1156 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1158 application.SendNotification();
1159 application.Render();
1161 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1163 Property::Value* colorValue = outlineMapGet.Find("color");
1165 bool colorMatched( false );
1169 Property::Type valueType = colorValue->GetType();
1171 if ( Property::STRING == valueType )
1173 std::string stringValue;
1174 colorValue->Get( stringValue );
1175 if ( stringValue == "red" )
1177 colorMatched = true;
1180 else if ( Property::VECTOR4 == valueType )
1182 Vector4 colorVector4;
1183 colorValue->Get( colorVector4 );
1184 if ( colorVector4 == Color::RED )
1186 colorMatched = true;
1191 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1196 int UtcDaliToolkitTextlabelMultiline(void)
1198 ToolkitTestApplication application;
1199 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1201 TextLabel label = TextLabel::New();
1202 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1203 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1204 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1205 Stage::GetCurrent().Add( label );
1207 application.SendNotification();
1208 application.Render();
1210 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1211 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1213 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1215 application.SendNotification();
1216 application.Render();
1218 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1219 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1225 int UtcDaliToolkitTextlabelTextDirection(void)
1227 ToolkitTestApplication application;
1228 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1230 TextLabel label = TextLabel::New();
1231 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1233 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1234 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1235 Stage::GetCurrent().Add( label );
1237 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1239 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1240 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1245 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1247 ToolkitTestApplication application;
1248 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1250 TextLabel label = TextLabel::New();
1252 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1253 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1254 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1255 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1256 Stage::GetCurrent().Add( label );
1257 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1259 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1260 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1262 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1263 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );