2 * Copyright (c) 2019 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/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
33 using namespace Toolkit;
35 void dali_textlabel_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_textlabel_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
51 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
52 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
53 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
56 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
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";
68 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
70 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
71 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
72 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
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& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
79 const Property::Map::SizeType size = mapGet.Count();
81 if( size == mapSet.Count() )
83 for( unsigned int index = 0u; index < size; ++index )
85 const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
87 // Find the keys of the 'get' map
88 Property::Index indexKey = valueGet.first.indexKey;
89 std::string stringKey = valueGet.first.stringKey;
91 if( !indexConversionTable.empty() )
93 if( stringKey.empty() )
95 stringKey = indexConversionTable[ indexKey ];
98 if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
100 Property::Index index = 0u;
101 for( auto key : indexConversionTable )
103 if( key == stringKey )
113 const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
115 if( nullptr != valueSet )
117 if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
119 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
122 else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
124 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
127 else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
129 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
132 else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
134 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
137 else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
139 Vector2 vector2Get = valueGet.second.Get<Vector2>();
140 Vector2 vector2Set = valueSet->Get<Vector2>();
141 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
144 else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
146 Vector4 vector4Get = valueGet.second.Get<Vector4>();
147 Vector4 vector4Set = valueSet->Get<Vector4>();
148 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 );
154 if ( valueGet.first.type == Property::Key::INDEX )
156 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
160 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
172 int UtcDaliToolkitTextLabelConstructorP(void)
174 ToolkitTestApplication application;
175 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
177 DALI_TEST_CHECK( !textLabel );
181 int UtcDaliToolkitTextLabelNewP(void)
183 ToolkitTestApplication application;
184 tet_infoline(" UtcDaliToolkitTextLabelNewP");
185 TextLabel textLabel = TextLabel::New( "Test Text" );
186 DALI_TEST_CHECK( textLabel );
190 int UtcDaliToolkitTextLabelDownCastP(void)
192 ToolkitTestApplication application;
193 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
194 TextLabel textLabel1 = TextLabel::New();
195 BaseHandle object( textLabel1 );
197 TextLabel textLabel2 = TextLabel::DownCast( object );
198 DALI_TEST_CHECK( textLabel2 );
200 TextLabel textLabel3 = DownCast< TextLabel >( object );
201 DALI_TEST_CHECK( textLabel3 );
205 int UtcDaliToolkitTextLabelDownCastN(void)
207 ToolkitTestApplication application;
208 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
209 BaseHandle uninitializedObject;
210 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
211 DALI_TEST_CHECK( !textLabel1 );
213 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
214 DALI_TEST_CHECK( !textLabel2 );
218 int UtcDaliToolkitTextLabelCopyConstructorP(void)
220 ToolkitTestApplication application;
221 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
222 TextLabel textLabel = TextLabel::New();
223 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
225 TextLabel copy( textLabel );
226 DALI_TEST_CHECK( copy );
227 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
231 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
233 ToolkitTestApplication application;
234 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
235 TextLabel textLabel = TextLabel::New();
236 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
238 TextLabel copy = textLabel;
239 DALI_TEST_CHECK( copy );
240 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
244 // Positive test case for a method
245 int UtcDaliToolkitTextLabelGetPropertyP(void)
247 ToolkitTestApplication application;
248 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
249 TextLabel label = TextLabel::New("Test Text");
250 DALI_TEST_CHECK( label );
252 // Check Property Indices are correct
253 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
254 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
255 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
256 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
257 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
258 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
259 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
260 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
261 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
262 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
263 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
264 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
265 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
266 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
267 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
268 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
269 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
270 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
271 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
272 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
273 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
274 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
275 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
280 int UtcDaliToolkitTextLabelSetPropertyP(void)
282 ToolkitTestApplication application;
283 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
284 TextLabel label = TextLabel::New();
285 DALI_TEST_CHECK( label );
287 Stage::GetCurrent().Add( label );
289 // Note - we can't check the defaults since the stylesheets are platform-specific
290 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
291 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
293 // Check that text can be correctly reset
294 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
295 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
297 // Check font properties.
298 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
299 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
301 Property::Map fontStyleMapSet;
302 Property::Map fontStyleMapGet;
304 fontStyleMapSet.Insert( "weight", "bold" );
305 fontStyleMapSet.Insert( "width", "condensed" );
306 fontStyleMapSet.Insert( "slant", "italic" );
307 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
309 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
310 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
311 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
313 // Check the old font style format.
314 fontStyleMapSet.Clear();
315 fontStyleMapSet.Insert( "weight", "thin" );
316 fontStyleMapSet.Insert( "width", "expanded" );
317 fontStyleMapSet.Insert( "slant", "oblique" );
318 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
320 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
321 std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
322 DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
324 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
325 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
328 fontStyleMapSet.Clear();
329 fontStyleMapSet.Insert( "weight", "normal" );
330 fontStyleMapSet.Insert( "slant", "oblique" );
332 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
333 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
334 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
335 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
337 fontStyleMapSet.Clear();
338 fontStyleMapSet.Insert( "slant", "roman" );
340 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
341 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
342 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
344 // Replace 'roman' for 'normal'.
345 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
346 if( NULL != slantValue )
348 if( "normal" == slantValue->Get<std::string>() )
350 fontStyleMapGet["slant"] = "roman";
353 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
355 fontStyleMapSet.Clear();
357 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
358 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
359 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
360 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
363 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
364 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
366 // Check that the Alignment properties can be correctly set
367 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
368 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
369 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
370 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
372 // Check that text color can be properly set
373 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
374 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
376 Property::Map underlineMapSet;
377 Property::Map underlineMapGet;
379 underlineMapSet.Insert( "enable", false );
380 underlineMapSet.Insert( "color", Color::BLUE );
381 underlineMapSet.Insert( "height", 0 );
383 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
384 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
385 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
387 TextLabel label2 = TextLabel::New( "New text" );
388 DALI_TEST_CHECK( label2 );
389 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
391 // Check the enable markup property.
392 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
393 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
394 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
396 // Check the text property when markup is enabled
397 label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
398 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
400 // Check for incomplete marks.
401 label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
402 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
405 application.SendNotification();
406 application.Render();
410 tet_result(TET_FAIL);
413 // Check autoscroll properties
414 const int SCROLL_SPEED = 80;
415 const int SCROLL_LOOPS = 4;
416 const float SCROLL_GAP = 50.0f;
417 const float SCROLL_LOOP_DELAY = 0.3f;
418 const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
419 const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
421 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
422 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
423 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
424 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
425 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
426 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
427 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
428 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
429 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
430 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
431 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
432 DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
434 //Check autoscroll stop type property
435 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
436 DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
438 label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
439 DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
441 // test natural size with multi-line and line spacing
443 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
444 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
445 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
446 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
447 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
449 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
450 // The height of the text when multi-line is enabled will be larger
451 DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
452 DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
454 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
455 // Everything else will remain the same
456 int lineSpacing = 20;
457 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
458 Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
459 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
460 DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
463 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
465 TextLabel label3 = TextLabel::New("Some text here end there end here");
466 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
467 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
468 Vector3 textNaturalSize = label3.GetNaturalSize();
469 int lineSpacing = 20;
470 label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
471 Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
472 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
473 DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
475 // Check the line spacing property
476 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
477 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
478 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
480 // Check the underline property
481 underlineMapSet.Clear();
482 underlineMapSet.Insert( "enable", true );
483 underlineMapSet.Insert( "color", Color::RED );
484 underlineMapSet.Insert( "height", 1 );
486 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
488 application.SendNotification();
489 application.Render();
491 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
492 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
493 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
495 underlineMapSet.Clear();
496 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
497 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
498 underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
500 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
502 application.SendNotification();
503 application.Render();
505 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
506 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
507 std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
508 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
510 underlineMapSet.Clear();
512 Property::Map underlineDisabledMapGet;
513 underlineDisabledMapGet.Insert( "enable", false );
514 underlineDisabledMapGet.Insert( "color", Color::GREEN );
515 underlineDisabledMapGet.Insert( "height", 2 );
517 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
519 application.SendNotification();
520 application.Render();
522 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
523 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
524 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
526 // Check the shadow property
528 Property::Map shadowMapSet;
529 Property::Map shadowMapGet;
531 shadowMapSet.Insert( "color", Color::GREEN );
532 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
533 shadowMapSet.Insert( "blurRadius", 5.0f );
535 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
537 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
538 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
539 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
541 shadowMapSet.Clear();
543 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
544 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
545 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
547 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
549 // Replace the offset (string) by a vector2
550 shadowMapSet.Clear();
551 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
552 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
553 shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
555 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
556 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
557 std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
558 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
560 shadowMapSet.Clear();
561 Property::Map shadowDisabledMapGet;
562 shadowDisabledMapGet.Insert( "color", Color::BLUE );
563 shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
564 shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
566 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
568 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
569 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
570 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
572 // Check the emboss property
573 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
574 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
576 // Check the outline property
578 // Test string type first
579 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
580 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
581 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
583 // Then test the property map type
584 Property::Map outlineMapSet;
585 Property::Map outlineMapGet;
587 outlineMapSet["color"] = Color::RED;
588 outlineMapSet["width"] = 2.0f;
589 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
591 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
592 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
593 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
595 outlineMapSet.Clear();
596 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
597 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
598 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
600 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
601 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
602 std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
603 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
605 // Check the background property
606 Property::Map backgroundMapSet;
607 Property::Map backgroundMapGet;
609 backgroundMapSet["enable"] = true;
610 backgroundMapSet["color"] = Color::RED;
611 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
613 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
614 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
617 backgroundMapSet.Clear();
618 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
619 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
620 label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
622 backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
623 DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
624 std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
625 DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
627 // Check the pixel size of font
628 label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
629 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 // Check the ellipsis property
632 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
633 label.SetProperty( TextLabel::Property::ELLIPSIS, false );
634 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
636 // Check the layout direction property
637 label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
638 DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
640 application.SendNotification();
641 application.Render();
646 int UtcDaliToolkitTextlabelAtlasRenderP(void)
648 ToolkitTestApplication application;
649 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
650 TextLabel label = TextLabel::New("Test Text");
651 DALI_TEST_CHECK( label );
653 // Avoid a crash when core load gl resources.
654 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
656 Stage::GetCurrent().Add( label );
658 // Turn on all the effects
659 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
660 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
662 Property::Map underlineMap;
663 underlineMap.Insert( "enable", true );
664 underlineMap.Insert( "color", Color::RED );
665 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
667 Property::Map shadowMap;
668 shadowMap.Insert( "color", Color::BLUE );
669 shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
670 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
674 // Render some text with the shared atlas backend
675 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
676 application.SendNotification();
677 application.Render();
681 tet_result(TET_FAIL);
686 // Render some text with the shared atlas backend
687 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
688 application.SendNotification();
689 application.Render();
693 tet_result(TET_FAIL);
698 int UtcDaliToolkitTextLabelLanguagesP(void)
700 ToolkitTestApplication application;
701 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
702 TextLabel label = TextLabel::New();
703 DALI_TEST_CHECK( label );
705 Stage::GetCurrent().Add( label );
707 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
708 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
709 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
710 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
711 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
712 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
714 label.SetProperty( TextLabel::Property::TEXT, scripts );
715 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
717 application.SendNotification();
718 application.Render();
723 int UtcDaliToolkitTextLabelEmojisP(void)
725 ToolkitTestApplication application;
726 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
727 TextLabel label = TextLabel::New();
728 DALI_TEST_CHECK( label );
730 Stage::GetCurrent().Add( label );
732 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
734 char* pathNamePtr = get_current_dir_name();
735 const std::string pathName( pathNamePtr );
738 TextAbstraction::FontDescription fontDescription;
739 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
740 fontDescription.family = "BreezeColorEmoji";
741 fontDescription.width = TextAbstraction::FontWidth::NONE;
742 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
743 fontDescription.slant = TextAbstraction::FontSlant::NONE;
745 fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
747 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>";
748 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
749 label.SetProperty( TextLabel::Property::TEXT, emojis );
751 Property::Map shadowMap;
752 shadowMap.Insert( "color", "green" );
753 shadowMap.Insert( "offset", "2 2" );
754 label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
756 application.SendNotification();
757 application.Render();
762 int UtcDaliToolkitTextlabelScrollingP(void)
764 ToolkitTestApplication application;
765 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
766 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
767 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
769 DALI_TEST_CHECK( labelImmediate );
770 DALI_TEST_CHECK( labelFinished );
771 // Avoid a crash when core load gl resources.
772 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
773 Stage::GetCurrent().Add( labelImmediate );
774 // Turn on all the effects
775 labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
776 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
777 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
778 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
779 labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
781 Stage::GetCurrent().Add( labelFinished );
782 // Turn on all the effects
783 labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
784 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
785 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
786 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
787 labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
793 // Render some text with the shared atlas backend
794 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
795 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
797 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
798 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
800 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
802 application.SendNotification();
803 application.Render();
805 labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
806 labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
807 application.SendNotification();
808 application.Render();
813 tet_result(TET_FAIL);
819 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
821 ToolkitTestApplication application;
822 TextLabel labelShort = TextLabel::New("Some text to scroll");
823 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!");
825 DALI_TEST_CHECK( labelShort );
826 DALI_TEST_CHECK( labelLong );
827 // Avoid a crash when core load gl resources.
828 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
829 Stage::GetCurrent().Add( labelShort );
830 // Turn on all the effects
831 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
832 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
833 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
834 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
835 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
836 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
838 Stage::GetCurrent().Add( labelLong );
839 // Turn on all the effects
840 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
841 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
842 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
843 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
844 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
845 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
849 // Render some text with the shared atlas backend
850 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
851 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
852 application.SendNotification();
853 application.Render();
855 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
856 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
857 application.SendNotification();
858 application.Render();
863 tet_result(TET_FAIL);
869 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
871 ToolkitTestApplication application;
872 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
873 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
875 DALI_TEST_CHECK( labelShort );
876 DALI_TEST_CHECK( labelLong );
877 // Avoid a crash when core load gl resources.
878 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
879 Stage::GetCurrent().Add( labelShort );
880 // Turn on all the effects
881 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
882 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
883 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
884 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
885 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
886 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
888 Stage::GetCurrent().Add( labelLong );
889 // Turn on all the effects
890 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
891 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
892 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
893 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
894 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
895 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
899 // Render some text with the shared atlas backend
900 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
901 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
902 application.SendNotification();
903 application.Render();
905 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
906 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
907 application.SendNotification();
908 application.Render();
913 tet_result(TET_FAIL);
919 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
921 ToolkitTestApplication application;
922 TextLabel labelShort = TextLabel::New("Some text to scroll");
923 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!");
925 DALI_TEST_CHECK( labelShort );
926 DALI_TEST_CHECK( labelLong );
927 // Avoid a crash when core load gl resources.
928 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
929 Stage::GetCurrent().Add( labelShort );
930 // Turn on all the effects
931 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
932 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
933 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
934 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
935 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
936 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
938 Stage::GetCurrent().Add( labelLong );
939 // Turn on all the effects
940 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
941 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
942 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
943 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
944 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
945 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
949 // Render some text with the shared atlas backend
950 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
951 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
952 application.SendNotification();
953 application.Render();
955 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
956 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
957 application.SendNotification();
958 application.Render();
963 tet_result(TET_FAIL);
969 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
971 ToolkitTestApplication application;
972 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
973 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
975 DALI_TEST_CHECK( labelShort );
976 DALI_TEST_CHECK( labelLong );
977 // Avoid a crash when core load gl resources.
978 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
979 Stage::GetCurrent().Add( labelShort );
980 // Turn on all the effects
981 labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
982 labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
983 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
984 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
985 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
986 labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
988 Stage::GetCurrent().Add( labelLong );
989 // Turn on all the effects
990 labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
991 labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
992 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
993 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
994 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
995 labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
999 // Render some text with the shared atlas backend
1000 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1001 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1002 application.SendNotification();
1003 application.Render();
1005 labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1006 labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1007 application.SendNotification();
1008 application.Render();
1013 tet_result(TET_FAIL);
1019 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1021 ToolkitTestApplication application;
1022 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1023 TextLabel label = TextLabel::New("Some text to scroll");
1024 DALI_TEST_CHECK( label );
1025 // Avoid a crash when core load gl resources.
1026 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1027 Stage::GetCurrent().Add( label );
1028 label.SetSize( 360.0f, 20.f );
1029 // Turn on all the effects
1030 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1031 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1032 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1033 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1036 application.SendNotification();
1037 application.Render();
1039 unsigned int actorCount1 = label.GetChildCount();
1040 tet_printf("Initial actor count is(%d)\n", actorCount1 );
1044 // Render some text with the shared atlas backend
1045 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1046 application.SendNotification();
1047 application.Render(2000);
1049 unsigned int actorCount1 = label.GetChildCount();
1050 tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1052 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1055 application.SendNotification();
1056 application.Render();
1058 unsigned int actorCount2 = label.GetChildCount();
1059 tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1061 DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1066 tet_result(TET_FAIL);
1072 int UtcDaliToolkitTextlabelScrollingN(void)
1074 ToolkitTestApplication application;
1075 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1077 TextLabel label = TextLabel::New("Some text to scroll");
1078 DALI_TEST_CHECK( label );
1080 Stage::GetCurrent().Add( label );
1082 // Avoid a crash when core load gl resources.
1083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1085 // The text scrolling works only on single line text.
1086 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1088 // Turn on all the effects.
1089 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1090 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1091 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1093 // Enable the auto scrolling effect.
1094 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1096 // The auto scrolling shouldn't be enabled.
1097 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1098 DALI_TEST_CHECK( !enabled );
1103 int UtcDaliToolkitTextlabelEllipsis(void)
1105 ToolkitTestApplication application;
1106 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1108 TextLabel label = TextLabel::New("Hello world");
1109 DALI_TEST_CHECK( label );
1111 // Avoid a crash when core load gl resources.
1112 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1114 Stage::GetCurrent().Add( label );
1116 // Turn on all the effects
1117 label.SetAnchorPoint( AnchorPoint::CENTER );
1118 label.SetParentOrigin( ParentOrigin::CENTER );
1119 label.SetSize( 360.0f, 10.f );
1124 application.SendNotification();
1125 application.Render();
1129 tet_result(TET_FAIL);
1132 label.SetProperty( TextLabel::Property::TEXT, "Hello world " );
1133 label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1134 label.SetSize( 400.0f, 10.f );
1139 application.SendNotification();
1140 application.Render();
1144 tet_result(TET_FAIL);
1148 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1149 label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1150 label.SetSize( 400.0f, 10.f );
1155 application.SendNotification();
1156 application.Render();
1160 tet_result(TET_FAIL);
1166 int UtcDaliToolkitTextlabelTextWrapMode(void)
1168 ToolkitTestApplication application;
1169 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1173 TextLabel label = TextLabel::New();
1174 label.SetSize( 300.0f, 300.f );
1175 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1176 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1180 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1181 Stage::GetCurrent().Add( label );
1183 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1184 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1186 application.SendNotification();
1187 application.Render();
1189 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1190 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1192 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1193 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1195 application.SendNotification();
1196 application.Render();
1198 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1199 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1201 application.SendNotification();
1202 application.Render();
1204 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1205 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1207 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1208 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1210 application.SendNotification();
1211 application.Render();
1213 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1214 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1216 tet_infoline( "Ensure invalid string does not change wrapping mode" );
1217 label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1218 DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1223 int UtcDaliToolkitTextLabelColorComponents(void)
1225 ToolkitTestApplication application;
1227 TextLabel label = TextLabel::New();
1228 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1229 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 1.0f, TEST_LOCATION );
1230 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1231 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1232 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1234 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1235 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1237 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 0.0f, TEST_LOCATION );
1238 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1240 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1241 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ), 0.0f, TEST_LOCATION );
1242 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1243 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ), 1.0f, TEST_LOCATION );
1244 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1246 label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1247 DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1248 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1249 DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1251 // Test a transparent text - Rendering should be skipped.
1252 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1253 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1255 Stage::GetCurrent().Add( label );
1257 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1258 drawTrace.Enable( true );
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered
1265 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1269 application.SendNotification();
1270 application.Render();
1272 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1274 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1278 application.SendNotification();
1279 application.Render();
1281 DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1286 int UtcDaliToolkitTextlabelTextStyle01(void)
1288 ToolkitTestApplication application;
1289 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1291 TextLabel label = TextLabel::New();
1292 label.SetSize( 300.0f, 300.f );
1293 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1294 label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1295 Stage::GetCurrent().Add( label );
1297 Property::Map outlineMapSet;
1298 Property::Map outlineMapGet;
1300 outlineMapSet["color"] = Color::BLUE;
1301 outlineMapSet["width"] = 2.0f;
1302 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1304 application.SendNotification();
1305 application.Render();
1307 Property::Map shadowMapSet;
1308 shadowMapSet.Insert( "color", "green" );
1309 shadowMapSet.Insert( "offset", "2 2" );
1310 shadowMapSet.Insert( "blurRadius", "3" );
1311 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1313 outlineMapSet["color"] = Color::RED;
1314 outlineMapSet["width"] = 0.0f;
1315 label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1317 application.SendNotification();
1318 application.Render();
1320 outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1322 Property::Value* colorValue = outlineMapGet.Find("color");
1324 bool colorMatched( false );
1328 Property::Type valueType = colorValue->GetType();
1330 if ( Property::STRING == valueType )
1332 std::string stringValue;
1333 colorValue->Get( stringValue );
1334 if ( stringValue == "red" )
1336 colorMatched = true;
1339 else if ( Property::VECTOR4 == valueType )
1341 Vector4 colorVector4;
1342 colorValue->Get( colorVector4 );
1343 if ( colorVector4 == Color::RED )
1345 colorMatched = true;
1350 DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1355 int UtcDaliToolkitTextlabelMultiline(void)
1357 ToolkitTestApplication application;
1358 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1360 TextLabel label = TextLabel::New();
1361 label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1362 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1363 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1364 Stage::GetCurrent().Add( label );
1366 application.SendNotification();
1367 application.Render();
1369 int lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1370 DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1372 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1374 application.SendNotification();
1375 application.Render();
1377 lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1378 DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1384 int UtcDaliToolkitTextlabelTextDirection(void)
1386 ToolkitTestApplication application;
1387 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1389 TextLabel label = TextLabel::New();
1390 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1392 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1393 label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1394 Stage::GetCurrent().Add( label );
1397 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1400 label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1401 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1403 // Test RTL text starting with weak character
1404 label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1405 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1407 // Test RTL text string with emoji and weak character
1408 label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1409 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1414 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1416 ToolkitTestApplication application;
1417 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1419 TextLabel label = TextLabel::New();
1421 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP );
1422 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1423 label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1424 label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1425 Stage::GetCurrent().Add( label );
1426 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1428 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE );
1429 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1431 label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM );
1432 DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1437 int UtcDaliToolkitTextLabelBitmapFont(void)
1439 ToolkitTestApplication application;
1440 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1442 DevelText::BitmapFontDescription fontDescription;
1443 fontDescription.name = "Digits";
1444 fontDescription.underlinePosition = 0.f;
1445 fontDescription.underlineThickness = 0.f;
1447 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1448 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1449 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1450 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1451 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1452 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1453 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1454 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1455 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1456 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1457 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1459 TextAbstraction::BitmapFont bitmapFont;
1460 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1462 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1463 fontClient.GetFontId( bitmapFont );
1465 TextLabel label = TextLabel::New();
1467 label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1468 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1470 // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1471 DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1473 Stage::GetCurrent().Add( label );
1475 application.SendNotification();
1476 application.Render();
1478 // The text has been rendered if the height of the text-label is the height of the line.
1479 DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1484 int ConvertPointToPixel( float point )
1486 unsigned int horizontalDpi = 0u;
1487 unsigned int verticalDpi = 0u;
1488 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1489 fontClient.GetDpi( horizontalDpi, verticalDpi );
1491 return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1494 int UtcDaliToolkitTextlabelTextFit(void)
1496 ToolkitTestApplication application;
1497 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1498 TextLabel label = TextLabel::New();
1499 Vector2 size( 460.0f, 100.0f );
1500 label.SetSize( size );
1501 label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1504 Property::Map textFitMapSet;
1505 textFitMapSet["enable"] = true;
1506 textFitMapSet["minSize"] = 10.f;
1507 textFitMapSet["maxSize"] = 100.f;
1508 textFitMapSet["stepSize"] = -1.f;
1509 textFitMapSet["fontSizeType"] = "pointSize";
1511 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1512 label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1514 Stage::GetCurrent().Add( label );
1516 application.SendNotification();
1517 application.Render();
1519 const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
1520 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1523 textFitMapSet.Clear();
1524 textFitMapSet["enable"] = true;
1525 textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1526 textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1527 textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1528 textFitMapSet["fontSizeType"] = "pixelSize";
1530 label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1532 application.SendNotification();
1533 application.Render();
1535 DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1540 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1542 ToolkitTestApplication application;
1543 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1545 DevelText::BitmapFontDescription fontDescription;
1546 fontDescription.name = "Digits";
1547 fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1549 TextAbstraction::BitmapFont bitmapFont;
1550 DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1552 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1553 fontClient.GetFontId( bitmapFont );
1555 TextLabel label = TextLabel::New();
1556 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1557 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1558 label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1559 label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1560 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1562 Property::Map underlineMapSet;
1563 underlineMapSet.Clear();
1564 underlineMapSet.Insert( "enable", true );
1565 underlineMapSet.Insert( "color", Color::RED );
1566 underlineMapSet.Insert( "height", 1 );
1567 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1568 label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1570 Stage::GetCurrent().Add( label );
1572 application.SendNotification();
1573 application.Render();
1575 const int maxTextureSize = Dali::GetMaxTextureSize();
1576 // Whether the rendered text is greater than maxTextureSize
1577 DALI_TEST_CHECK( label.GetCurrentSize().height > maxTextureSize );
1579 // Check if the number of renderers is greater than 1.
1580 DALI_TEST_CHECK( label.GetRendererCount() > 1u );