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