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