96fcb630a284dec0ee29bea15d8698137c0b765b
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
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-toolkit/devel-api/text/bitmap-font.h>
29
30 using namespace Dali;
31 using namespace Toolkit;
32
33 void dali_textlabel_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void dali_textlabel_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43 namespace
44 {
45
46 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
47 const char* const PROPERTY_NAME_TEXT = "text";
48 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
49 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
50 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
51 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
52 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
53 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
54 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
55 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
60
61 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
62 const char* const PROPERTY_NAME_UNDERLINE = "underline";
63 const char* const PROPERTY_NAME_SHADOW = "shadow";
64 const char* const PROPERTY_NAME_EMBOSS = "emboss";
65 const char* const PROPERTY_NAME_OUTLINE = "outline";
66 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
67
68 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
69 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
70 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
71
72 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
73 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
74
75 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
76 {
77   const Property::Map::SizeType size = mapGet.Count();
78
79   if( size == mapSet.Count() )
80   {
81     for( unsigned int index = 0u; index < size; ++index )
82     {
83       const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
84
85       // Find the keys of the 'get' map
86       Property::Index indexKey = valueGet.first.indexKey;
87       std::string stringKey = valueGet.first.stringKey;
88
89       if( !indexConversionTable.empty() )
90       {
91         if( stringKey.empty() )
92         {
93           stringKey = indexConversionTable[ indexKey ];
94         }
95
96         if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
97         {
98           Property::Index index = 0u;
99           for( auto key : indexConversionTable )
100           {
101             if( key == stringKey )
102             {
103               indexKey = index;
104               break;
105             }
106             ++index;
107           }
108         }
109       }
110
111       const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
112
113       if( nullptr != valueSet )
114       {
115         if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
116         {
117           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
118           return false;
119         }
120         else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
121         {
122           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
123           return false;
124         }
125         else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
126         {
127           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
128           return false;
129         }
130         else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
131         {
132           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
133           return false;
134         }
135         else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
136         {
137           Vector2 vector2Get = valueGet.second.Get<Vector2>();
138           Vector2 vector2Set = valueSet->Get<Vector2>();
139           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
140           return false;
141         }
142         else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
143         {
144           Vector4 vector4Get = valueGet.second.Get<Vector4>();
145           Vector4 vector4Set = valueSet->Get<Vector4>();
146           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 );
147           return false;
148         }
149       }
150       else
151       {
152         if ( valueGet.first.type == Property::Key::INDEX )
153         {
154           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
155         }
156         else
157         {
158           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
159         }
160         return false;
161       }
162     }
163   }
164
165   return true;
166 }
167
168 } // namespace
169
170 int UtcDaliToolkitTextLabelConstructorP(void)
171 {
172   ToolkitTestApplication application;
173   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
174   TextLabel textLabel;
175   DALI_TEST_CHECK( !textLabel );
176   END_TEST;
177 }
178
179 int UtcDaliToolkitTextLabelNewP(void)
180 {
181   ToolkitTestApplication application;
182   tet_infoline(" UtcDaliToolkitTextLabelNewP");
183   TextLabel textLabel = TextLabel::New( "Test Text" );
184   DALI_TEST_CHECK( textLabel );
185   END_TEST;
186 }
187
188 int UtcDaliToolkitTextLabelDownCastP(void)
189 {
190   ToolkitTestApplication application;
191   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
192   TextLabel textLabel1 = TextLabel::New();
193   BaseHandle object( textLabel1 );
194
195   TextLabel textLabel2 = TextLabel::DownCast( object );
196   DALI_TEST_CHECK( textLabel2 );
197
198   TextLabel textLabel3 = DownCast< TextLabel >( object );
199   DALI_TEST_CHECK( textLabel3 );
200   END_TEST;
201 }
202
203 int UtcDaliToolkitTextLabelDownCastN(void)
204 {
205   ToolkitTestApplication application;
206   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
207   BaseHandle uninitializedObject;
208   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
209   DALI_TEST_CHECK( !textLabel1 );
210
211   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
212   DALI_TEST_CHECK( !textLabel2 );
213   END_TEST;
214 }
215
216 int UtcDaliToolkitTextLabelCopyConstructorP(void)
217 {
218   ToolkitTestApplication application;
219   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
220   TextLabel textLabel = TextLabel::New();
221   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
222
223   TextLabel copy( textLabel );
224   DALI_TEST_CHECK( copy );
225   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
226   END_TEST;
227 }
228
229 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
230 {
231   ToolkitTestApplication application;
232   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
233   TextLabel textLabel = TextLabel::New();
234   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
235
236   TextLabel copy = textLabel;
237   DALI_TEST_CHECK( copy );
238   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
239   END_TEST;
240 }
241
242 // Positive test case for a method
243 int UtcDaliToolkitTextLabelGetPropertyP(void)
244 {
245   ToolkitTestApplication application;
246   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
247   TextLabel label = TextLabel::New("Test Text");
248   DALI_TEST_CHECK( label );
249
250   // Check Property Indices are correct
251   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
252   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
253   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
254   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
255   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
256   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
257   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
258   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
259   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
260   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
261   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
262   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
263   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
264   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
265   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
266   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
267   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
268   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
269   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
270   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
271   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
272   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
273   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
274
275   END_TEST;
276 }
277
278 int UtcDaliToolkitTextLabelSetPropertyP(void)
279 {
280   ToolkitTestApplication application;
281   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
282   TextLabel label = TextLabel::New();
283   DALI_TEST_CHECK( label );
284
285   Stage::GetCurrent().Add( label );
286
287   // Note - we can't check the defaults since the stylesheets are platform-specific
288   label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
289   DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
290
291   // Check that text can be correctly reset
292   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
293   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
294
295   // Check font properties.
296   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
297   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
298
299   Property::Map fontStyleMapSet;
300   Property::Map fontStyleMapGet;
301
302   fontStyleMapSet.Insert( "weight", "bold" );
303   fontStyleMapSet.Insert( "width", "condensed" );
304   fontStyleMapSet.Insert( "slant", "italic" );
305   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
306
307   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
308   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
309   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
310
311   // Check the old font style format.
312   fontStyleMapSet.Clear();
313   fontStyleMapSet.Insert( "weight", "thin" );
314   fontStyleMapSet.Insert( "width", "expanded" );
315   fontStyleMapSet.Insert( "slant", "oblique" );
316   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
317
318   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
319   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
320   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
321
322   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
323   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
324
325   // Reset font style.
326   fontStyleMapSet.Clear();
327   fontStyleMapSet.Insert( "weight", "normal" );
328   fontStyleMapSet.Insert( "slant", "oblique" );
329
330   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
331   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
332   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
333   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
334
335   fontStyleMapSet.Clear();
336   fontStyleMapSet.Insert( "slant", "roman" );
337
338   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
339   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
340   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
341
342   // Replace 'roman' for 'normal'.
343   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
344   if( NULL != slantValue )
345   {
346     if( "normal" == slantValue->Get<std::string>() )
347     {
348       fontStyleMapGet["slant"] = "roman";
349     }
350   }
351   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
352
353   fontStyleMapSet.Clear();
354
355   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
356   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
357   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
358   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
359
360   // Toggle multi-line
361   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
362   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
363
364   // Check that the Alignment properties can be correctly set
365   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
366   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
367   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
368   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
369
370   // Check that text color can be properly set
371   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
372   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
373
374   Property::Map underlineMapSet;
375   Property::Map underlineMapGet;
376
377   underlineMapSet.Insert( "enable", false );
378   underlineMapSet.Insert( "color", Color::BLUE );
379   underlineMapSet.Insert( "height", 0 );
380
381   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
382   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
383   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
384
385   TextLabel label2 = TextLabel::New( "New text" );
386   DALI_TEST_CHECK( label2 );
387   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
388
389   // Check the enable markup property.
390   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
391   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
392   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
393
394   // Check the text property when markup is enabled
395   label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
396   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
397
398   application.SendNotification();
399   application.Render();
400
401   // Check autoscroll properties
402   const int SCROLL_SPEED = 80;
403   const int SCROLL_LOOPS = 4;
404   const float SCROLL_GAP = 50.0f;
405   const float SCROLL_LOOP_DELAY = 0.3f;
406   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
407   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
408
409   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
410   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
411   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
412   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
413   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
414   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
415   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
416   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
417   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
418   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
419   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
420   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
421
422   //Check autoscroll stop type property
423   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
424   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
425
426   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
427   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
428
429   // test natural size with multi-line and line spacing
430   {
431     TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
432     Vector3 oneLineNaturalSize = label3.GetNaturalSize();
433     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
434     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
435     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
436
437     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
438     // The height of the text when multi-line is enabled will be larger
439     DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
440     DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
441
442     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
443     // Everything else will remain the same
444     int lineSpacing = 20;
445     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
446     Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
447     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
448     DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
449   }
450
451   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
452   {
453     TextLabel label3 = TextLabel::New("Some text here end there end here");
454     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
455     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
456     Vector3 textNaturalSize = label3.GetNaturalSize();
457     int lineSpacing = 20;
458     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
459     Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
460     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
461     DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
462   }
463   // Check the line spacing property
464   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
465   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
466   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
467
468   // Check the underline property
469   underlineMapSet.Clear();
470   underlineMapSet.Insert( "enable", true );
471   underlineMapSet.Insert( "color", Color::RED );
472   underlineMapSet.Insert( "height", 1 );
473
474   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
475
476   application.SendNotification();
477   application.Render();
478
479   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
480   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
481   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
482
483   underlineMapSet.Clear();
484   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
485   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
486   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
487
488   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
489
490   application.SendNotification();
491   application.Render();
492
493   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
494   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
495   std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
496   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
497
498   underlineMapSet.Clear();
499
500   Property::Map underlineDisabledMapGet;
501   underlineDisabledMapGet.Insert( "enable", false );
502   underlineDisabledMapGet.Insert( "color", Color::GREEN );
503   underlineDisabledMapGet.Insert( "height", 2 );
504
505   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
506
507   application.SendNotification();
508   application.Render();
509
510   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
511   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
512   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
513
514   // Check the shadow property
515
516   Property::Map shadowMapSet;
517   Property::Map shadowMapGet;
518
519   shadowMapSet.Insert( "color", Color::GREEN );
520   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
521   shadowMapSet.Insert( "blurRadius", 5.0f );
522
523   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
524
525   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
526   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
527   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
528
529   shadowMapSet.Clear();
530
531   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
532   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
533   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
534
535   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
536
537   // Replace the offset (string) by a vector2
538   shadowMapSet.Clear();
539   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
540   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
541   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
542
543   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
544   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
545   std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
546   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
547
548   shadowMapSet.Clear();
549   Property::Map shadowDisabledMapGet;
550   shadowDisabledMapGet.Insert( "color", Color::BLUE );
551   shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
552   shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
553
554   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
555
556   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
557   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
558   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
559
560   // Check the emboss property
561   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
562   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
563
564   // Check the outline property
565
566   // Test string type first
567   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
568   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
569   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
570
571   // Then test the property map type
572   Property::Map outlineMapSet;
573   Property::Map outlineMapGet;
574
575   outlineMapSet["color"] = Color::RED;
576   outlineMapSet["width"] = 2.0f;
577   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
578
579   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
580   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
581   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
582
583   outlineMapSet.Clear();
584   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
585   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
586   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
587
588   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
589   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
590   std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
591   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
592
593   // Check the background property
594   Property::Map backgroundMapSet;
595   Property::Map backgroundMapGet;
596
597   backgroundMapSet["enable"] = true;
598   backgroundMapSet["color"] = Color::RED;
599   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
600
601   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
602   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
603   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
604
605   backgroundMapSet.Clear();
606   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
607   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
608   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
609
610   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
611   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
612   std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
613   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
614
615   // Check the pixel size of font
616   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
617   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618
619   // Check the ellipsis property
620   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
621   label.SetProperty( TextLabel::Property::ELLIPSIS, false );
622   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
623
624   // Check the layout direction property
625   label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
626   DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
627
628   application.SendNotification();
629   application.Render();
630
631   END_TEST;
632 }
633
634 int UtcDaliToolkitTextlabelAtlasRenderP(void)
635 {
636   ToolkitTestApplication application;
637   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
638   TextLabel label = TextLabel::New("Test Text");
639   DALI_TEST_CHECK( label );
640
641   // Avoid a crash when core load gl resources.
642   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
643
644   Stage::GetCurrent().Add( label );
645
646   // Turn on all the effects
647   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
648   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
649
650   Property::Map underlineMap;
651   underlineMap.Insert( "enable", true );
652   underlineMap.Insert( "color", Color::RED );
653   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
654
655   Property::Map shadowMap;
656   shadowMap.Insert( "color", Color::BLUE );
657   shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
658   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
659
660   try
661   {
662     // Render some text with the shared atlas backend
663     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
664     application.SendNotification();
665     application.Render();
666   }
667   catch( ... )
668   {
669     tet_result(TET_FAIL);
670   }
671
672   try
673   {
674     // Render some text with the shared atlas backend
675     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
676     application.SendNotification();
677     application.Render();
678   }
679   catch( ... )
680   {
681     tet_result(TET_FAIL);
682   }
683   END_TEST;
684 }
685
686 int UtcDaliToolkitTextLabelLanguagesP(void)
687 {
688   ToolkitTestApplication application;
689   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
690   TextLabel label = TextLabel::New();
691   DALI_TEST_CHECK( label );
692
693   Stage::GetCurrent().Add( label );
694
695   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
696                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
697                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
698                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
699                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
700                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
701
702   label.SetProperty( TextLabel::Property::TEXT, scripts );
703   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
704
705   application.SendNotification();
706   application.Render();
707
708   END_TEST;
709 }
710
711 int UtcDaliToolkitTextLabelEmojisP(void)
712 {
713   ToolkitTestApplication application;
714   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
715   TextLabel label = TextLabel::New();
716   DALI_TEST_CHECK( label );
717
718   Stage::GetCurrent().Add( label );
719
720   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
721
722   char* pathNamePtr = get_current_dir_name();
723   const std::string pathName( pathNamePtr );
724   free( pathNamePtr );
725
726   TextAbstraction::FontDescription fontDescription;
727   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
728   fontDescription.family = "BreezeColorEmoji";
729   fontDescription.width = TextAbstraction::FontWidth::NONE;
730   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
731   fontDescription.slant = TextAbstraction::FontSlant::NONE;
732
733   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
734
735   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>";
736   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
737   label.SetProperty( TextLabel::Property::TEXT, emojis );
738
739   Property::Map shadowMap;
740   shadowMap.Insert( "color", "green" );
741   shadowMap.Insert( "offset", "2 2" );
742   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
743
744   application.SendNotification();
745   application.Render();
746
747   END_TEST;
748 }
749
750 int UtcDaliToolkitTextlabelScrollingP(void)
751 {
752   ToolkitTestApplication application;
753   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
754   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
755   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
756
757   DALI_TEST_CHECK( labelImmediate );
758   DALI_TEST_CHECK( labelFinished );
759   // Avoid a crash when core load gl resources.
760   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
761   Stage::GetCurrent().Add( labelImmediate );
762   // Turn on all the effects
763   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
764   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
765   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
766   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
767   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
768
769   Stage::GetCurrent().Add( labelFinished );
770   // Turn on all the effects
771   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
772   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
773   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
774   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
775   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
776
777
778
779   try
780   {
781     // Render some text with the shared atlas backend
782     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
783     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
784
785     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
786     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
787
788     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
789     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
790     application.SendNotification();
791     application.Render();
792
793     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
794     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
795     application.SendNotification();
796     application.Render();
797
798   }
799   catch( ... )
800   {
801     tet_result(TET_FAIL);
802   }
803
804   END_TEST;
805 }
806
807 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
808 {
809   ToolkitTestApplication application;
810   TextLabel labelShort = TextLabel::New("Some text to scroll");
811   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!");
812
813   DALI_TEST_CHECK( labelShort );
814   DALI_TEST_CHECK( labelLong );
815   // Avoid a crash when core load gl resources.
816   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
817   Stage::GetCurrent().Add( labelShort );
818   // Turn on all the effects
819   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
820   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
821   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
822   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
823   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
824   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
825
826   Stage::GetCurrent().Add( labelLong );
827   // Turn on all the effects
828   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
829   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
830   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
831   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
832   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
833   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
834
835   try
836   {
837     // Render some text with the shared atlas backend
838     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
839     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
840     application.SendNotification();
841     application.Render();
842
843     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
844     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
845     application.SendNotification();
846     application.Render();
847
848   }
849   catch( ... )
850   {
851     tet_result(TET_FAIL);
852   }
853
854   END_TEST;
855 }
856
857 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
858 {
859   ToolkitTestApplication application;
860   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
861   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
862
863   DALI_TEST_CHECK( labelShort );
864   DALI_TEST_CHECK( labelLong );
865   // Avoid a crash when core load gl resources.
866   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
867   Stage::GetCurrent().Add( labelShort );
868   // Turn on all the effects
869   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
870   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
871   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
872   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
873   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
874   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
875
876   Stage::GetCurrent().Add( labelLong );
877   // Turn on all the effects
878   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
879   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
880   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
881   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
882   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
883   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
884
885   try
886   {
887     // Render some text with the shared atlas backend
888     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
889     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
890     application.SendNotification();
891     application.Render();
892
893     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
894     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
895     application.SendNotification();
896     application.Render();
897
898   }
899   catch( ... )
900   {
901     tet_result(TET_FAIL);
902   }
903
904   END_TEST;
905 }
906
907 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
908 {
909   ToolkitTestApplication application;
910   TextLabel labelShort = TextLabel::New("Some text to scroll");
911   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!");
912
913   DALI_TEST_CHECK( labelShort );
914   DALI_TEST_CHECK( labelLong );
915   // Avoid a crash when core load gl resources.
916   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
917   Stage::GetCurrent().Add( labelShort );
918   // Turn on all the effects
919   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
920   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
921   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
922   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
923   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
924   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
925
926   Stage::GetCurrent().Add( labelLong );
927   // Turn on all the effects
928   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
929   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
930   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
931   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
932   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
933   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
934
935   try
936   {
937     // Render some text with the shared atlas backend
938     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
939     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
940     application.SendNotification();
941     application.Render();
942
943     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
944     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
945     application.SendNotification();
946     application.Render();
947
948   }
949   catch( ... )
950   {
951     tet_result(TET_FAIL);
952   }
953
954   END_TEST;
955 }
956
957 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
958 {
959   ToolkitTestApplication application;
960   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
961   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
962
963   DALI_TEST_CHECK( labelShort );
964   DALI_TEST_CHECK( labelLong );
965   // Avoid a crash when core load gl resources.
966   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
967   Stage::GetCurrent().Add( labelShort );
968   // Turn on all the effects
969   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
970   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
971   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
972   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
973   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
974   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
975
976   Stage::GetCurrent().Add( labelLong );
977   // Turn on all the effects
978   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
979   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
980   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
981   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
982   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
983   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
984
985   try
986   {
987     // Render some text with the shared atlas backend
988     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
989     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
990     application.SendNotification();
991     application.Render();
992
993     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
994     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
995     application.SendNotification();
996     application.Render();
997
998   }
999   catch( ... )
1000   {
1001     tet_result(TET_FAIL);
1002   }
1003
1004   END_TEST;
1005 }
1006
1007 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1008 {
1009   ToolkitTestApplication application;
1010   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1011   TextLabel label = TextLabel::New("Some text to scroll");
1012   DALI_TEST_CHECK( label );
1013   // Avoid a crash when core load gl resources.
1014   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1015   Stage::GetCurrent().Add( label );
1016   label.SetSize( 360.0f, 20.f );
1017   // Turn on all the effects
1018   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1019   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1020   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1021   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1022
1023   // Render the text.
1024   application.SendNotification();
1025   application.Render();
1026
1027   unsigned int actorCount1 = label.GetChildCount();
1028   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1029
1030   try
1031   {
1032     // Render some text with the shared atlas backend
1033     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1034     application.SendNotification();
1035     application.Render(2000);
1036
1037     unsigned int actorCount1 = label.GetChildCount();
1038     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1039
1040     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1041
1042     // Render the text.
1043     application.SendNotification();
1044     application.Render();
1045
1046     unsigned int actorCount2 = label.GetChildCount();
1047     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1048
1049     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1050
1051   }
1052   catch( ... )
1053   {
1054     tet_result(TET_FAIL);
1055   }
1056
1057   END_TEST;
1058 }
1059
1060 int UtcDaliToolkitTextlabelScrollingN(void)
1061 {
1062   ToolkitTestApplication application;
1063   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1064
1065   TextLabel label = TextLabel::New("Some text to scroll");
1066   DALI_TEST_CHECK( label );
1067
1068   Stage::GetCurrent().Add( label );
1069
1070   // Avoid a crash when core load gl resources.
1071   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1072
1073   // The text scrolling works only on single line text.
1074   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1075
1076   // Turn on all the effects.
1077   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1078   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1079   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1080
1081   // Enable the auto scrolling effect.
1082   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1083
1084   // The auto scrolling shouldn't be enabled.
1085   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1086   DALI_TEST_CHECK( !enabled );
1087
1088   END_TEST;
1089 }
1090
1091 int UtcDaliToolkitTextlabelEllipsis(void)
1092 {
1093   ToolkitTestApplication application;
1094   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1095
1096   TextLabel label = TextLabel::New("Hello world");
1097   DALI_TEST_CHECK( label );
1098
1099   // Avoid a crash when core load gl resources.
1100   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1101
1102   Stage::GetCurrent().Add( label );
1103
1104   // Turn on all the effects
1105   label.SetAnchorPoint( AnchorPoint::CENTER );
1106   label.SetParentOrigin( ParentOrigin::CENTER );
1107   label.SetSize( 360.0f, 10.f );
1108
1109   try
1110   {
1111     // Render the text.
1112     application.SendNotification();
1113     application.Render();
1114   }
1115   catch( ... )
1116   {
1117     tet_result(TET_FAIL);
1118   }
1119
1120   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1121   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1122   label.SetSize( 400.0f, 10.f );
1123
1124   try
1125   {
1126     // Render the text.
1127     application.SendNotification();
1128     application.Render();
1129   }
1130   catch( ... )
1131   {
1132     tet_result(TET_FAIL);
1133   }
1134
1135
1136   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1137   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1138   label.SetSize( 400.0f, 10.f );
1139
1140   try
1141   {
1142     // Render the text.
1143     application.SendNotification();
1144     application.Render();
1145   }
1146   catch( ... )
1147   {
1148     tet_result(TET_FAIL);
1149   }
1150
1151   END_TEST;
1152 }
1153
1154 int UtcDaliToolkitTextlabelTextWrapMode(void)
1155 {
1156   ToolkitTestApplication application;
1157   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1158
1159   int lineCount =0 ;
1160
1161   TextLabel label = TextLabel::New();
1162   label.SetSize( 300.0f, 300.f );
1163   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1164   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1165
1166
1167
1168   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1169   Stage::GetCurrent().Add( label );
1170
1171   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1172   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1173
1174   application.SendNotification();
1175   application.Render();
1176
1177   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1178   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1179
1180   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1181   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1182
1183   application.SendNotification();
1184   application.Render();
1185
1186   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1187   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1188
1189   application.SendNotification();
1190   application.Render();
1191
1192   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1193   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1194
1195   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1196   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1197
1198   application.SendNotification();
1199   application.Render();
1200
1201   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1202   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1203
1204   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1205   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1206   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1207
1208   END_TEST;
1209 }
1210
1211 int UtcDaliToolkitTextLabelColorComponents(void)
1212 {
1213   ToolkitTestApplication application;
1214
1215   TextLabel label = TextLabel::New();
1216   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1217   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1218   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1219   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1220   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1221
1222   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1223   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1224   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1225   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1226   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1227
1228   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1229   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.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 ),  1.0f, TEST_LOCATION );
1232   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1233
1234   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1235   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1236   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1237   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1238
1239   // Test a transparent text - Rendering should be skipped.
1240   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1241   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1242
1243   Stage::GetCurrent().Add( label );
1244
1245   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1246   drawTrace.Enable( true );
1247
1248   application.SendNotification();
1249   application.Render();
1250
1251   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1252
1253   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1254
1255   drawTrace.Reset();
1256
1257   application.SendNotification();
1258   application.Render();
1259
1260   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1261
1262   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1263
1264   drawTrace.Reset();
1265
1266   application.SendNotification();
1267   application.Render();
1268
1269   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1270
1271   END_TEST;
1272 }
1273
1274 int UtcDaliToolkitTextlabelTextStyle01(void)
1275 {
1276   ToolkitTestApplication application;
1277   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1278
1279   TextLabel label = TextLabel::New();
1280   label.SetSize( 300.0f, 300.f );
1281   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1282   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1283   Stage::GetCurrent().Add( label );
1284
1285   Property::Map outlineMapSet;
1286   Property::Map outlineMapGet;
1287
1288   outlineMapSet["color"] = Color::BLUE;
1289   outlineMapSet["width"] = 2.0f;
1290   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1291
1292   application.SendNotification();
1293   application.Render();
1294
1295   Property::Map shadowMapSet;
1296   shadowMapSet.Insert( "color", "green" );
1297   shadowMapSet.Insert( "offset", "2 2" );
1298   shadowMapSet.Insert( "blurRadius", "3" );
1299   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1300
1301   outlineMapSet["color"] = Color::RED;
1302   outlineMapSet["width"] = 0.0f;
1303   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1304
1305   application.SendNotification();
1306   application.Render();
1307
1308   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1309
1310   Property::Value* colorValue = outlineMapGet.Find("color");
1311
1312   bool colorMatched( false );
1313
1314   if ( colorValue )
1315   {
1316      Property::Type valueType = colorValue->GetType();
1317
1318      if ( Property::STRING == valueType )
1319      {
1320        std::string stringValue;
1321        colorValue->Get( stringValue );
1322        if (  stringValue == "red" )
1323        {
1324          colorMatched = true;
1325        }
1326      }
1327      else if ( Property::VECTOR4 == valueType )
1328      {
1329        Vector4 colorVector4;
1330        colorValue->Get( colorVector4 );
1331        if (  colorVector4 == Color::RED )
1332        {
1333          colorMatched = true;
1334        }
1335      }
1336   }
1337
1338   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1339
1340   END_TEST;
1341 }
1342
1343 int UtcDaliToolkitTextlabelMultiline(void)
1344 {
1345   ToolkitTestApplication application;
1346   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1347
1348   TextLabel label = TextLabel::New();
1349   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1350   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1351   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1352   Stage::GetCurrent().Add( label );
1353
1354   application.SendNotification();
1355   application.Render();
1356
1357   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1358   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1359
1360   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1361
1362   application.SendNotification();
1363   application.Render();
1364
1365   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1366   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1367
1368
1369   END_TEST;
1370 }
1371
1372 int UtcDaliToolkitTextlabelTextDirection(void)
1373 {
1374   ToolkitTestApplication application;
1375   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1376
1377   TextLabel label = TextLabel::New();
1378   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1379
1380   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1381   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1382   Stage::GetCurrent().Add( label );
1383
1384   // Test LTR text
1385   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1386
1387   // Test RTL text
1388   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1389   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1390
1391   // Test RTL text starting with weak character
1392   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1393   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1394
1395   // Test RTL text string with emoji and weak character
1396   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1397   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1398
1399   END_TEST;
1400 }
1401
1402 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1403 {
1404   ToolkitTestApplication application;
1405   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1406
1407   TextLabel label = TextLabel::New();
1408
1409   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1410   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1411   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1412   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1413   Stage::GetCurrent().Add( label );
1414   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1415
1416   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1417   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1418
1419   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1420   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1421
1422   END_TEST;
1423 }
1424
1425 int UtcDaliToolkitTextLabelBitmapFont(void)
1426 {
1427   ToolkitTestApplication application;
1428   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1429
1430   DevelText::BitmapFontDescription fontDescription;
1431   fontDescription.name = "Digits";
1432   fontDescription.underlinePosition = 0.f;
1433   fontDescription.underlineThickness = 0.f;
1434
1435   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1436   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1437   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1438   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1439   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1440   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1441   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1442   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1443   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1444   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1445   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1446
1447   TextAbstraction::BitmapFont bitmapFont;
1448   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1449
1450   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1451   fontClient.GetFontId( bitmapFont );
1452
1453   TextLabel label = TextLabel::New();
1454
1455   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1456   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1457
1458   // 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.
1459   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1460
1461   Stage::GetCurrent().Add( label );
1462
1463   application.SendNotification();
1464   application.Render();
1465
1466   // The text has been rendered if the height of the text-label is the height of the line.
1467   DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1468
1469   END_TEST;
1470 }