2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
24 using namespace Toolkit;
26 void dali_textlabel_startup(void)
28 test_return_value = TET_UNDEF;
31 void dali_textlabel_cleanup(void)
33 test_return_value = TET_PASS;
39 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
40 const char* const PROPERTY_NAME_TEXT = "text";
41 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
42 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
43 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
44 const char* const PROPERTY_NAME_MULTI_LINE = "multiLine";
45 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
46 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
47 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
48 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
49 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
50 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
51 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
52 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
53 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
54 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
55 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
59 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
60 const char* const PROPERTY_NAME_UNDERLINE = "underline";
61 const char* const PROPERTY_NAME_SHADOW = "shadow";
62 const char* const PROPERTY_NAME_EMBOSS = "emboss";
63 const char* const PROPERTY_NAME_OUTLINE = "outline";
65 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
67 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
69 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
71 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
73 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
75 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
76 if( NULL != valueSet )
78 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
80 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
86 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
97 int UtcDaliToolkitTextLabelConstructorP(void)
99 ToolkitTestApplication application;
100 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
102 DALI_TEST_CHECK( !textLabel );
106 int UtcDaliToolkitTextLabelNewP(void)
108 ToolkitTestApplication application;
109 tet_infoline(" UtcDaliToolkitTextLabelNewP");
110 TextLabel textLabel = TextLabel::New( "Test Text" );
111 DALI_TEST_CHECK( textLabel );
115 int UtcDaliToolkitTextLabelDownCastP(void)
117 ToolkitTestApplication application;
118 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
119 TextLabel textLabel1 = TextLabel::New();
120 BaseHandle object( textLabel1 );
122 TextLabel textLabel2 = TextLabel::DownCast( object );
123 DALI_TEST_CHECK( textLabel2 );
125 TextLabel textLabel3 = DownCast< TextLabel >( object );
126 DALI_TEST_CHECK( textLabel3 );
130 int UtcDaliToolkitTextLabelDownCastN(void)
132 ToolkitTestApplication application;
133 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
134 BaseHandle uninitializedObject;
135 TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
136 DALI_TEST_CHECK( !textLabel1 );
138 TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
139 DALI_TEST_CHECK( !textLabel2 );
143 int UtcDaliToolkitTextLabelCopyConstructorP(void)
145 ToolkitTestApplication application;
146 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
147 TextLabel textLabel = TextLabel::New();
148 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
150 TextLabel copy( textLabel );
151 DALI_TEST_CHECK( copy );
152 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
156 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
158 ToolkitTestApplication application;
159 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
160 TextLabel textLabel = TextLabel::New();
161 textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
163 TextLabel copy = textLabel;
164 DALI_TEST_CHECK( copy );
165 DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
169 // Positive test case for a method
170 int UtcDaliToolkitTextLabelGetPropertyP(void)
172 ToolkitTestApplication application;
173 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
174 TextLabel label = TextLabel::New("Test Text");
175 DALI_TEST_CHECK( label );
177 // Check Property Indices are correct
178 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
179 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
180 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
181 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
182 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
183 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
184 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
185 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
186 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
187 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
188 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
189 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
190 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
191 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
192 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
193 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
194 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
195 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
196 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
197 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
198 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
199 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
200 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
201 DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
206 int UtcDaliToolkitTextLabelSetPropertyP(void)
208 ToolkitTestApplication application;
209 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
210 TextLabel label = TextLabel::New();
211 DALI_TEST_CHECK( label );
213 // Note - we can't check the defaults since the stylesheets are platform-specific
214 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
215 DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
217 // Check that text can be correctly reset
218 label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
219 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
221 // Check font properties.
222 label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
223 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
225 Property::Map fontStyleMapSet;
226 Property::Map fontStyleMapGet;
228 fontStyleMapSet.Insert( "weight", "bold" );
229 fontStyleMapSet.Insert( "width", "condensed" );
230 fontStyleMapSet.Insert( "slant", "italic" );
231 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
233 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
234 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
235 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
237 // Check the old font style format.
238 fontStyleMapSet.Clear();
239 fontStyleMapSet.Insert( "weight", "thin" );
240 fontStyleMapSet.Insert( "width", "expanded" );
241 fontStyleMapSet.Insert( "slant", "oblique" );
243 label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
244 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
245 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
246 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
248 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
249 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
252 fontStyleMapSet.Clear();
253 fontStyleMapSet.Insert( "weight", "normal" );
254 fontStyleMapSet.Insert( "slant", "oblique" );
256 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
257 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
258 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
259 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
261 fontStyleMapSet.Clear();
262 fontStyleMapSet.Insert( "slant", "roman" );
264 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
265 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
266 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
268 // Replace 'roman' for 'normal'.
269 Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
270 if( NULL != slantValue )
272 if( "normal" == slantValue->Get<std::string>() )
274 fontStyleMapGet["slant"] = "roman";
277 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
279 fontStyleMapSet.Clear();
281 label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
282 fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
283 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
284 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
287 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
288 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
290 // Check that the Alignment properties can be correctly set
291 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
292 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
293 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
294 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
296 // Check that text color can be properly set
297 label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
298 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
299 // The underline color is changed as well.
300 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
302 Property::Map underlineMapSet;
303 Property::Map underlineMapGet;
305 underlineMapSet.Insert( "enable", "false" );
306 underlineMapSet.Insert( "color", "blue" );
307 underlineMapSet.Insert( "height", "0" );
309 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
310 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
311 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
313 // Check that shadow parameters can be correctly set
314 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
315 DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
316 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
317 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
319 // Check that underline parameters can be correctly set
320 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
321 DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
322 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
323 DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
324 label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
325 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
327 TextLabel label2 = TextLabel::New( "New text" );
328 DALI_TEST_CHECK( label2 );
329 DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
331 // Check the enable markup property.
332 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
333 label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
334 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
336 // Check autoscroll properties
337 const int SCROLL_SPEED = 80;
338 const int SCROLL_LOOPS = 4;
339 const float SCROLL_GAP = 50.0f;
340 label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
341 DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
342 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
343 DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
344 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
345 DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
346 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
347 DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
348 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
349 DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
351 // Check the line spacing property
352 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
353 label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
354 DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
356 // Check the underline property
358 underlineMapSet.Clear();
359 underlineMapSet.Insert( "enable", "true" );
360 underlineMapSet.Insert( "color", "red" );
361 underlineMapSet.Insert( "height", "1" );
363 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
365 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
366 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
367 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
369 underlineMapSet.Clear();
371 Property::Map underlineDisabledMapGet;
372 underlineDisabledMapGet.Insert( "enable", "false" );
373 underlineDisabledMapGet.Insert( "color", "red" );
374 underlineDisabledMapGet.Insert( "height", "1" );
376 label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
377 underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
378 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
379 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
381 // Check the shadow property
383 Property::Map shadowMapSet;
384 Property::Map shadowMapGet;
386 shadowMapSet.Insert( "color", "green" );
387 shadowMapSet.Insert( "offset", "2 2" );
389 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
391 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
392 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
393 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
395 shadowMapSet.Clear();
396 Property::Map shadowDisabledMapGet;
397 shadowDisabledMapGet.Insert( "color", "green" );
398 shadowDisabledMapGet.Insert( "offset", "0 0" );
400 label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
402 shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
403 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
404 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
406 // Check the emboss property
407 label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
408 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
410 // Check the outline property
411 label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
412 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
417 int UtcDaliToolkitTextlabelAtlasRenderP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
421 TextLabel label = TextLabel::New("Test Text");
422 DALI_TEST_CHECK( label );
424 // Avoid a crash when core load gl resources.
425 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
427 Stage::GetCurrent().Add( label );
429 // Turn on all the effects
430 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
431 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
432 label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
433 label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
434 label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
435 label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
439 // Render some text with the shared atlas backend
440 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
441 application.SendNotification();
442 application.Render();
446 tet_result(TET_FAIL);
452 int UtcDaliToolkitTextLabelLanguagesP(void)
454 ToolkitTestApplication application;
455 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
456 TextLabel label = TextLabel::New();
457 DALI_TEST_CHECK( label );
459 Stage::GetCurrent().Add( label );
461 const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
462 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
463 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
464 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
465 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
466 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
468 label.SetProperty( TextLabel::Property::TEXT, scripts );
469 DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
471 application.SendNotification();
472 application.Render();
477 int UtcDaliToolkitTextLabelVectorBasedP(void)
479 ToolkitTestApplication application;
480 tet_infoline(" UtcDaliToolkitTextLabelVectorBasedP");
482 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
483 glAbstraction.EnableTextureCallTrace( true );
485 TextLabel label = TextLabel::New();
486 label.SetParentOrigin( ParentOrigin::CENTER );
487 label.SetSize( Stage::GetCurrent().GetSize() );
488 label.SetProperty( TextLabel::Property::TEXT, "Hello World" );
489 label.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
490 label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED );
491 Stage::GetCurrent().Add( label );
493 application.SendNotification();
494 application.Render();
496 // Test that the vector data is uploaded to atlas
497 DALI_TEST_CHECK( glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") );
498 glAbstraction.GetTextureTrace().Reset();
500 // Add another label with the same text in a different point-size
501 TextLabel label2 = TextLabel::New();
502 label2.SetProperty( TextLabel::Property::TEXT, "Hello World" );
503 label2.SetProperty( TextLabel::Property::POINT_SIZE, 13.0f );
504 label2.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED );
505 Stage::GetCurrent().Add( label2 );
507 application.SendNotification();
508 application.Render();
510 // Test that no additional vector data was uploaded to atlas
511 // i.e. the same vector data can be used to render any point-size
512 DALI_TEST_CHECK( ! glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") );
517 int UtcDaliToolkitTextlabelScrollingP(void)
519 ToolkitTestApplication application;
520 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
521 TextLabel label = TextLabel::New("Some text to scroll");
522 DALI_TEST_CHECK( label );
523 // Avoid a crash when core load gl resources.
524 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
525 Stage::GetCurrent().Add( label );
526 // Turn on all the effects
527 label.SetProperty( TextLabel::Property::MULTI_LINE, false );
528 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
529 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
530 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
534 // Render some text with the shared atlas backend
535 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
536 application.SendNotification();
537 application.Render();
541 tet_result(TET_FAIL);
547 int UtcDaliToolkitTextlabelScrollingN(void)
549 ToolkitTestApplication application;
550 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
552 TextLabel label = TextLabel::New("Some text to scroll");
553 DALI_TEST_CHECK( label );
555 Stage::GetCurrent().Add( label );
557 // Avoid a crash when core load gl resources.
558 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
560 // The text scrolling works only on single line text.
561 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
563 // Turn on all the effects.
564 label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
565 label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
566 label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
568 // Enable the auto scrolling effect.
569 label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
571 // The auto scrolling shouldn't be enabled.
572 const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
573 DALI_TEST_CHECK( !enabled );
578 int UtcDaliToolkitTextlabelEllipsis(void)
580 ToolkitTestApplication application;
581 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
583 TextLabel label = TextLabel::New("Hello world");
584 DALI_TEST_CHECK( label );
586 // Avoid a crash when core load gl resources.
587 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
589 Stage::GetCurrent().Add( label );
591 // Turn on all the effects
592 label.SetAnchorPoint( AnchorPoint::CENTER );
593 label.SetParentOrigin( ParentOrigin::CENTER );
594 label.SetSize( 360.0f, 10.f );
599 application.SendNotification();
600 application.Render();
604 tet_result(TET_FAIL);