2 * Copyright (c) 2014 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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
26 void text_actor_test_startup(void)
28 test_return_value = TET_UNDEF;
31 void text_actor_test_cleanup(void)
33 test_return_value = TET_PASS;
38 static const char* TestTextHello = "Hello";
39 static const char* TestTextHelloWorld = "Hello World";
40 static const char* LongTestText = "This is a very long piece of text, and is sure not to fit into any box presented to it";
42 static const std::string DEFAULT_NAME_STYLE( "" );
43 static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f );
45 static const std::string FONT_FAMILY( "Arial" );
46 static const std::string FONT_STYLE( "Bold" );
47 static const PointSize FONT_POINT_SIZE( 12.f );
48 static const Vector4 TEXT_COLOR( Color::RED );
50 static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT );
51 static const float SMOOTH_EDGE( 5.0f );
53 static const bool ITALICS( true );
54 static const Degree ITALICS_ANGLE( 10.f );
55 static const Radian ITALICS_RADIAN_ANGLE(0.4f);
57 static const bool UNDERLINE( true );
58 static const float UNDERLINE_THICKNESS( 5.0f );
59 static const float UNDERLINE_POSITION( 60.0f );
61 static const bool SHADOW( true );
62 static const Vector4 SHADOW_COLOR( Color::BLUE );
63 static const Vector2 SHADOW_OFFSET( 2.f, 2.f );
64 static const float SHADOW_SIZE( 55.f );
66 static const bool GLOW( true );
67 static const Vector4 GLOW_COLOR( Color::BLACK );
68 static const float GLOW_INTENSITY( 10.0f );
70 static const bool OUTLINE( true );
71 static const Vector4 OUTLINE_COLOR( Color::MAGENTA );
72 static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f );
74 static const bool GRADIENT( true );
75 static const Vector4 GRADIENT_COLOR( Color::YELLOW );
76 static const Vector2 GRADIENT_START_POINT( 1.f, 1.f );
77 static const Vector2 GRADIENT_END_POINT( 2.f, 2.f );
80 int UtcDaliTextActorConstructorVoid(void)
82 TestApplication application;
84 tet_infoline("Testing Dali::TextActor::TextActor()");
88 DALI_TEST_CHECK(!actor);
92 int UtcDaliTextActorNew01(void)
94 TestApplication application;
96 tet_infoline("Testing Dali::TextActor::New()");
98 TextActor actor = TextActor::New(TestTextHello);
100 DALI_TEST_CHECK(actor);
102 actor = TextActor::New(Text(std::string(TestTextHello)));
104 DALI_TEST_CHECK(actor);
109 int UtcDaliTextActorNew02(void)
111 TestApplication application;
113 tet_infoline("Testing Dali::TextActor::New()");
115 TextActor actor = TextActor::New(TestTextHello, false);
117 DALI_TEST_CHECK(actor);
119 actor = TextActor::New(Text(std::string(TestTextHello)), false);
121 DALI_TEST_CHECK(actor);
125 int UtcDaliTextActorNew03(void)
127 TestApplication application;
129 tet_infoline("Testing Dali::TextActor::New()");
131 TextActor actor = TextActor::New(TestTextHello, false, false);
133 DALI_TEST_CHECK(actor);
135 actor = TextActor::New(Text(std::string(TestTextHello)), false, false);
137 DALI_TEST_CHECK(actor);
142 int UtcDaliTextActorNew04(void)
144 TestApplication application;
146 tet_infoline("Testing Dali::TextActor::New()");
148 FontParameters parameters( "FreeSerif", "Book", PointSize(8) );
149 Font freeSerif = Font::New( parameters );
151 TextActor actor = TextActor::New(TestTextHello, freeSerif);
153 DALI_TEST_CHECK(actor);
155 actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif);
157 DALI_TEST_CHECK(actor);
161 int UtcDaliTextActorNew05(void)
163 TestApplication application;
165 tet_infoline("Testing Dali::TextActor::New()");
167 FontParameters parameters( "FreeSerif", "Book", PointSize(8) );
168 Font freeSerif = Font::New( parameters );
170 TextActor actor = TextActor::New(TestTextHello, freeSerif, false);
172 DALI_TEST_CHECK(actor);
174 actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif, false);
176 DALI_TEST_CHECK(actor);
180 int UtcDaliTextActorNew06(void)
182 TestApplication application;
184 tet_infoline("Testing Dali::TextActor::New()");
186 FontParameters parameters( "FreeSerif", "Book", PointSize(8) );
187 Font freeSerif = Font::New( parameters );
189 TextActor actor = TextActor::New(TestTextHello, freeSerif, false, false);
191 DALI_TEST_CHECK(actor);
193 actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif, false, false);
195 DALI_TEST_CHECK(actor);
199 int UtcDaliTextActorNew07(void)
201 TestApplication application;
203 tet_infoline("Testing Dali::TextActor::New()");
207 TextActor actor = TextActor::New(Text(TestTextHello), style, false, false);
209 DALI_TEST_CHECK(actor);
214 int UtcDaliTextActorDownCast(void)
216 TestApplication application;
217 tet_infoline("Testing Dali::TextActor::DownCast()");
219 TextActor actor1 = TextActor::New("Hello, World!");
220 Actor anActor = Actor::New();
223 Actor child = anActor.GetChildAt(0);
224 TextActor textActor = TextActor::DownCast(child);
226 DALI_TEST_CHECK(textActor);
227 DALI_TEST_CHECK(!textActor.GetText().compare("Hello, World!"));
231 int UtcDaliTextActorDownCast2(void)
233 TestApplication application;
234 tet_infoline("Testing Dali::TextActor::DownCast()");
236 Actor actor1 = Actor::New();
237 Actor anActor = Actor::New();
240 Actor child = anActor.GetChildAt(0);
241 TextActor textActor = TextActor::DownCast(child);
242 DALI_TEST_CHECK(!textActor);
244 Actor unInitialzedActor;
245 textActor = DownCast< TextActor >( unInitialzedActor );
246 DALI_TEST_CHECK(!textActor);
250 int UtcDaliTextActorSetText(void)
252 TestApplication application;
254 tet_infoline("Testing Dali::TextActor::SetText()");
256 TextActor actor01 = TextActor::New(TestTextHello);
258 actor01.SetText(TestTextHelloWorld);
260 std::string text = actor01.GetText();
262 DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
264 actor01.SetText(Text(std::string(TestTextHelloWorld)));
266 text = actor01.GetText();
268 DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
272 text = actor01.GetText();
274 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
276 TextActor actor02 = TextActor::New("");
278 actor02.SetText( std::string() );
280 text = actor02.GetText();
282 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
284 actor02.SetText(TestTextHelloWorld);
285 actor02.SetText( std::string() );
287 text = actor02.GetText();
289 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
291 TextActor actor03 = TextActor::New("");
293 actor03.SetText(voidText);
295 text = actor03.GetText();
297 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
299 actor03.SetText(TestTextHelloWorld);
300 actor03.SetText(voidText);
302 text = actor03.GetText();
304 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
308 int UtcDaliTextActorSetFont(void)
310 TestApplication application;
312 TextActor actor = TextActor::New(TestTextHello);
314 Font defaultFont = actor.GetFont();
315 DALI_TEST_EQUALS( defaultFont.GetName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
316 DALI_TEST_EQUALS( defaultFont.GetStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
317 DALI_TEST_CHECK( defaultFont.IsDefaultSystemSize() );
319 TextStyle defaultStyle = actor.GetTextStyle();
320 DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
321 DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
322 DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
324 FontParameters params( FONT_FAMILY, FONT_STYLE, FONT_POINT_SIZE );
326 Font font = Font::New( params );
328 actor.SetFont( font );
330 Font font2 = actor.GetFont();
332 DALI_TEST_EQUALS( font2.GetName(), FONT_FAMILY, TEST_LOCATION );
333 DALI_TEST_EQUALS( font2.GetStyle(), FONT_STYLE, TEST_LOCATION );
334 DALI_TEST_CHECK( !font2.IsDefaultSystemSize() );
335 DALI_TEST_EQUALS( PointSize( font2.GetPointSize() ), FONT_POINT_SIZE, TEST_LOCATION );
337 TextStyle style = actor.GetTextStyle();
338 DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
339 DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
340 DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
345 int UtcDaliTextActorSetFontDetection(void)
347 TestApplication application;
349 TextActor actor = TextActor::New(TestTextHello);
351 actor.SetFontDetectionAutomatic( true );
353 DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() );
358 int UtcDaliTextActorSetTextIndividualStyles(void)
360 TestApplication application;
362 TextActor actor = TextActor::New(TestTextHello);
363 TextStyle defaultStyle = actor.GetTextStyle();
365 DALI_TEST_EQUALS( actor.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
366 DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
368 DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
369 DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
371 DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
373 DALI_TEST_CHECK( !actor.GetItalics() );
374 DALI_TEST_EQUALS( actor.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
375 DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
376 DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
377 DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
379 DALI_TEST_CHECK( !actor.GetUnderline() );
380 DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
381 DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
382 DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
383 DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
385 DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
386 DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
387 DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
388 DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
390 DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
391 DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
392 DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
393 DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
395 DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
396 DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
397 DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
398 DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
400 DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
401 DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
402 DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
403 DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
404 DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
407 actor.SetTextColor( TEXT_COLOR );
409 actor.SetWeight( TEXT_WEIGHT );
410 actor.SetSmoothEdge( SMOOTH_EDGE );
412 actor.SetItalics( ITALICS, ITALICS_ANGLE );
413 actor.SetUnderline( UNDERLINE );
415 actor.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
416 actor.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
417 actor.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
418 actor.SetGradientColor( GRADIENT_COLOR );
419 actor.SetGradientStartPoint( GRADIENT_START_POINT );
420 actor.SetGradientEndPoint( GRADIENT_END_POINT );
423 TextStyle style = actor.GetTextStyle();
425 DALI_TEST_EQUALS( actor.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
426 DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
428 DALI_TEST_EQUALS( actor.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
429 DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
431 DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
433 DALI_TEST_CHECK( actor.GetItalics() );
434 DALI_TEST_EQUALS( actor.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
435 DALI_TEST_CHECK( !style.IsItalicsDefault() );
436 DALI_TEST_CHECK( style.IsItalicsEnabled() );
437 DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
439 DALI_TEST_CHECK( actor.GetUnderline() );
440 DALI_TEST_CHECK( !style.IsUnderlineDefault() );
441 DALI_TEST_CHECK( style.IsUnderlineEnabled() );
442 DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
443 DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
445 DALI_TEST_CHECK( !style.IsShadowDefault() );
446 DALI_TEST_CHECK( style.IsShadowEnabled() );
447 DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
448 DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
450 DALI_TEST_CHECK( !style.IsGlowDefault() );
451 DALI_TEST_CHECK( style.IsGlowEnabled() );
452 DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
453 DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
455 DALI_TEST_CHECK( !style.IsOutlineDefault() );
456 DALI_TEST_CHECK( style.IsOutlineEnabled() );
457 DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
458 DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
460 DALI_TEST_EQUALS( actor.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
461 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
462 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
463 DALI_TEST_CHECK( !style.IsGradientDefault() );
464 DALI_TEST_CHECK( style.IsGradientEnabled() );
465 DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
466 DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
467 DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
469 // Added to increase coverage.
471 // Set a different color.
472 actor.SetTextColor( TEXT_COLOR );
473 actor.SetTextColor( Color::GREEN );
474 DALI_TEST_EQUALS( actor.GetTextColor(), Color::GREEN, TEST_LOCATION );
476 // Set a different weight
477 actor.SetWeight( TEXT_WEIGHT );
478 actor.SetWeight( TextStyle::BOLD );
479 DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::BOLD, TEST_LOCATION );
481 // Set a different smooth edge
482 actor.SetSmoothEdge( SMOOTH_EDGE );
483 actor.SetSmoothEdge( 1.f );
484 DALI_TEST_EQUALS( actor.GetTextStyle().GetSmoothEdge(), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
486 // Set different italic parameters
487 actor.SetItalics( true, ITALICS_ANGLE );
488 actor.SetItalics( false );
489 DALI_TEST_CHECK( !actor.GetItalics() );
490 actor.SetItalics( true, Degree( 15.f ) );
491 DALI_TEST_EQUALS( actor.GetItalicsAngle(), Degree( 15.f ), TEST_LOCATION );
496 int UtcDaliTextActorChangingText(void)
498 TestApplication application;
500 TextActor actor = TextActor::New(TestTextHello);
501 actor.SetSize(Vector3(200, 20, 0.0f));
502 actor.SetPosition(20.0f, 400.0f, 40.0f);
503 Stage::GetCurrent().Add(actor);
505 tet_infoline("Testing Dali::TextActor::SetText() & Dali::TextActor::GetText()");
506 actor.SetText(LongTestText);
507 std::string text = actor.GetText();
508 DALI_TEST_EQUALS(text, LongTestText, TEST_LOCATION);
511 application.SendNotification();
512 application.Render();
514 // check that the size did not change
515 DALI_TEST_EQUALS( Vector3(200, 20, 0.0f), actor.GetCurrentSize(), TEST_LOCATION);
519 int UtcDaliTextActorGetLoadingState(void)
521 TestApplication application;
523 TextActor actor = TextActor::New(TestTextHello);
525 DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState());
527 application.SendNotification();
528 application.Render();
530 DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState());
535 int UtcDaliTextActorSetItalics(void)
537 TestApplication application;
539 tet_infoline("Testing Dali::TextActor::New()");
541 TextActor actor = TextActor::New(TestTextHello);
543 DALI_TEST_CHECK(actor);
545 actor.SetItalics( true );
547 DALI_TEST_CHECK( actor.GetItalics() );
549 DALI_TEST_EQUALS( static_cast<float>( Degree( actor.GetItalicsAngle() ) ), static_cast<float>(TextStyle::DEFAULT_ITALICS_ANGLE), 0.0001f, TEST_LOCATION );
551 actor.SetItalics( false );
553 DALI_TEST_CHECK( ! actor.GetItalics() );
555 // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
559 int UtcDaliTextActorSetUnderline(void)
561 TestApplication application;
563 tet_infoline("Testing Dali::TextActor::SetUnderline()");
565 TextActor actor = TextActor::New(TestTextHello);
567 DALI_TEST_CHECK(actor);
569 actor.SetUnderline( true );
571 DALI_TEST_CHECK( actor.GetUnderline() );
573 actor.SetUnderline( false );
575 DALI_TEST_CHECK( ! actor.GetUnderline() );
577 // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
581 int UtcDaliTextActorSetWeight(void)
583 TestApplication application;
585 tet_infoline("Testing Dali::TextActor::SetWeight()");
587 TextActor actor = TextActor::New(TestTextHello);
589 DALI_TEST_CHECK(actor);
591 actor.SetWeight( TextStyle::EXTRABOLD );
593 DALI_TEST_CHECK( TextStyle::EXTRABOLD == actor.GetWeight() );
595 actor.SetWeight( TextStyle::BOLD );
597 DALI_TEST_CHECK( TextStyle::BOLD == actor.GetWeight() );
601 int UtcDaliTextActorSetStyle(void)
603 TestApplication application;
605 tet_infoline("Testing Dali::TextActor::SetTextStyle()");
607 TextActor actor = TextActor::New(TestTextHello);
609 const TextStyle defaultStyle = actor.GetTextStyle();
611 DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
612 DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
613 DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
614 DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
616 DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
617 DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
620 DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
621 DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
623 DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
624 DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
625 DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
626 DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
629 DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
630 DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
631 DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
633 DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
634 DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
635 DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
636 DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
638 DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
639 DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
640 DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
641 DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
643 DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
644 DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
645 DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
646 DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
647 DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
650 // Set a non default style.
653 style.SetFontName( FONT_FAMILY );
654 style.SetFontStyle( FONT_STYLE );
655 style.SetFontPointSize( FONT_POINT_SIZE );
656 style.SetTextColor( TEXT_COLOR );
658 style.SetWeight( TEXT_WEIGHT );
659 style.SetSmoothEdge( SMOOTH_EDGE );
661 style.SetItalics( ITALICS, ITALICS_ANGLE );
662 style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
664 style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
665 style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
666 style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
667 style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
669 actor.SetTextStyle( style );
671 // This is necessary since SetColor (via TextStyle) is asynchronous
672 application.SendNotification();
673 application.Render();
675 TextStyle style2 = actor.GetTextStyle();
677 DALI_TEST_CHECK( !style2.IsFontNameDefault() );
678 DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
679 DALI_TEST_CHECK( !style2.IsFontSizeDefault() );
680 DALI_TEST_CHECK( !style2.IsTextColorDefault() );
681 DALI_TEST_CHECK( !style2.IsFontWeightDefault() );
682 DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() );
683 DALI_TEST_CHECK( !style2.IsItalicsDefault() );
684 DALI_TEST_CHECK( !style2.IsUnderlineDefault() );
685 DALI_TEST_CHECK( !style2.IsShadowDefault() );
686 DALI_TEST_CHECK( !style2.IsGlowDefault() );
687 DALI_TEST_CHECK( !style2.IsOutlineDefault() );
688 DALI_TEST_CHECK( !style2.IsGradientDefault() );
690 DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
691 DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
692 DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
693 DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
695 DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
696 DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 DALI_TEST_CHECK( style2.IsItalicsEnabled() );
699 DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
701 DALI_TEST_CHECK( style2.IsUnderlineEnabled() );
702 DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705 DALI_TEST_CHECK( style2.IsShadowEnabled() );
706 DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
707 DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
709 DALI_TEST_CHECK( style2.IsGlowEnabled() );
710 DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
711 DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 DALI_TEST_CHECK( style2.IsOutlineEnabled() );
714 DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
715 DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
717 DALI_TEST_CHECK( style2.IsGradientEnabled() );
718 DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
719 DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
720 DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
723 // Set a default style
724 actor.SetTextStyle( defaultStyle );
726 TextStyle style3 = actor.GetTextStyle();
728 DALI_TEST_EQUALS( style3.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
729 DALI_TEST_EQUALS( style3.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
730 DALI_TEST_EQUALS( style3.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
731 DALI_TEST_EQUALS( style3.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
733 DALI_TEST_EQUALS( style3.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
734 DALI_TEST_EQUALS( style3.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 DALI_TEST_CHECK( style3.IsItalicsDefault() );
737 DALI_TEST_CHECK( !style3.IsItalicsEnabled() );
738 DALI_TEST_EQUALS( style3.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
740 DALI_TEST_CHECK( style3.IsUnderlineDefault() );
741 DALI_TEST_CHECK( !style3.IsUnderlineEnabled() );
742 DALI_TEST_EQUALS( style3.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 DALI_TEST_EQUALS( style3.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
745 DALI_TEST_CHECK( style3.IsShadowDefault() );
746 DALI_TEST_CHECK( !style3.IsShadowEnabled() );
747 DALI_TEST_EQUALS( style3.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
748 DALI_TEST_EQUALS( style3.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
750 DALI_TEST_CHECK( style3.IsGlowDefault() );
751 DALI_TEST_CHECK( !style3.IsGlowEnabled() );
752 DALI_TEST_EQUALS( style3.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
753 DALI_TEST_EQUALS( style3.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
755 DALI_TEST_CHECK( style3.IsOutlineDefault() );
756 DALI_TEST_CHECK( !style3.IsOutlineEnabled() );
757 DALI_TEST_EQUALS( style3.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
758 DALI_TEST_EQUALS( style3.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
760 DALI_TEST_CHECK( style3.IsGradientDefault() );
761 DALI_TEST_CHECK( !style3.IsGradientEnabled() );
762 DALI_TEST_EQUALS( style3.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
763 DALI_TEST_EQUALS( style3.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
764 DALI_TEST_EQUALS( style3.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
766 // Added to increase coverage.
767 // Reset what is already reset.
769 actor.SetTextStyle( style3 );
771 TextStyle style4 = actor.GetTextStyle();
773 DALI_TEST_EQUALS( style4.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
774 DALI_TEST_EQUALS( style4.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
775 DALI_TEST_EQUALS( style4.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
776 DALI_TEST_EQUALS( style4.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
778 DALI_TEST_EQUALS( style4.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
779 DALI_TEST_EQUALS( style4.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
781 DALI_TEST_CHECK( style4.IsItalicsDefault() );
782 DALI_TEST_CHECK( !style4.IsItalicsEnabled() );
783 DALI_TEST_EQUALS( style4.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
785 DALI_TEST_CHECK( style4.IsUnderlineDefault() );
786 DALI_TEST_CHECK( !style4.IsUnderlineEnabled() );
787 DALI_TEST_EQUALS( style4.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
788 DALI_TEST_EQUALS( style4.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
790 DALI_TEST_CHECK( style4.IsShadowDefault() );
791 DALI_TEST_CHECK( !style4.IsShadowEnabled() );
792 DALI_TEST_EQUALS( style4.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
793 DALI_TEST_EQUALS( style4.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
795 DALI_TEST_CHECK( style4.IsGlowDefault() );
796 DALI_TEST_CHECK( !style4.IsGlowEnabled() );
797 DALI_TEST_EQUALS( style4.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
798 DALI_TEST_EQUALS( style4.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
800 DALI_TEST_CHECK( style4.IsOutlineDefault() );
801 DALI_TEST_CHECK( !style4.IsOutlineEnabled() );
802 DALI_TEST_EQUALS( style4.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
803 DALI_TEST_EQUALS( style4.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
805 DALI_TEST_CHECK( style4.IsGradientDefault() );
806 DALI_TEST_CHECK( !style4.IsGradientEnabled() );
807 DALI_TEST_EQUALS( style4.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
808 DALI_TEST_EQUALS( style4.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
809 DALI_TEST_EQUALS( style4.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
814 int UtcDaliTextActorDefaultProperties(void)
816 TestApplication application;
817 tet_infoline("Testing Dali::TextActor DefaultProperties");
819 TextActor actor = TextActor::New("@");
821 std::vector<Property::Index> indices ;
822 indices.push_back(TextActor::TEXT );
823 indices.push_back(TextActor::FONT );
824 indices.push_back(TextActor::FONT_STYLE );
825 indices.push_back(TextActor::OUTLINE_ENABLE );
826 indices.push_back(TextActor::OUTLINE_COLOR );
827 indices.push_back(TextActor::OUTLINE_THICKNESS_WIDTH );
828 indices.push_back(TextActor::SMOOTH_EDGE );
829 indices.push_back(TextActor::GLOW_ENABLE );
830 indices.push_back(TextActor::GLOW_COLOR );
831 indices.push_back(TextActor::GLOW_INTENSITY );
832 indices.push_back(TextActor::SHADOW_ENABLE );
833 indices.push_back(TextActor::SHADOW_COLOR );
834 indices.push_back(TextActor::SHADOW_OFFSET );
835 indices.push_back(TextActor::ITALICS_ANGLE );
836 indices.push_back(TextActor::UNDERLINE );
837 indices.push_back(TextActor::WEIGHT );
838 indices.push_back(TextActor::FONT_DETECTION_AUTOMATIC );
839 indices.push_back(TextActor::GRADIENT_COLOR );
840 indices.push_back(TextActor::GRADIENT_START_POINT );
841 indices.push_back(TextActor::GRADIENT_END_POINT );
842 indices.push_back(TextActor::SHADOW_SIZE );
843 indices.push_back(TextActor::TEXT_COLOR );
845 DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
847 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
849 DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
850 DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) );
851 DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
852 DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds
855 // set/get one of them
856 actor.SetUnderline(false);
857 DALI_TEST_CHECK(actor.GetUnderline() != true);
859 actor.SetProperty(TextActor::UNDERLINE, Property::Value(true));
860 Property::Value v = actor.GetProperty(TextActor::UNDERLINE);
861 DALI_TEST_CHECK(v.GetType() == Property::BOOLEAN);
863 DALI_TEST_CHECK(v.Get<bool>() == true);
867 int UtcDaliTextActorSetGradientColor(void)
869 TestApplication application;
871 tet_infoline("Testing Dali::TextActor::SetGradientColor()");
873 TextActor actor = TextActor::New(TestTextHello);
875 DALI_TEST_CHECK(actor);
877 actor.SetGradientColor( Color::RED );
878 DALI_TEST_EQUALS( actor.GetGradientColor(), Color::RED, TEST_LOCATION );
880 actor.SetGradientColor( Color::BLUE );
881 DALI_TEST_EQUALS( actor.GetGradientColor(), Color::BLUE, TEST_LOCATION );
885 int UtcDaliTextActorSetGradientStartPoint(void)
887 TestApplication application;
889 tet_infoline("Testing Dali::TextActor::SetGradientStartPoint()");
891 TextActor actor = TextActor::New(TestTextHello);
893 DALI_TEST_CHECK(actor);
895 actor.SetGradientStartPoint( Vector2(0.5f, 0.5f) );
896 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(0.5f, 0.5f), TEST_LOCATION );
898 actor.SetGradientStartPoint( Vector2(1.0f, 0.0f) );
899 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(1.0f, 0.0f), TEST_LOCATION );
903 int UtcDaliTextActorSetGradientEndPoint(void)
905 TestApplication application;
907 tet_infoline("Testing Dali::TextActor::SetGradientEndPoint()");
909 TextActor actor = TextActor::New(TestTextHello);
911 DALI_TEST_CHECK(actor);
913 actor.SetGradientEndPoint( Vector2(0.25f, 0.25f) );
914 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.25f, 0.25f), TEST_LOCATION );
916 actor.SetGradientEndPoint( Vector2(0.0f, 1.0f) );
917 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.0f, 1.0f), TEST_LOCATION );
921 int UtcDaliTextActorSynchronousGlyphLoading(void)
923 TestApplication application;
925 tet_infoline( "Testing synchronous loading of glyphs");
927 // All numerals 0 through 9 are 'fake' cached in the test abstraction glyphcache
929 // create text actor containg "Hello"
930 TextActor actor = TextActor::New(TestTextHello);
932 // no glyphs will be cached
934 // so..GetGlyphData should have been called to gather metrics
935 DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:false" ) );
936 // ..but not to load glyph bitmap data
937 DALI_TEST_CHECK( ! application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
938 // ..also, cached high quality glyphs will not have been requested yet
939 DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
941 // reset PlatformAbstraction function call traces
942 application.GetPlatform().ResetTrace();
944 // Invoke Core::ProcessEvent and tick the update/render threads
945 application.SendNotification();
946 application.Render();
948 // An attempt to load high quality glyphs will have been requested and loaded nothing
949 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
950 // low quality glyphs bitmap data will have now been generated
951 DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
954 actor.SetText( "0123456789" );
956 // reset PlatformAbstraction function call traces
957 application.GetPlatform().ResetTrace();
959 application.SendNotification();
960 application.Render();
962 // An attempt to load high quality glyphs will have been requested and loaded all the numerals
963 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
964 // ..therefore no low quality glyphs bitmap data will have been requested
965 DALI_TEST_CHECK( !application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
969 int UtcDaliTextActorAutomaticSizeSet(void)
971 TestApplication application;
973 tet_infoline("Testing Dali::TextActor getting size based on text automatically");
975 // create empty text actor
976 TextActor actor = TextActor::New();
977 Stage::GetCurrent().Add(actor);
979 // initial size is zero
980 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
983 actor.SetText( "a" );
985 application.SendNotification();
986 application.Render();
988 // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger
989 Vector3 currentSize = actor.GetCurrentSize();
990 DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION );
991 DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION );
993 // set some more text
994 actor.SetText( "abba" );
996 application.SendNotification();
997 application.Render();
999 Vector3 biggerSize = actor.GetCurrentSize();
1000 DALI_TEST_GREATER( biggerSize.width, currentSize.width, TEST_LOCATION );
1002 // set some shorter text
1003 actor.SetText( "i" );
1005 application.SendNotification();
1006 application.Render();
1009 DALI_TEST_GREATER( biggerSize.width, actor.GetCurrentSize().width, TEST_LOCATION );
1011 // set a size from application side, from this point onwards text actor no longer uses the "natural" size of the text
1012 actor.SetSize( Vector2( 10.0f, 11.0f ) );
1014 application.SendNotification();
1015 application.Render();
1016 // actor has the user set size
1017 DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
1019 // set some different text
1020 std::string longText( "jabba dabba duu" );
1021 actor.SetText( longText );
1023 application.SendNotification();
1024 application.Render();
1025 // actor still has the user set size
1026 DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
1028 // set text to its natural size
1029 actor.SetToNaturalSize();
1031 application.SendNotification();
1032 application.Render();
1033 // actor has the natural size
1034 Font defaultFont = Font::New();
1035 Vector3 naturalSize = defaultFont.MeasureText( longText );
1036 DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
1040 int UtcDaliTextActorAutomaticSizeSetAnimation(void)
1042 TestApplication application;
1044 tet_infoline("Testing Dali::TextActor getting size based on text automatically with animation");
1046 // create empty text actor
1047 TextActor actor = TextActor::New();
1048 Stage::GetCurrent().Add(actor);
1050 // initial size is zero
1051 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
1054 actor.SetText( "a" );
1056 application.SendNotification();
1057 application.Render();
1059 // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger
1060 Vector3 currentSize = actor.GetCurrentSize();
1061 DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION );
1062 DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION );
1064 // animate size, from this point onwards text actor no longer uses the "natural" size of the text
1065 Animation sizeAnim = Animation::New( 0.1f ); // 0.1 seconds
1066 Vector3 animationTargetSize( 20.0f, 30.0f, 0.0f );
1067 sizeAnim.AnimateTo( Property( actor, Actor::SIZE ), animationTargetSize );
1070 // set some more text
1071 actor.SetText( "abba" );
1073 application.SendNotification();
1074 application.Render( 1000 ); // 1 second to complete the animation
1076 DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1078 // set some more text
1079 std::string moreText( "something else" );
1080 actor.SetText( moreText );
1082 application.SendNotification();
1083 application.Render();
1085 DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1087 // set text to its natural size
1088 actor.SetToNaturalSize();
1090 application.SendNotification();
1091 application.Render();
1092 // actor has the natural size
1093 Font defaultFont = Font::New();
1094 Vector3 naturalSize = defaultFont.MeasureText( moreText );
1095 DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
1100 int UtcDaliTextActorPropertyIndices(void)
1102 TestApplication application;
1103 Actor basicActor = Actor::New();
1104 TextActor textActor = TextActor::New("Text");
1106 Property::IndexContainer indices;
1107 textActor.GetPropertyIndices( indices );
1108 DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() );
1109 DALI_TEST_EQUALS( indices.size(), textActor.GetPropertyCount(), TEST_LOCATION );