Merge "Remove the unused-variable gLogFilter in internal/text/text-font-style.cpp...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2017 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
26 using namespace Dali;
27 using namespace Toolkit;
28
29 void dali_textlabel_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void dali_textlabel_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
43 const char* const PROPERTY_NAME_TEXT = "text";
44 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
45 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
46 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
47 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
48 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
49 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
52 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
53 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
54 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
55 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
56 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
61
62 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
63 const char* const PROPERTY_NAME_UNDERLINE = "underline";
64 const char* const PROPERTY_NAME_SHADOW = "shadow";
65 const char* const PROPERTY_NAME_EMBOSS = "emboss";
66 const char* const PROPERTY_NAME_OUTLINE = "outline";
67
68 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
69 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
70 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
71
72 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
73 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
74 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
75
76 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
77 {
78   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
79   {
80     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
81     {
82       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
83
84       Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
85       if( NULL != valueSet )
86       {
87         if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
88         {
89           tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
90           return false;
91         }
92       }
93       else
94       {
95         tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
96         return false;
97       }
98     }
99   }
100
101   return true;
102 }
103
104 } // namespace
105
106 int UtcDaliToolkitTextLabelConstructorP(void)
107 {
108   ToolkitTestApplication application;
109   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
110   TextLabel textLabel;
111   DALI_TEST_CHECK( !textLabel );
112   END_TEST;
113 }
114
115 int UtcDaliToolkitTextLabelNewP(void)
116 {
117   ToolkitTestApplication application;
118   tet_infoline(" UtcDaliToolkitTextLabelNewP");
119   TextLabel textLabel = TextLabel::New( "Test Text" );
120   DALI_TEST_CHECK( textLabel );
121   END_TEST;
122 }
123
124 int UtcDaliToolkitTextLabelDownCastP(void)
125 {
126   ToolkitTestApplication application;
127   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
128   TextLabel textLabel1 = TextLabel::New();
129   BaseHandle object( textLabel1 );
130
131   TextLabel textLabel2 = TextLabel::DownCast( object );
132   DALI_TEST_CHECK( textLabel2 );
133
134   TextLabel textLabel3 = DownCast< TextLabel >( object );
135   DALI_TEST_CHECK( textLabel3 );
136   END_TEST;
137 }
138
139 int UtcDaliToolkitTextLabelDownCastN(void)
140 {
141   ToolkitTestApplication application;
142   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
143   BaseHandle uninitializedObject;
144   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
145   DALI_TEST_CHECK( !textLabel1 );
146
147   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
148   DALI_TEST_CHECK( !textLabel2 );
149   END_TEST;
150 }
151
152 int UtcDaliToolkitTextLabelCopyConstructorP(void)
153 {
154   ToolkitTestApplication application;
155   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
156   TextLabel textLabel = TextLabel::New();
157   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
158
159   TextLabel copy( textLabel );
160   DALI_TEST_CHECK( copy );
161   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
162   END_TEST;
163 }
164
165 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
166 {
167   ToolkitTestApplication application;
168   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
169   TextLabel textLabel = TextLabel::New();
170   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
171
172   TextLabel copy = textLabel;
173   DALI_TEST_CHECK( copy );
174   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
175   END_TEST;
176 }
177
178 // Positive test case for a method
179 int UtcDaliToolkitTextLabelGetPropertyP(void)
180 {
181   ToolkitTestApplication application;
182   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
183   TextLabel label = TextLabel::New("Test Text");
184   DALI_TEST_CHECK( label );
185
186   // Check Property Indices are correct
187   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
188   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
189   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
190   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
191   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
192   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
193   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
194   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
195   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
196   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
197   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
198   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
199   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
200   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
201   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
202   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
203   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
204   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
205   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
206   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
207   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
208   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
209   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
210   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
211   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextLabel::Property::PIXEL_SIZE );
212   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextLabel::Property::ELLIPSIS );
213   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
214
215   END_TEST;
216 }
217
218 int UtcDaliToolkitTextLabelSetPropertyP(void)
219 {
220   ToolkitTestApplication application;
221   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
222   TextLabel label = TextLabel::New();
223   DALI_TEST_CHECK( label );
224
225   // Note - we can't check the defaults since the stylesheets are platform-specific
226   label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
227   DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
228
229   // Check that text can be correctly reset
230   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
231   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
232
233   // Check font properties.
234   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
235   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
236
237   Property::Map fontStyleMapSet;
238   Property::Map fontStyleMapGet;
239
240   fontStyleMapSet.Insert( "weight", "bold" );
241   fontStyleMapSet.Insert( "width", "condensed" );
242   fontStyleMapSet.Insert( "slant", "italic" );
243   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
244
245   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
246   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
247   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
248
249   // Check the old font style format.
250   fontStyleMapSet.Clear();
251   fontStyleMapSet.Insert( "weight", "thin" );
252   fontStyleMapSet.Insert( "width", "expanded" );
253   fontStyleMapSet.Insert( "slant", "oblique" );
254   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
255
256   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
257   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
258   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
259
260   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
261   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
262
263   // Reset font style.
264   fontStyleMapSet.Clear();
265   fontStyleMapSet.Insert( "weight", "normal" );
266   fontStyleMapSet.Insert( "slant", "oblique" );
267
268   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
269   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
270   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
271   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
272
273   fontStyleMapSet.Clear();
274   fontStyleMapSet.Insert( "slant", "roman" );
275
276   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
277   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
278   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
279
280   // Replace 'roman' for 'normal'.
281   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
282   if( NULL != slantValue )
283   {
284     if( "normal" == slantValue->Get<std::string>() )
285     {
286       fontStyleMapGet["slant"] = "roman";
287     }
288   }
289   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
290
291   fontStyleMapSet.Clear();
292
293   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
294   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
295   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
296   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
297
298   // Toggle multi-line
299   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
300   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
301
302   // Check that the Alignment properties can be correctly set
303   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
304   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
305   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
306   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
307
308   // Check that text color can be properly set
309   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
310   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
311   // The underline color is changed as well.
312   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
313
314   Property::Map underlineMapSet;
315   Property::Map underlineMapGet;
316
317   underlineMapSet.Insert( "enable", "false" );
318   underlineMapSet.Insert( "color", "blue" );
319   underlineMapSet.Insert( "height", "0" );
320
321   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
322   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
323   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
324
325   // Check that shadow parameters can be correctly set
326   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
327   DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
328   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
329   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
330
331   // Check that underline parameters can be correctly set
332   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
333   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
334   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
335   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
336   label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
337   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
338
339   TextLabel label2 = TextLabel::New( "New text" );
340   DALI_TEST_CHECK( label2 );
341   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
342
343   // Check the enable markup property.
344   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
345   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
346   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
347
348   // Check autoscroll properties
349   const int SCROLL_SPEED = 80;
350   const int SCROLL_LOOPS = 4;
351   const float SCROLL_GAP = 50.0f;
352   const float SCROLL_LOOP_DELAY = 0.3f;
353   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
354   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
355
356   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
357   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
358   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
359   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
360   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
361   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
362   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
363   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
364   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
365   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
366   label.SetProperty(DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
367   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
368
369   //Check autoscroll stop type property
370   label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
371   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
372
373   label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
374   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
375
376
377   // Check the line spacing property
378   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
379   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
380   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
381
382   // Check the underline property
383
384   underlineMapSet.Clear();
385   underlineMapSet.Insert( "enable", "true" );
386   underlineMapSet.Insert( "color", "red" );
387   underlineMapSet.Insert( "height", "1" );
388
389   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
390
391   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
392   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
393   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
394
395   underlineMapSet.Clear();
396
397   Property::Map underlineDisabledMapGet;
398   underlineDisabledMapGet.Insert( "enable", "false" );
399   underlineDisabledMapGet.Insert( "color", "red" );
400   underlineDisabledMapGet.Insert( "height", "1" );
401
402   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
403   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
404   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
405   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
406
407   // Check the shadow property
408
409   Property::Map shadowMapSet;
410   Property::Map shadowMapGet;
411
412   shadowMapSet.Insert( "color", "green" );
413   shadowMapSet.Insert( "offset", "2 2" );
414
415   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
416
417   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
418   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
419   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
420
421   shadowMapSet.Clear();
422   Property::Map shadowDisabledMapGet;
423   shadowDisabledMapGet.Insert( "color", "green" );
424   shadowDisabledMapGet.Insert( "offset", "0 0" );
425
426   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
427
428   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
429   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
430   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
431
432   // Check the emboss property
433   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
434   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
435
436   // Check the outline property
437   Property::Map outlineMapSet;
438   Property::Map outlineMapGet;
439
440   outlineMapSet["color"] = Color::RED;
441   outlineMapSet["width"] = 2.0f;
442   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
443
444   outlineMapSet["color"] = "red";
445   outlineMapSet["width"] = "2";
446   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
447   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
448   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
449
450   // Check the pixel size of font
451   label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
452   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
453
454   // Check the ellipsis property
455   DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
456   label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
457   DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
458
459   END_TEST;
460 }
461
462 int UtcDaliToolkitTextlabelAtlasRenderP(void)
463 {
464   ToolkitTestApplication application;
465   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
466   TextLabel label = TextLabel::New("Test Text");
467   DALI_TEST_CHECK( label );
468
469   // Avoid a crash when core load gl resources.
470   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
471
472   Stage::GetCurrent().Add( label );
473
474   // Turn on all the effects
475   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
476   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
477   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
478   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
479   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
480   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
481
482   try
483   {
484     // Render some text with the shared atlas backend
485     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
486     application.SendNotification();
487     application.Render();
488   }
489   catch( ... )
490   {
491     tet_result(TET_FAIL);
492   }
493
494   try
495   {
496     // Render some text with the shared atlas backend
497     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
498     application.SendNotification();
499     application.Render();
500   }
501   catch( ... )
502   {
503     tet_result(TET_FAIL);
504   }
505   END_TEST;
506 }
507
508 int UtcDaliToolkitTextLabelLanguagesP(void)
509 {
510   ToolkitTestApplication application;
511   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
512   TextLabel label = TextLabel::New();
513   DALI_TEST_CHECK( label );
514
515   Stage::GetCurrent().Add( label );
516
517   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
518                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
519                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
520                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
521                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
522                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
523
524   label.SetProperty( TextLabel::Property::TEXT, scripts );
525   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
526
527   application.SendNotification();
528   application.Render();
529
530   END_TEST;
531 }
532
533 int UtcDaliToolkitTextLabelEmojisP(void)
534 {
535   ToolkitTestApplication application;
536   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
537   TextLabel label = TextLabel::New();
538   DALI_TEST_CHECK( label );
539
540   Stage::GetCurrent().Add( label );
541
542   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
543
544   char* pathNamePtr = get_current_dir_name();
545   const std::string pathName( pathNamePtr );
546   free( pathNamePtr );
547
548   TextAbstraction::FontDescription fontDescription;
549   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
550   fontDescription.family = "BreezeColorEmoji";
551   fontDescription.width = TextAbstraction::FontWidth::NONE;
552   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
553   fontDescription.slant = TextAbstraction::FontSlant::NONE;
554
555   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
556
557   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>";
558   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
559   label.SetProperty( TextLabel::Property::TEXT, emojis );
560
561   application.SendNotification();
562   application.Render();
563
564   END_TEST;
565 }
566
567 int UtcDaliToolkitTextlabelScrollingP(void)
568 {
569   ToolkitTestApplication application;
570   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
571   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
572   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
573
574   DALI_TEST_CHECK( labelImmediate );
575   DALI_TEST_CHECK( labelFinished );
576   // Avoid a crash when core load gl resources.
577   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
578   Stage::GetCurrent().Add( labelImmediate );
579   // Turn on all the effects
580   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
581   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
582   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
583   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
584   labelImmediate.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
585
586   Stage::GetCurrent().Add( labelFinished );
587   // Turn on all the effects
588   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
589   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
590   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
591   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
592   labelFinished.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
593
594
595
596   try
597   {
598     // Render some text with the shared atlas backend
599     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
600     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
601     application.SendNotification();
602     application.Render();
603
604     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
605     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
606     application.SendNotification();
607     application.Render();
608
609   }
610   catch( ... )
611   {
612     tet_result(TET_FAIL);
613   }
614
615   END_TEST;
616 }
617
618 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
619 {
620   ToolkitTestApplication application;
621   TextLabel labelShort = TextLabel::New("Some text to scroll");
622   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!");
623
624   DALI_TEST_CHECK( labelShort );
625   DALI_TEST_CHECK( labelLong );
626   // Avoid a crash when core load gl resources.
627   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
628   Stage::GetCurrent().Add( labelShort );
629   // Turn on all the effects
630   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
631   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
632   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
633   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
634   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
635   labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
636
637   Stage::GetCurrent().Add( labelLong );
638   // Turn on all the effects
639   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
640   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
641   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
642   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
643   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
644   labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
645
646   try
647   {
648     // Render some text with the shared atlas backend
649     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
650     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
651     application.SendNotification();
652     application.Render();
653
654     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
655     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
656     application.SendNotification();
657     application.Render();
658
659   }
660   catch( ... )
661   {
662     tet_result(TET_FAIL);
663   }
664
665   END_TEST;
666 }
667
668 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
669 {
670   ToolkitTestApplication application;
671   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
672   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
673
674   DALI_TEST_CHECK( labelShort );
675   DALI_TEST_CHECK( labelLong );
676   // Avoid a crash when core load gl resources.
677   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
678   Stage::GetCurrent().Add( labelShort );
679   // Turn on all the effects
680   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
681   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
682   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
683   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
684   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
685   labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
686
687   Stage::GetCurrent().Add( labelLong );
688   // Turn on all the effects
689   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
690   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
691   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
692   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
693   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
694   labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
695
696   try
697   {
698     // Render some text with the shared atlas backend
699     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
700     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
701     application.SendNotification();
702     application.Render();
703
704     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
705     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
706     application.SendNotification();
707     application.Render();
708
709   }
710   catch( ... )
711   {
712     tet_result(TET_FAIL);
713   }
714
715   END_TEST;
716 }
717
718 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
719 {
720   ToolkitTestApplication application;
721   TextLabel labelShort = TextLabel::New("Some text to scroll");
722   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!");
723
724   DALI_TEST_CHECK( labelShort );
725   DALI_TEST_CHECK( labelLong );
726   // Avoid a crash when core load gl resources.
727   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
728   Stage::GetCurrent().Add( labelShort );
729   // Turn on all the effects
730   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
731   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
732   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
733   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
734   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
735   labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
736
737   Stage::GetCurrent().Add( labelLong );
738   // Turn on all the effects
739   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
740   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
741   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
742   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
743   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
744   labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
745
746   try
747   {
748     // Render some text with the shared atlas backend
749     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
750     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
751     application.SendNotification();
752     application.Render();
753
754     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
755     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
756     application.SendNotification();
757     application.Render();
758
759   }
760   catch( ... )
761   {
762     tet_result(TET_FAIL);
763   }
764
765   END_TEST;
766 }
767
768 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
769 {
770   ToolkitTestApplication application;
771   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
772   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
773
774   DALI_TEST_CHECK( labelShort );
775   DALI_TEST_CHECK( labelLong );
776   // Avoid a crash when core load gl resources.
777   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
778   Stage::GetCurrent().Add( labelShort );
779   // Turn on all the effects
780   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
781   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
782   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
783   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
784   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
785   labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
786
787   Stage::GetCurrent().Add( labelLong );
788   // Turn on all the effects
789   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
790   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
791   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
792   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
793   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
794   labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
795
796   try
797   {
798     // Render some text with the shared atlas backend
799     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
800     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801     application.SendNotification();
802     application.Render();
803
804     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
806     application.SendNotification();
807     application.Render();
808
809   }
810   catch( ... )
811   {
812     tet_result(TET_FAIL);
813   }
814
815   END_TEST;
816 }
817
818 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
819 {
820   ToolkitTestApplication application;
821   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
822   TextLabel label = TextLabel::New("Some text to scroll");
823   DALI_TEST_CHECK( label );
824   // Avoid a crash when core load gl resources.
825   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
826   Stage::GetCurrent().Add( label );
827   label.SetSize( 360.0f, 20.f );
828   // Turn on all the effects
829   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
830   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
831   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
832   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
833
834   // Render the text.
835   application.SendNotification();
836   application.Render();
837
838   unsigned int actorCount1 = label.GetChildCount();
839   tet_printf("Initial actor count is(%d)\n", actorCount1 );
840
841   try
842   {
843     // Render some text with the shared atlas backend
844     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
845     application.SendNotification();
846     application.Render(2000);
847
848     unsigned int actorCount1 = label.GetChildCount();
849     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
850
851     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
852
853     // Render the text.
854     application.SendNotification();
855     application.Render();
856
857     unsigned int actorCount2 = label.GetChildCount();
858     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
859
860     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
861
862   }
863   catch( ... )
864   {
865     tet_result(TET_FAIL);
866   }
867
868   END_TEST;
869 }
870
871 int UtcDaliToolkitTextlabelScrollingN(void)
872 {
873   ToolkitTestApplication application;
874   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
875
876   TextLabel label = TextLabel::New("Some text to scroll");
877   DALI_TEST_CHECK( label );
878
879   Stage::GetCurrent().Add( label );
880
881   // Avoid a crash when core load gl resources.
882   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
883
884   // The text scrolling works only on single line text.
885   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
886
887   // Turn on all the effects.
888   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
889   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
890   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
891
892   // Enable the auto scrolling effect.
893   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
894
895   // The auto scrolling shouldn't be enabled.
896   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
897   DALI_TEST_CHECK( !enabled );
898
899   END_TEST;
900 }
901
902 int UtcDaliToolkitTextlabelEllipsis(void)
903 {
904   ToolkitTestApplication application;
905   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
906
907   TextLabel label = TextLabel::New("Hello world");
908   DALI_TEST_CHECK( label );
909
910   // Avoid a crash when core load gl resources.
911   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
912
913   Stage::GetCurrent().Add( label );
914
915   // Turn on all the effects
916   label.SetAnchorPoint( AnchorPoint::CENTER );
917   label.SetParentOrigin( ParentOrigin::CENTER );
918   label.SetSize( 360.0f, 10.f );
919
920   try
921   {
922     // Render the text.
923     application.SendNotification();
924     application.Render();
925   }
926   catch( ... )
927   {
928     tet_result(TET_FAIL);
929   }
930
931   END_TEST;
932 }
933
934 int UtcDaliToolkitTextlabelTextWarpMode(void)
935 {
936   ToolkitTestApplication application;
937   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
938
939   int lineCount =0 ;
940
941   TextLabel label = TextLabel::New();
942   label.SetSize( 300.0f, 300.f );
943   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
944   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
945
946
947
948   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
949   Stage::GetCurrent().Add( label );
950
951   label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_WORD" );
952
953   application.SendNotification();
954   application.Render();
955
956   lineCount =  label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
957   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
958
959
960
961   label.SetProperty( DevelTextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_CHARACTER" );
962
963   application.SendNotification();
964   application.Render();
965
966
967   lineCount =  label.GetProperty<int>( DevelTextLabel::Property::LINE_COUNT );
968   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
969
970   END_TEST;
971 }
972
973 int UtcDaliToolkitTextLabelColorComponents(void)
974 {
975   ToolkitTestApplication application;
976
977   TextLabel label = TextLabel::New();
978   label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::RED );
979   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
980   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
981   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
982   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
983
984   label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN );
985   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
986   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
987   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
988   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
989
990   label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
991   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
992   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
993   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
994   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
995
996   label.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
997   DALI_TEST_EQUALS( label.GetProperty< float >( DevelTextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
998   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
999   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1000
1001   END_TEST;
1002 }
1003
1004 int UtcDaliToolkitTextlabelTextStyle01(void)
1005 {
1006   ToolkitTestApplication application;
1007   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1008
1009   TextLabel label = TextLabel::New();
1010   label.SetSize( 300.0f, 300.f );
1011   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1012   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1013   Stage::GetCurrent().Add( label );
1014
1015   Property::Map outlineMapSet;
1016   Property::Map outlineMapGet;
1017
1018   outlineMapSet["color"] = Color::BLUE;
1019   outlineMapSet["width"] = 2.0f;
1020   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1021
1022   application.SendNotification();
1023   application.Render();
1024
1025   Property::Map shadowMapSet;
1026   shadowMapSet.Insert( "color", "green" );
1027   shadowMapSet.Insert( "offset", "2 2" );
1028   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1029
1030   outlineMapSet["color"] = Color::RED;
1031   outlineMapSet["width"] = 0.0f;
1032   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1033
1034   application.SendNotification();
1035   application.Render();
1036
1037   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1038
1039   Property::Value* colorValue = outlineMapGet.Find("color");
1040
1041   bool colorMatched( false );
1042
1043   if ( colorValue )
1044   {
1045      Property::Type valueType = colorValue->GetType();
1046
1047      if ( Property::STRING == valueType )
1048      {
1049        std::string stringValue;
1050        colorValue->Get( stringValue );
1051        if (  stringValue == "red" )
1052        {
1053          colorMatched = true;
1054        }
1055      }
1056      else if ( Property::VECTOR4 == valueType )
1057      {
1058        Vector4 colorVector4;
1059        colorValue->Get( colorVector4 );
1060        if (  colorVector4 == Color::RED )
1061        {
1062          colorMatched = true;
1063        }
1064      }
1065   }
1066
1067   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1068
1069   END_TEST;
1070 }