Actor's Transformation API Cleanup
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TextActor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 void text_actor_test_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void text_actor_test_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 namespace
37 {
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";
41
42 static const std::string DEFAULT_NAME_STYLE( "" );
43 static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f );
44
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 );
49
50 static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT );
51 static const float SMOOTH_EDGE( 5.0f );
52
53 static const bool ITALICS( true );
54 static const Degree ITALICS_ANGLE( 10.f );
55 static const Radian ITALICS_RADIAN_ANGLE(0.4f);
56
57 static const bool UNDERLINE( true );
58 static const float UNDERLINE_THICKNESS( 5.0f );
59 static const float UNDERLINE_POSITION( 60.0f );
60
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 );
65
66 static const bool GLOW( true );
67 static const Vector4 GLOW_COLOR( Color::BLACK );
68 static const float GLOW_INTENSITY( 10.0f );
69
70 static const bool OUTLINE( true );
71 static const Vector4 OUTLINE_COLOR( Color::MAGENTA );
72 static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f );
73
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 );
78 } // anon namespace
79
80 int UtcDaliTextActorConstructorVoid(void)
81 {
82   TestApplication application;
83
84   tet_infoline("Testing Dali::TextActor::TextActor()");
85
86   TextActor actor;
87
88   DALI_TEST_CHECK(!actor);
89   END_TEST;
90 }
91
92 int UtcDaliTextActorNew01(void)
93 {
94   TestApplication application;
95
96   tet_infoline("Testing Dali::TextActor::New()");
97
98   TextActor actor = TextActor::New();
99
100   DALI_TEST_CHECK(actor);
101
102   END_TEST;
103 }
104
105
106 int UtcDaliTextActorNew02(void)
107 {
108   TestApplication application;
109
110   tet_infoline("Testing Dali::TextActor::New(const Text& text)");
111
112   TextActor actor1 = TextActor::New(TestTextHello);
113
114   DALI_TEST_CHECK(actor1);
115
116   TextActor actor2 = TextActor::New(std::string(TestTextHello));
117
118   DALI_TEST_CHECK(actor2);
119
120   TextActor actor3 = TextActor::New(Text(TestTextHello));
121
122   DALI_TEST_CHECK(actor3);
123
124   TextActor actor4 = TextActor::New(Text(std::string(TestTextHello)));
125
126   DALI_TEST_CHECK(actor4);
127
128   END_TEST;
129 }
130
131 int UtcDaliTextActorNew03(void)
132 {
133   TestApplication application;
134
135   tet_infoline("Testing Dali::TextActor::New(const Text& text, const TextActorParameters& parameters)");
136
137   TextActorParameters parameters;
138
139   TextActor actor1 = TextActor::New(TestTextHello, parameters);
140
141   DALI_TEST_CHECK(actor1);
142   DALI_TEST_CHECK(actor1.IsFontDetectionAutomatic());
143
144   TextStyle style;
145   style.SetTextColor( Color::RED );
146
147   parameters = TextActorParameters( style, TextActorParameters::FONT_DETECTION_OFF );
148
149   TextActor actor2 = TextActor::New(std::string(TestTextHello), parameters);
150
151   DALI_TEST_CHECK(actor2);
152   DALI_TEST_CHECK(!actor2.IsFontDetectionAutomatic());
153   DALI_TEST_CHECK( style.GetTextColor() == actor2.GetTextStyle().GetTextColor());
154
155   TextActor actor3 = TextActor::New(Text(TestTextHello), parameters);
156
157   DALI_TEST_CHECK(actor3);
158
159   TextActor actor4 = TextActor::New(Text(std::string(TestTextHello)), parameters);
160
161   DALI_TEST_CHECK(actor4);
162
163   END_TEST;
164 }
165
166 int UtcDaliTextActorDownCast(void)
167 {
168   TestApplication application;
169   tet_infoline("Testing Dali::TextActor::DownCast()");
170
171   TextActor actor1 = TextActor::New("Hello, World!");
172   Actor anActor = Actor::New();
173   anActor.Add(actor1);
174
175   Actor child = anActor.GetChildAt(0);
176   TextActor textActor = TextActor::DownCast(child);
177
178   DALI_TEST_CHECK(textActor);
179   DALI_TEST_CHECK(!textActor.GetText().compare("Hello, World!"));
180   END_TEST;
181 }
182
183 int UtcDaliTextActorDownCast2(void)
184 {
185   TestApplication application;
186   tet_infoline("Testing Dali::TextActor::DownCast()");
187
188   Actor actor1 = Actor::New();
189   Actor anActor = Actor::New();
190   anActor.Add(actor1);
191
192   Actor child = anActor.GetChildAt(0);
193   TextActor textActor = TextActor::DownCast(child);
194   DALI_TEST_CHECK(!textActor);
195
196   Actor unInitialzedActor;
197   textActor = DownCast< TextActor >( unInitialzedActor );
198   DALI_TEST_CHECK(!textActor);
199   END_TEST;
200 }
201
202 int UtcDaliTextActorSetText(void)
203 {
204   TestApplication application;
205
206   tet_infoline("Testing Dali::TextActor::SetText()");
207
208   TextActor actor01 = TextActor::New(TestTextHello);
209
210   actor01.SetText(TestTextHelloWorld);
211
212   std::string text = actor01.GetText();
213
214   DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
215
216   actor01.SetText(Text(std::string(TestTextHelloWorld)));
217
218   text = actor01.GetText();
219
220   DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION);
221
222   actor01.SetText("");
223
224   text = actor01.GetText();
225
226   DALI_TEST_EQUALS(text, "", TEST_LOCATION);
227
228   TextActor actor02 = TextActor::New("");
229
230   actor02.SetText( std::string() );
231
232   text = actor02.GetText();
233
234   DALI_TEST_EQUALS(text, "", TEST_LOCATION);
235
236   actor02.SetText(TestTextHelloWorld);
237   actor02.SetText( std::string() );
238
239   text = actor02.GetText();
240
241   DALI_TEST_EQUALS(text, "", TEST_LOCATION);
242
243   TextActor actor03 = TextActor::New("");
244   const Text voidText;
245   actor03.SetText(voidText);
246
247   text = actor03.GetText();
248
249   DALI_TEST_EQUALS(text, "", TEST_LOCATION);
250
251   actor03.SetText(TestTextHelloWorld);
252   actor03.SetText(voidText);
253
254   text = actor03.GetText();
255
256   DALI_TEST_EQUALS(text, "", TEST_LOCATION);
257   END_TEST;
258 }
259
260 int UtcDaliTextActorSetFont(void)
261 {
262   TestApplication application;
263
264   TextActor actor = TextActor::New(TestTextHello);
265
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() );
270
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 );
275
276   FontParameters params( FONT_FAMILY, FONT_STYLE, FONT_POINT_SIZE );
277
278   Font font = Font::New( params );
279
280   actor.SetFont( font );
281
282   Font font2 = actor.GetFont();
283
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 );
288
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 );
293
294   END_TEST;
295 }
296
297 int UtcDaliTextActorSetFontDetection(void)
298 {
299   TestApplication application;
300
301   TextActor actor = TextActor::New(TestTextHello);
302
303   actor.SetFontDetectionAutomatic( true );
304
305   DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() );
306
307   END_TEST;
308 }
309
310 int UtcDaliTextActorSetTextIndividualStyles(void)
311 {
312   TestApplication application;
313
314   TextActor actor = TextActor::New(TestTextHello);
315   TextStyle defaultStyle = actor.GetTextStyle();
316
317   DALI_TEST_EQUALS( actor.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
318   DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION );
319
320   DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
321   DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION );
322
323   DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
324
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 );
330
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 );
336
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 );
341
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 );
346
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 );
351
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 );
357
358
359   actor.SetTextColor( TEXT_COLOR );
360
361   actor.SetWeight( TEXT_WEIGHT );
362   actor.SetSmoothEdge( SMOOTH_EDGE  );
363
364   actor.SetItalics( ITALICS, ITALICS_ANGLE );
365   actor.SetUnderline( UNDERLINE );
366
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 );
373
374
375   TextStyle style = actor.GetTextStyle();
376
377   DALI_TEST_EQUALS( actor.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
378   DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION );
379
380   DALI_TEST_EQUALS( actor.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
381   DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
382
383   DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
384
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 );
390
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 );
396
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 );
401
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 );
406
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 );
411
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 );
420
421   // Added to increase coverage.
422
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 );
427
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 );
432
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 );
437
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 );
444
445   END_TEST;
446 }
447
448 int UtcDaliTextActorChangingText(void)
449 {
450   TestApplication application;
451
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);
456
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);
461
462   // do a render
463   application.SendNotification();
464   application.Render();
465
466   // check that the size did not change
467   DALI_TEST_EQUALS( Vector3(200, 20, 0.0f), actor.GetCurrentSize(), TEST_LOCATION);
468   END_TEST;
469 }
470
471 int UtcDaliTextActorGetLoadingState(void)
472 {
473   TestApplication application;
474
475   TextActor actor = TextActor::New(TestTextHello);
476
477   DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState());
478
479   application.SendNotification();
480   application.Render();
481
482   DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState());
483
484   END_TEST;
485 }
486
487 int UtcDaliTextActorSetItalics(void)
488 {
489   TestApplication application;
490
491   tet_infoline("Testing Dali::TextActor::New()");
492
493   TextActor actor = TextActor::New(TestTextHello);
494
495   DALI_TEST_CHECK(actor);
496
497   actor.SetItalics( true );
498
499   DALI_TEST_CHECK( actor.GetItalics() );
500
501   DALI_TEST_EQUALS( static_cast<float>( Degree( actor.GetItalicsAngle() ) ), static_cast<float>(TextStyle::DEFAULT_ITALICS_ANGLE), 0.0001f, TEST_LOCATION );
502
503   actor.SetItalics( false );
504
505   DALI_TEST_CHECK( ! actor.GetItalics() );
506
507   // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
508   END_TEST;
509 }
510
511 int UtcDaliTextActorSetUnderline(void)
512 {
513   TestApplication application;
514
515   tet_infoline("Testing Dali::TextActor::SetUnderline()");
516
517   TextActor actor = TextActor::New(TestTextHello);
518
519   DALI_TEST_CHECK(actor);
520
521   actor.SetUnderline( true );
522
523   DALI_TEST_CHECK( actor.GetUnderline() );
524
525   actor.SetUnderline( false );
526
527   DALI_TEST_CHECK( ! actor.GetUnderline() );
528
529   // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly
530   END_TEST;
531 }
532
533 int UtcDaliTextActorSetWeight(void)
534 {
535   TestApplication application;
536
537   tet_infoline("Testing Dali::TextActor::SetWeight()");
538
539   TextActor actor = TextActor::New(TestTextHello);
540
541   DALI_TEST_CHECK(actor);
542
543   actor.SetWeight( TextStyle::EXTRABOLD );
544
545   DALI_TEST_CHECK( TextStyle::EXTRABOLD == actor.GetWeight() );
546
547   actor.SetWeight( TextStyle::BOLD );
548
549   DALI_TEST_CHECK( TextStyle::BOLD == actor.GetWeight() );
550   END_TEST;
551 }
552
553 int UtcDaliTextActorSetStyle(void)
554 {
555   TestApplication application;
556
557   tet_infoline("Testing Dali::TextActor::SetTextStyle()");
558
559   TextActor actor = TextActor::New(TestTextHello);
560
561   const TextStyle defaultStyle = actor.GetTextStyle();
562
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 );
567
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 );
570
571   DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() );
572   DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() );
573   DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
574
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 );
579
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 );
584
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 );
589
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 );
594
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 );
600
601
602   // Set a non default style.
603
604   TextStyle style;
605   style.SetFontName( FONT_FAMILY );
606   style.SetFontStyle( FONT_STYLE );
607   style.SetFontPointSize( FONT_POINT_SIZE );
608   style.SetTextColor( TEXT_COLOR );
609
610   style.SetWeight( TEXT_WEIGHT );
611   style.SetSmoothEdge( SMOOTH_EDGE );
612
613   style.SetItalics( ITALICS, ITALICS_ANGLE );
614   style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION );
615
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 );
620
621   actor.SetTextStyle( style );
622
623   // This is necessary since SetColor (via TextStyle) is asynchronous
624   application.SendNotification();
625   application.Render();
626
627   TextStyle style2 = actor.GetTextStyle();
628
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() );
641
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 );
646
647   DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION );
648   DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
649
650   DALI_TEST_CHECK( style2.IsItalicsEnabled() );
651   DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION );
652
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 );
656
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 );
660
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 );
664
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 );
668
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 );
673
674
675   // Set a default style
676   actor.SetTextStyle( defaultStyle );
677
678   TextStyle style3 = actor.GetTextStyle();
679
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 );
684
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 );
687
688   DALI_TEST_CHECK( style3.IsItalicsDefault() );
689   DALI_TEST_CHECK( !style3.IsItalicsEnabled() );
690   DALI_TEST_EQUALS( style3.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
691
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 );
696
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 );
701
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 );
706
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 );
711
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 );
717
718   // Added to increase coverage.
719   // Reset what is already reset.
720
721   actor.SetTextStyle( style3 );
722
723   TextStyle style4 = actor.GetTextStyle();
724
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 );
729
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 );
732
733   DALI_TEST_CHECK( style4.IsItalicsDefault() );
734   DALI_TEST_CHECK( !style4.IsItalicsEnabled() );
735   DALI_TEST_EQUALS( style4.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION );
736
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 );
741
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 );
746
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 );
751
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 );
756
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 );
762
763   END_TEST;
764 }
765
766 int UtcDaliTextActorDefaultProperties(void)
767 {
768   TestApplication application;
769   tet_infoline("Testing Dali::TextActor DefaultProperties");
770
771   TextActor actor = TextActor::New("@");
772
773   std::vector<Property::Index> indices ;
774   indices.push_back(TextActor::Property::TEXT                     );
775   indices.push_back(TextActor::Property::FONT                     );
776   indices.push_back(TextActor::Property::FONT_STYLE               );
777   indices.push_back(TextActor::Property::OUTLINE_ENABLE           );
778   indices.push_back(TextActor::Property::OUTLINE_COLOR            );
779   indices.push_back(TextActor::Property::OUTLINE_THICKNESS_WIDTH  );
780   indices.push_back(TextActor::Property::SMOOTH_EDGE              );
781   indices.push_back(TextActor::Property::GLOW_ENABLE              );
782   indices.push_back(TextActor::Property::GLOW_COLOR               );
783   indices.push_back(TextActor::Property::GLOW_INTENSITY           );
784   indices.push_back(TextActor::Property::SHADOW_ENABLE            );
785   indices.push_back(TextActor::Property::SHADOW_COLOR             );
786   indices.push_back(TextActor::Property::SHADOW_OFFSET            );
787   indices.push_back(TextActor::Property::ITALICS_ANGLE            );
788   indices.push_back(TextActor::Property::UNDERLINE                );
789   indices.push_back(TextActor::Property::WEIGHT                   );
790   indices.push_back(TextActor::Property::FONT_DETECTION_AUTOMATIC );
791   indices.push_back(TextActor::Property::GRADIENT_COLOR           );
792   indices.push_back(TextActor::Property::GRADIENT_START_POINT     );
793   indices.push_back(TextActor::Property::GRADIENT_END_POINT       );
794   indices.push_back(TextActor::Property::SHADOW_SIZE              );
795   indices.push_back(TextActor::Property::TEXT_COLOR               );
796
797   DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
798
799   for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
800   {
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
805   }
806
807   // set/get one of them
808   actor.SetUnderline(false);
809   DALI_TEST_CHECK(actor.GetUnderline() != true);
810
811   actor.SetProperty(TextActor::Property::UNDERLINE, Property::Value(true));
812   Property::Value v = actor.GetProperty(TextActor::Property::UNDERLINE);
813   DALI_TEST_CHECK(v.GetType() == Property::BOOLEAN);
814
815   DALI_TEST_CHECK(v.Get<bool>() == true);
816   END_TEST;
817 }
818
819 int UtcDaliTextActorSetGradientColor(void)
820 {
821   TestApplication application;
822
823   tet_infoline("Testing Dali::TextActor::SetGradientColor()");
824
825   TextActor actor = TextActor::New(TestTextHello);
826
827   DALI_TEST_CHECK(actor);
828
829   actor.SetGradientColor( Color::RED );
830   DALI_TEST_EQUALS( actor.GetGradientColor(), Color::RED, TEST_LOCATION );
831
832   actor.SetGradientColor( Color::BLUE );
833   DALI_TEST_EQUALS( actor.GetGradientColor(), Color::BLUE, TEST_LOCATION );
834   END_TEST;
835 }
836
837 int UtcDaliTextActorSetGradientStartPoint(void)
838 {
839   TestApplication application;
840
841   tet_infoline("Testing Dali::TextActor::SetGradientStartPoint()");
842
843   TextActor actor = TextActor::New(TestTextHello);
844
845   DALI_TEST_CHECK(actor);
846
847   actor.SetGradientStartPoint( Vector2(0.5f, 0.5f) );
848   DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(0.5f, 0.5f), TEST_LOCATION );
849
850   actor.SetGradientStartPoint( Vector2(1.0f, 0.0f) );
851   DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(1.0f, 0.0f), TEST_LOCATION );
852   END_TEST;
853 }
854
855 int UtcDaliTextActorSetGradientEndPoint(void)
856 {
857   TestApplication application;
858
859   tet_infoline("Testing Dali::TextActor::SetGradientEndPoint()");
860
861   TextActor actor = TextActor::New(TestTextHello);
862
863   DALI_TEST_CHECK(actor);
864
865   actor.SetGradientEndPoint( Vector2(0.25f, 0.25f) );
866   DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.25f, 0.25f), TEST_LOCATION );
867
868   actor.SetGradientEndPoint( Vector2(0.0f, 1.0f) );
869   DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.0f, 1.0f), TEST_LOCATION );
870   END_TEST;
871 }
872
873 int UtcDaliTextActorSynchronousGlyphLoading(void)
874 {
875   TestApplication application;
876
877   tet_infoline( "Testing synchronous loading of glyphs");
878
879   // All numerals 0 through 9 are 'fake' cached in the test abstraction glyphcache
880
881   // create text actor containg "Hello"
882   TextActor actor = TextActor::New(TestTextHello);
883
884   // no glyphs will be cached
885
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) );
892
893   // reset PlatformAbstraction function call traces
894   application.GetPlatform().ResetTrace();
895
896   // Invoke Core::ProcessEvent and tick the update/render threads
897   application.SendNotification();
898   application.Render();
899
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" ) );
904
905   // request numerals
906   actor.SetText( "0123456789" );
907
908   // reset PlatformAbstraction function call traces
909   application.GetPlatform().ResetTrace();
910
911   application.SendNotification();
912   application.Render();
913
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" ) );
918   END_TEST;
919 }
920
921 int UtcDaliTextActorAutomaticSizeSet(void)
922 {
923   TestApplication application;
924
925   tet_infoline("Testing Dali::TextActor getting size based on text automatically");
926
927   // create empty text actor
928   TextActor actor = TextActor::New();
929   Stage::GetCurrent().Add(actor);
930
931   // initial size is zero
932   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
933
934   // set some text
935   actor.SetText( "a" );
936   // render a frame
937   application.SendNotification();
938   application.Render();
939
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 );
944
945   // set some more text
946   actor.SetText( "abba" );
947   // render a frame
948   application.SendNotification();
949   application.Render();
950
951   Vector3 biggerSize = actor.GetCurrentSize();
952   DALI_TEST_GREATER( biggerSize.width, currentSize.width, TEST_LOCATION );
953
954   // set some shorter text
955   actor.SetText( "i" );
956   // render a frame
957   application.SendNotification();
958   application.Render();
959
960   // actor has shrunk
961   DALI_TEST_GREATER( biggerSize.width, actor.GetCurrentSize().width, TEST_LOCATION );
962
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 ) );
965   // render a frame
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 );
970
971   // set some different text
972   std::string longText( "jabba dabba duu" );
973   actor.SetText( longText );
974   // render a frame
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 );
979
980   // set text to its natural size
981   actor.SetToNaturalSize();
982   // render a frame
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 );
989   END_TEST;
990 }
991
992 int UtcDaliTextActorAutomaticSizeSetAnimation(void)
993 {
994   TestApplication application;
995
996   tet_infoline("Testing Dali::TextActor getting size based on text automatically with animation");
997
998   // create empty text actor
999   TextActor actor = TextActor::New();
1000   Stage::GetCurrent().Add(actor);
1001
1002   // initial size is zero
1003   DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION );
1004
1005   // set some text
1006   actor.SetText( "a" );
1007   // render a frame
1008   application.SendNotification();
1009   application.Render();
1010
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 );
1015
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::Property::SIZE ), animationTargetSize );
1020   sizeAnim.Play();
1021
1022   // set some more text
1023   actor.SetText( "abba" );
1024   // render a frame
1025   application.SendNotification();
1026   application.Render( 1000 ); // 1 second to complete the animation
1027
1028   DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1029
1030   // set some more text
1031   std::string moreText( "something else" );
1032   actor.SetText( moreText );
1033   // render a frame
1034   application.SendNotification();
1035   application.Render();
1036
1037   DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION );
1038
1039   // set text to its natural size
1040   actor.SetToNaturalSize();
1041   // render a frame
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 );
1048   END_TEST;
1049 }
1050
1051
1052 int UtcDaliTextActorPropertyIndices(void)
1053 {
1054   TestApplication application;
1055   Actor basicActor = Actor::New();
1056   TextActor textActor = TextActor::New("Text");
1057
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 );
1062   END_TEST;
1063 }
1064
1065 int UtcDaliTextActorGetNaturalSize(void)
1066 {
1067   TestApplication application;
1068
1069   TextActor actor = TextActor::New();
1070   std::string text( "something else" );
1071   actor.SetText( text );
1072
1073   Font defaultFont = Font::New();
1074   Vector3 naturalSize = defaultFont.MeasureText( text );
1075
1076   DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == naturalSize.GetVectorXY() );
1077
1078   END_TEST;
1079 }