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();
100 DALI_TEST_CHECK(actor);
106 int UtcDaliTextActorNew02(void)
108 TestApplication application;
110 tet_infoline("Testing Dali::TextActor::New(const Text& text)");
112 TextActor actor1 = TextActor::New(TestTextHello);
114 DALI_TEST_CHECK(actor1);
116 TextActor actor2 = TextActor::New(std::string(TestTextHello));
118 DALI_TEST_CHECK(actor2);
120 TextActor actor3 = TextActor::New(Text(TestTextHello));
122 DALI_TEST_CHECK(actor3);
124 TextActor actor4 = TextActor::New(Text(std::string(TestTextHello)));
126 DALI_TEST_CHECK(actor4);
131 int UtcDaliTextActorNew03(void)
133 TestApplication application;
135 tet_infoline("Testing Dali::TextActor::New(const Text& text, const TextActorParameters& parameters)");
137 TextActorParameters parameters;
139 TextActor actor1 = TextActor::New(TestTextHello, parameters);
141 DALI_TEST_CHECK(actor1);
142 DALI_TEST_CHECK(actor1.IsFontDetectionAutomatic());
145 style.SetTextColor( Color::RED );
147 parameters = TextActorParameters( style, TextActorParameters::FONT_DETECTION_OFF );
149 TextActor actor2 = TextActor::New(std::string(TestTextHello), parameters);
151 DALI_TEST_CHECK(actor2);
152 DALI_TEST_CHECK(!actor2.IsFontDetectionAutomatic());
153 DALI_TEST_CHECK( style.GetTextColor() == actor2.GetTextStyle().GetTextColor());
155 TextActor actor3 = TextActor::New(Text(TestTextHello), parameters);
157 DALI_TEST_CHECK(actor3);
159 TextActor actor4 = TextActor::New(Text(std::string(TestTextHello)), parameters);
161 DALI_TEST_CHECK(actor4);
166 int UtcDaliTextActorDownCast(void)
168 TestApplication application;
169 tet_infoline("Testing Dali::TextActor::DownCast()");
171 TextActor actor1 = TextActor::New("Hello, World!");
172 Actor anActor = Actor::New();
175 Actor child = anActor.GetChildAt(0);
176 TextActor textActor = TextActor::DownCast(child);
178 DALI_TEST_CHECK(textActor);
179 DALI_TEST_CHECK(!textActor.GetText().compare("Hello, World!"));
183 int UtcDaliTextActorDownCast2(void)
185 TestApplication application;
186 tet_infoline("Testing Dali::TextActor::DownCast()");
188 Actor actor1 = Actor::New();
189 Actor anActor = Actor::New();
192 Actor child = anActor.GetChildAt(0);
193 TextActor textActor = TextActor::DownCast(child);
194 DALI_TEST_CHECK(!textActor);
196 Actor unInitialzedActor;
197 textActor = DownCast< TextActor >( unInitialzedActor );
198 DALI_TEST_CHECK(!textActor);
202 int UtcDaliTextActorSetText(void)
204 TestApplication application;
206 tet_infoline("Testing Dali::TextActor::SetText()");
208 TextActor actor01 = TextActor::New(TestTextHello);
210 actor01.SetText(TestTextHelloWorld);
212 std::string text = actor01.GetText();
214 DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
216 actor01.SetText(Text(std::string(TestTextHelloWorld)));
218 text = actor01.GetText();
220 DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
224 text = actor01.GetText();
226 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
228 TextActor actor02 = TextActor::New("");
230 actor02.SetText( std::string() );
232 text = actor02.GetText();
234 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
236 actor02.SetText(TestTextHelloWorld);
237 actor02.SetText( std::string() );
239 text = actor02.GetText();
241 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
243 TextActor actor03 = TextActor::New("");
245 actor03.SetText(voidText);
247 text = actor03.GetText();
249 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
251 actor03.SetText(TestTextHelloWorld);
252 actor03.SetText(voidText);
254 text = actor03.GetText();
256 DALI_TEST_EQUALS(text, "", TEST_LOCATION);
260 int UtcDaliTextActorSetFont(void)
262 TestApplication application;
264 TextActor actor = TextActor::New(TestTextHello);
266 Font defaultFont = actor.GetFont();
267 DALI_TEST_EQUALS( defaultFont.GetName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
268 DALI_TEST_EQUALS( defaultFont.GetStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
269 DALI_TEST_CHECK( defaultFont.IsDefaultSystemSize() );
271 TextStyle defaultStyle = actor.GetTextStyle();
272 DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
273 DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
274 DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
276 FontParameters params( FONT_FAMILY, FONT_STYLE, FONT_POINT_SIZE );
278 Font font = Font::New( params );
280 actor.SetFont( font );
282 Font font2 = actor.GetFont();
284 DALI_TEST_EQUALS( font2.GetName(), FONT_FAMILY, TEST_LOCATION );
285 DALI_TEST_EQUALS( font2.GetStyle(), FONT_STYLE, TEST_LOCATION );
286 DALI_TEST_CHECK( !font2.IsDefaultSystemSize() );
287 DALI_TEST_EQUALS( PointSize( font2.GetPointSize() ), FONT_POINT_SIZE, TEST_LOCATION );
289 TextStyle style = actor.GetTextStyle();
290 DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION );
291 DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
292 DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
297 int UtcDaliTextActorSetFontDetection(void)
299 TestApplication application;
301 TextActor actor = TextActor::New(TestTextHello);
303 actor.SetFontDetectionAutomatic( true );
305 DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() );
310 int UtcDaliTextActorSetTextIndividualStyles(void)
312 TestApplication application;
314 TextActor actor = TextActor::New(TestTextHello);
315 TextStyle defaultStyle = actor.GetTextStyle();
317 DALI_TEST_EQUALS( actor.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
318 DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
320 DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
321 DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
323 DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
325 DALI_TEST_CHECK( !actor.GetItalics() );
326 DALI_TEST_EQUALS( actor.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
327 DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
328 DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
329 DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
331 DALI_TEST_CHECK( !actor.GetUnderline() );
332 DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
333 DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
334 DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
335 DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
337 DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
338 DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
339 DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
340 DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
342 DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
343 DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
344 DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
345 DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
347 DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
348 DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
349 DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
350 DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
352 DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
353 DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
354 DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
355 DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
356 DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
359 actor.SetTextColor( TEXT_COLOR );
361 actor.SetWeight( TEXT_WEIGHT );
362 actor.SetSmoothEdge( SMOOTH_EDGE );
364 actor.SetItalics( ITALICS, ITALICS_ANGLE );
365 actor.SetUnderline( UNDERLINE );
367 actor.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
368 actor.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
369 actor.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
370 actor.SetGradientColor( GRADIENT_COLOR );
371 actor.SetGradientStartPoint( GRADIENT_START_POINT );
372 actor.SetGradientEndPoint( GRADIENT_END_POINT );
375 TextStyle style = actor.GetTextStyle();
377 DALI_TEST_EQUALS( actor.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
378 DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
380 DALI_TEST_EQUALS( actor.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
381 DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
383 DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
385 DALI_TEST_CHECK( actor.GetItalics() );
386 DALI_TEST_EQUALS( actor.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
387 DALI_TEST_CHECK( !style.IsItalicsDefault() );
388 DALI_TEST_CHECK( style.IsItalicsEnabled() );
389 DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
391 DALI_TEST_CHECK( actor.GetUnderline() );
392 DALI_TEST_CHECK( !style.IsUnderlineDefault() );
393 DALI_TEST_CHECK( style.IsUnderlineEnabled() );
394 DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
395 DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
397 DALI_TEST_CHECK( !style.IsShadowDefault() );
398 DALI_TEST_CHECK( style.IsShadowEnabled() );
399 DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
400 DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
402 DALI_TEST_CHECK( !style.IsGlowDefault() );
403 DALI_TEST_CHECK( style.IsGlowEnabled() );
404 DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
405 DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
407 DALI_TEST_CHECK( !style.IsOutlineDefault() );
408 DALI_TEST_CHECK( style.IsOutlineEnabled() );
409 DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
410 DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
412 DALI_TEST_EQUALS( actor.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
413 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
414 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
415 DALI_TEST_CHECK( !style.IsGradientDefault() );
416 DALI_TEST_CHECK( style.IsGradientEnabled() );
417 DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
418 DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
419 DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
421 // Added to increase coverage.
423 // Set a different color.
424 actor.SetTextColor( TEXT_COLOR );
425 actor.SetTextColor( Color::GREEN );
426 DALI_TEST_EQUALS( actor.GetTextColor(), Color::GREEN, TEST_LOCATION );
428 // Set a different weight
429 actor.SetWeight( TEXT_WEIGHT );
430 actor.SetWeight( TextStyle::BOLD );
431 DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::BOLD, TEST_LOCATION );
433 // Set a different smooth edge
434 actor.SetSmoothEdge( SMOOTH_EDGE );
435 actor.SetSmoothEdge( 1.f );
436 DALI_TEST_EQUALS( actor.GetTextStyle().GetSmoothEdge(), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
438 // Set different italic parameters
439 actor.SetItalics( true, ITALICS_ANGLE );
440 actor.SetItalics( false );
441 DALI_TEST_CHECK( !actor.GetItalics() );
442 actor.SetItalics( true, Degree( 15.f ) );
443 DALI_TEST_EQUALS( actor.GetItalicsAngle(), Degree( 15.f ), TEST_LOCATION );
448 int UtcDaliTextActorChangingText(void)
450 TestApplication application;
452 TextActor actor = TextActor::New(TestTextHello);
453 actor.SetSize(Vector3(200, 20, 0.0f));
454 actor.SetPosition(20.0f, 400.0f, 40.0f);
455 Stage::GetCurrent().Add(actor);
457 tet_infoline("Testing Dali::TextActor::SetText() & Dali::TextActor::GetText()");
458 actor.SetText(LongTestText);
459 std::string text = actor.GetText();
460 DALI_TEST_EQUALS(text, LongTestText, TEST_LOCATION);
463 application.SendNotification();
464 application.Render();
466 // check that the size did not change
467 DALI_TEST_EQUALS( Vector3(200, 20, 0.0f), actor.GetCurrentSize(), TEST_LOCATION);
471 int UtcDaliTextActorGetLoadingState(void)
473 TestApplication application;
475 TextActor actor = TextActor::New(TestTextHello);
477 DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState());
479 application.SendNotification();
480 application.Render();
482 DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState());
487 int UtcDaliTextActorSetItalics(void)
489 TestApplication application;
491 tet_infoline("Testing Dali::TextActor::New()");
493 TextActor actor = TextActor::New(TestTextHello);
495 DALI_TEST_CHECK(actor);
497 actor.SetItalics( true );
499 DALI_TEST_CHECK( actor.GetItalics() );
501 DALI_TEST_EQUALS( static_cast<float>( Degree( actor.GetItalicsAngle() ) ), static_cast<float>(TextStyle::DEFAULT_ITALICS_ANGLE), 0.0001f, TEST_LOCATION );
503 actor.SetItalics( false );
505 DALI_TEST_CHECK( ! actor.GetItalics() );
507 // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
511 int UtcDaliTextActorSetUnderline(void)
513 TestApplication application;
515 tet_infoline("Testing Dali::TextActor::SetUnderline()");
517 TextActor actor = TextActor::New(TestTextHello);
519 DALI_TEST_CHECK(actor);
521 actor.SetUnderline( true );
523 DALI_TEST_CHECK( actor.GetUnderline() );
525 actor.SetUnderline( false );
527 DALI_TEST_CHECK( ! actor.GetUnderline() );
529 // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
533 int UtcDaliTextActorSetWeight(void)
535 TestApplication application;
537 tet_infoline("Testing Dali::TextActor::SetWeight()");
539 TextActor actor = TextActor::New(TestTextHello);
541 DALI_TEST_CHECK(actor);
543 actor.SetWeight( TextStyle::EXTRABOLD );
545 DALI_TEST_CHECK( TextStyle::EXTRABOLD == actor.GetWeight() );
547 actor.SetWeight( TextStyle::BOLD );
549 DALI_TEST_CHECK( TextStyle::BOLD == actor.GetWeight() );
553 int UtcDaliTextActorSetStyle(void)
555 TestApplication application;
557 tet_infoline("Testing Dali::TextActor::SetTextStyle()");
559 TextActor actor = TextActor::New(TestTextHello);
561 const TextStyle defaultStyle = actor.GetTextStyle();
563 DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
564 DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
565 DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
566 DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
568 DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
569 DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
571 DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
572 DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
573 DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
575 DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() );
576 DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() );
577 DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
578 DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
580 DALI_TEST_CHECK( defaultStyle.IsShadowDefault() );
581 DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() );
582 DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
583 DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
585 DALI_TEST_CHECK( defaultStyle.IsGlowDefault() );
586 DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() );
587 DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
588 DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
590 DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() );
591 DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() );
592 DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
593 DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
595 DALI_TEST_CHECK( defaultStyle.IsGradientDefault() );
596 DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() );
597 DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
598 DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
599 DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
602 // Set a non default style.
605 style.SetFontName( FONT_FAMILY );
606 style.SetFontStyle( FONT_STYLE );
607 style.SetFontPointSize( FONT_POINT_SIZE );
608 style.SetTextColor( TEXT_COLOR );
610 style.SetWeight( TEXT_WEIGHT );
611 style.SetSmoothEdge( SMOOTH_EDGE );
613 style.SetItalics( ITALICS, ITALICS_ANGLE );
614 style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
616 style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE );
617 style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY );
618 style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS );
619 style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT );
621 actor.SetTextStyle( style );
623 // This is necessary since SetColor (via TextStyle) is asynchronous
624 application.SendNotification();
625 application.Render();
627 TextStyle style2 = actor.GetTextStyle();
629 DALI_TEST_CHECK( !style2.IsFontNameDefault() );
630 DALI_TEST_CHECK( !style2.IsFontStyleDefault() );
631 DALI_TEST_CHECK( !style2.IsFontSizeDefault() );
632 DALI_TEST_CHECK( !style2.IsTextColorDefault() );
633 DALI_TEST_CHECK( !style2.IsFontWeightDefault() );
634 DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() );
635 DALI_TEST_CHECK( !style2.IsItalicsDefault() );
636 DALI_TEST_CHECK( !style2.IsUnderlineDefault() );
637 DALI_TEST_CHECK( !style2.IsShadowDefault() );
638 DALI_TEST_CHECK( !style2.IsGlowDefault() );
639 DALI_TEST_CHECK( !style2.IsOutlineDefault() );
640 DALI_TEST_CHECK( !style2.IsGradientDefault() );
642 DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION );
643 DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION );
644 DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION );
645 DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
647 DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
648 DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 DALI_TEST_CHECK( style2.IsItalicsEnabled() );
651 DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
653 DALI_TEST_CHECK( style2.IsUnderlineEnabled() );
654 DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 DALI_TEST_CHECK( style2.IsShadowEnabled() );
658 DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION );
659 DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION );
661 DALI_TEST_CHECK( style2.IsGlowEnabled() );
662 DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION );
663 DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
665 DALI_TEST_CHECK( style2.IsOutlineEnabled() );
666 DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION );
667 DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION );
669 DALI_TEST_CHECK( style2.IsGradientEnabled() );
670 DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION );
671 DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION );
672 DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION );
675 // Set a default style
676 actor.SetTextStyle( defaultStyle );
678 TextStyle style3 = actor.GetTextStyle();
680 DALI_TEST_EQUALS( style3.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
681 DALI_TEST_EQUALS( style3.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
682 DALI_TEST_EQUALS( style3.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
683 DALI_TEST_EQUALS( style3.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
685 DALI_TEST_EQUALS( style3.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
686 DALI_TEST_EQUALS( style3.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
688 DALI_TEST_CHECK( style3.IsItalicsDefault() );
689 DALI_TEST_CHECK( !style3.IsItalicsEnabled() );
690 DALI_TEST_EQUALS( style3.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
692 DALI_TEST_CHECK( style3.IsUnderlineDefault() );
693 DALI_TEST_CHECK( !style3.IsUnderlineEnabled() );
694 DALI_TEST_EQUALS( style3.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
695 DALI_TEST_EQUALS( style3.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
697 DALI_TEST_CHECK( style3.IsShadowDefault() );
698 DALI_TEST_CHECK( !style3.IsShadowEnabled() );
699 DALI_TEST_EQUALS( style3.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
700 DALI_TEST_EQUALS( style3.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
702 DALI_TEST_CHECK( style3.IsGlowDefault() );
703 DALI_TEST_CHECK( !style3.IsGlowEnabled() );
704 DALI_TEST_EQUALS( style3.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
705 DALI_TEST_EQUALS( style3.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
707 DALI_TEST_CHECK( style3.IsOutlineDefault() );
708 DALI_TEST_CHECK( !style3.IsOutlineEnabled() );
709 DALI_TEST_EQUALS( style3.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
710 DALI_TEST_EQUALS( style3.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
712 DALI_TEST_CHECK( style3.IsGradientDefault() );
713 DALI_TEST_CHECK( !style3.IsGradientEnabled() );
714 DALI_TEST_EQUALS( style3.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
715 DALI_TEST_EQUALS( style3.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
716 DALI_TEST_EQUALS( style3.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
718 // Added to increase coverage.
719 // Reset what is already reset.
721 actor.SetTextStyle( style3 );
723 TextStyle style4 = actor.GetTextStyle();
725 DALI_TEST_EQUALS( style4.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION );
726 DALI_TEST_EQUALS( style4.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION );
727 DALI_TEST_EQUALS( style4.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION );
728 DALI_TEST_EQUALS( style4.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
730 DALI_TEST_EQUALS( style4.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
731 DALI_TEST_EQUALS( style4.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
733 DALI_TEST_CHECK( style4.IsItalicsDefault() );
734 DALI_TEST_CHECK( !style4.IsItalicsEnabled() );
735 DALI_TEST_EQUALS( style4.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
737 DALI_TEST_CHECK( style4.IsUnderlineDefault() );
738 DALI_TEST_CHECK( !style4.IsUnderlineEnabled() );
739 DALI_TEST_EQUALS( style4.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
740 DALI_TEST_EQUALS( style4.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742 DALI_TEST_CHECK( style4.IsShadowDefault() );
743 DALI_TEST_CHECK( !style4.IsShadowEnabled() );
744 DALI_TEST_EQUALS( style4.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION );
745 DALI_TEST_EQUALS( style4.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION );
747 DALI_TEST_CHECK( style4.IsGlowDefault() );
748 DALI_TEST_CHECK( !style4.IsGlowEnabled() );
749 DALI_TEST_EQUALS( style4.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION );
750 DALI_TEST_EQUALS( style4.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 DALI_TEST_CHECK( style4.IsOutlineDefault() );
753 DALI_TEST_CHECK( !style4.IsOutlineEnabled() );
754 DALI_TEST_EQUALS( style4.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION );
755 DALI_TEST_EQUALS( style4.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION );
757 DALI_TEST_CHECK( style4.IsGradientDefault() );
758 DALI_TEST_CHECK( !style4.IsGradientEnabled() );
759 DALI_TEST_EQUALS( style4.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION );
760 DALI_TEST_EQUALS( style4.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION );
761 DALI_TEST_EQUALS( style4.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION );
766 int UtcDaliTextActorDefaultProperties(void)
768 TestApplication application;
769 tet_infoline("Testing Dali::TextActor DefaultProperties");
771 TextActor actor = TextActor::New("@");
773 std::vector<Property::Index> indices ;
774 indices.push_back(TextActor::TEXT );
775 indices.push_back(TextActor::FONT );
776 indices.push_back(TextActor::FONT_STYLE );
777 indices.push_back(TextActor::OUTLINE_ENABLE );
778 indices.push_back(TextActor::OUTLINE_COLOR );
779 indices.push_back(TextActor::OUTLINE_THICKNESS_WIDTH );
780 indices.push_back(TextActor::SMOOTH_EDGE );
781 indices.push_back(TextActor::GLOW_ENABLE );
782 indices.push_back(TextActor::GLOW_COLOR );
783 indices.push_back(TextActor::GLOW_INTENSITY );
784 indices.push_back(TextActor::SHADOW_ENABLE );
785 indices.push_back(TextActor::SHADOW_COLOR );
786 indices.push_back(TextActor::SHADOW_OFFSET );
787 indices.push_back(TextActor::ITALICS_ANGLE );
788 indices.push_back(TextActor::UNDERLINE );
789 indices.push_back(TextActor::WEIGHT );
790 indices.push_back(TextActor::FONT_DETECTION_AUTOMATIC );
791 indices.push_back(TextActor::GRADIENT_COLOR );
792 indices.push_back(TextActor::GRADIENT_START_POINT );
793 indices.push_back(TextActor::GRADIENT_END_POINT );
794 indices.push_back(TextActor::SHADOW_SIZE );
795 indices.push_back(TextActor::TEXT_COLOR );
797 DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
799 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
801 DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
802 DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) );
803 DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
804 DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds
807 // set/get one of them
808 actor.SetUnderline(false);
809 DALI_TEST_CHECK(actor.GetUnderline() != true);
811 actor.SetProperty(TextActor::UNDERLINE, Property::Value(true));
812 Property::Value v = actor.GetProperty(TextActor::UNDERLINE);
813 DALI_TEST_CHECK(v.GetType() == Property::BOOLEAN);
815 DALI_TEST_CHECK(v.Get<bool>() == true);
819 int UtcDaliTextActorSetGradientColor(void)
821 TestApplication application;
823 tet_infoline("Testing Dali::TextActor::SetGradientColor()");
825 TextActor actor = TextActor::New(TestTextHello);
827 DALI_TEST_CHECK(actor);
829 actor.SetGradientColor( Color::RED );
830 DALI_TEST_EQUALS( actor.GetGradientColor(), Color::RED, TEST_LOCATION );
832 actor.SetGradientColor( Color::BLUE );
833 DALI_TEST_EQUALS( actor.GetGradientColor(), Color::BLUE, TEST_LOCATION );
837 int UtcDaliTextActorSetGradientStartPoint(void)
839 TestApplication application;
841 tet_infoline("Testing Dali::TextActor::SetGradientStartPoint()");
843 TextActor actor = TextActor::New(TestTextHello);
845 DALI_TEST_CHECK(actor);
847 actor.SetGradientStartPoint( Vector2(0.5f, 0.5f) );
848 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(0.5f, 0.5f), TEST_LOCATION );
850 actor.SetGradientStartPoint( Vector2(1.0f, 0.0f) );
851 DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(1.0f, 0.0f), TEST_LOCATION );
855 int UtcDaliTextActorSetGradientEndPoint(void)
857 TestApplication application;
859 tet_infoline("Testing Dali::TextActor::SetGradientEndPoint()");
861 TextActor actor = TextActor::New(TestTextHello);
863 DALI_TEST_CHECK(actor);
865 actor.SetGradientEndPoint( Vector2(0.25f, 0.25f) );
866 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.25f, 0.25f), TEST_LOCATION );
868 actor.SetGradientEndPoint( Vector2(0.0f, 1.0f) );
869 DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.0f, 1.0f), TEST_LOCATION );
873 int UtcDaliTextActorSynchronousGlyphLoading(void)
875 TestApplication application;
877 tet_infoline( "Testing synchronous loading of glyphs");
879 // All numerals 0 through 9 are 'fake' cached in the test abstraction glyphcache
881 // create text actor containg "Hello"
882 TextActor actor = TextActor::New(TestTextHello);
884 // no glyphs will be cached
886 // so..GetGlyphData should have been called to gather metrics
887 DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:false" ) );
888 // ..but not to load glyph bitmap data
889 DALI_TEST_CHECK( ! application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
890 // ..also, cached high quality glyphs will not have been requested yet
891 DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
893 // reset PlatformAbstraction function call traces
894 application.GetPlatform().ResetTrace();
896 // Invoke Core::ProcessEvent and tick the update/render threads
897 application.SendNotification();
898 application.Render();
900 // An attempt to load high quality glyphs will have been requested and loaded nothing
901 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
902 // low quality glyphs bitmap data will have now been generated
903 DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
906 actor.SetText( "0123456789" );
908 // reset PlatformAbstraction function call traces
909 application.GetPlatform().ResetTrace();
911 application.SendNotification();
912 application.Render();
914 // An attempt to load high quality glyphs will have been requested and loaded all the numerals
915 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) );
916 // ..therefore no low quality glyphs bitmap data will have been requested
917 DALI_TEST_CHECK( !application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) );
921 int UtcDaliTextActorAutomaticSizeSet(void)
923 TestApplication application;
925 tet_infoline("Testing Dali::TextActor getting size based on text automatically");
927 // create empty text actor
928 TextActor actor = TextActor::New();
929 Stage::GetCurrent().Add(actor);
931 // initial size is zero
932 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
935 actor.SetText( "a" );
937 application.SendNotification();
938 application.Render();
940 // 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
941 Vector3 currentSize = actor.GetCurrentSize();
942 DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION );
943 DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION );
945 // set some more text
946 actor.SetText( "abba" );
948 application.SendNotification();
949 application.Render();
951 Vector3 biggerSize = actor.GetCurrentSize();
952 DALI_TEST_GREATER( biggerSize.width, currentSize.width, TEST_LOCATION );
954 // set some shorter text
955 actor.SetText( "i" );
957 application.SendNotification();
958 application.Render();
961 DALI_TEST_GREATER( biggerSize.width, actor.GetCurrentSize().width, TEST_LOCATION );
963 // set a size from application side, from this point onwards text actor no longer uses the "natural" size of the text
964 actor.SetSize( Vector2( 10.0f, 11.0f ) );
966 application.SendNotification();
967 application.Render();
968 // actor has the user set size
969 DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
971 // set some different text
972 std::string longText( "jabba dabba duu" );
973 actor.SetText( longText );
975 application.SendNotification();
976 application.Render();
977 // actor still has the user set size
978 DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
980 // set text to its natural size
981 actor.SetToNaturalSize();
983 application.SendNotification();
984 application.Render();
985 // actor has the natural size
986 Font defaultFont = Font::New();
987 Vector3 naturalSize = defaultFont.MeasureText( longText );
988 DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
992 int UtcDaliTextActorAutomaticSizeSetAnimation(void)
994 TestApplication application;
996 tet_infoline("Testing Dali::TextActor getting size based on text automatically with animation");
998 // create empty text actor
999 TextActor actor = TextActor::New();
1000 Stage::GetCurrent().Add(actor);
1002 // initial size is zero
1003 DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
1006 actor.SetText( "a" );
1008 application.SendNotification();
1009 application.Render();
1011 // 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
1012 Vector3 currentSize = actor.GetCurrentSize();
1013 DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION );
1014 DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION );
1016 // animate size, from this point onwards text actor no longer uses the "natural" size of the text
1017 Animation sizeAnim = Animation::New( 0.1f ); // 0.1 seconds
1018 Vector3 animationTargetSize( 20.0f, 30.0f, 0.0f );
1019 sizeAnim.AnimateTo( Property( actor, Actor::SIZE ), animationTargetSize );
1022 // set some more text
1023 actor.SetText( "abba" );
1025 application.SendNotification();
1026 application.Render( 1000 ); // 1 second to complete the animation
1028 DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1030 // set some more text
1031 std::string moreText( "something else" );
1032 actor.SetText( moreText );
1034 application.SendNotification();
1035 application.Render();
1037 DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1039 // set text to its natural size
1040 actor.SetToNaturalSize();
1042 application.SendNotification();
1043 application.Render();
1044 // actor has the natural size
1045 Font defaultFont = Font::New();
1046 Vector3 naturalSize = defaultFont.MeasureText( moreText );
1047 DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
1052 int UtcDaliTextActorPropertyIndices(void)
1054 TestApplication application;
1055 Actor basicActor = Actor::New();
1056 TextActor textActor = TextActor::New("Text");
1058 Property::IndexContainer indices;
1059 textActor.GetPropertyIndices( indices );
1060 DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() );
1061 DALI_TEST_EQUALS( indices.size(), textActor.GetPropertyCount(), TEST_LOCATION );
1065 int UtcDaliTextActorGetNaturalSize(void)
1067 TestApplication application;
1069 TextActor actor = TextActor::New();
1070 std::string text( "something else" );
1071 actor.SetText( text );
1073 Font defaultFont = Font::New();
1074 Vector3 naturalSize = defaultFont.MeasureText( text );
1076 DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == naturalSize.GetVectorXY() );