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