Fixed an incorrect ellipsis
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Text-ViewModel.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <toolkit-text-utils.h>
25 #include <dali-toolkit/internal/text/font-description-run.h>
26 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
27 #include <dali-toolkit/internal/text/rendering/view-model.h>
28 #include <dali-toolkit/internal/text/text-controller.h>
29
30 using namespace Dali;
31 using namespace Toolkit;
32 using namespace Text;
33
34 namespace
35 {
36
37 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
38
39 const Size CONTROL_SIZE( 200.f, 400.f );
40 const Size CONTROL_SMALL_SIZE( 50.f, 100.f );
41 const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
42   "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
43   "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
44   "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
45   "Quidam corpora at duo. An eos possim scripserit?\n\n"
46   "Aťqui dicant sěnťenťíae aň vel!\n"
47   "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n"
48   "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n"
49   "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
50   "Asšúm sapěret usu ůť.\n"
51   "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n";
52 const Vector2 LOREM_SCROLL_POSITION( 0.f, -208.f );
53 const Length LOREM_NUMBER_OF_LINES = 32u;
54 const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
55 const Length LOREM_NUMBER_OF_GLYPHS = 632;
56 const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 397u;
57
58 // The expected layout size for UtcDaliTextViewModelGetLayoutSize
59 const Size LAYOUT_SIZE( 190.f, 48.f );
60
61 // The expected color indices for UtcDaliTextViewModelGetColors
62 const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u };
63 const Length NUMBER_OF_COLORS = 3u;
64 const Vector4 COLORS[] = { Color::RED, Color::BLUE, Color::GREEN };
65
66 struct ElideData
67 {
68   std::string  description;
69   std::string  text;
70   Vector2      size;
71   unsigned int numberOfLines;
72   unsigned int numberOfGlyphs;
73   float*       positions;
74   unsigned int ignoreOfGlyphs;
75 };
76
77 bool ElideTest( const ElideData& data )
78 {
79   std::cout << "  testing : " << data.description << std::endl;
80
81   // Load some fonts.
82   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
83   fontClient.SetDpi( 93u, 93u );
84
85   char* pathNamePtr = get_current_dir_name();
86   const std::string pathName( pathNamePtr );
87   free( pathNamePtr );
88
89   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
90   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
91   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
92
93   // Creates a text controller.
94   ControllerPtr controller = Controller::New();
95
96   // Tests the rendering controller has been created.
97   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
98   DALI_TEST_CHECK( typesetter );
99
100   // Tests the view model has been created.
101   ViewModel* model = typesetter->GetViewModel();
102   DALI_TEST_CHECK( NULL != model );
103
104   // Configures the text controller similarly to the text-label.
105   ConfigureTextLabel( controller );
106
107   // Sets a text and relais-out.
108   controller->SetMarkupProcessorEnabled( true );
109
110   controller->SetText( data.text );
111   controller->Relayout( data.size );
112
113   // Elide the glyphs.
114   model->ElideGlyphs();
115
116   if( data.numberOfLines != model->GetNumberOfLines() )
117   {
118     std::cout << "  different number of lines : " << model->GetNumberOfLines() << ", expected : " << data.numberOfLines << std::endl;
119     return false;
120   }
121
122   if( data.numberOfGlyphs != model->GetNumberOfGlyphs() )
123   {
124     std::cout << "  different number of glyphs : " << model->GetNumberOfGlyphs() << ", expected : " << data.numberOfGlyphs << std::endl;
125     return false;
126   }
127
128   const Vector2* const layoutBuffer = model->GetLayout();
129   const Length numberOfLines = model->GetNumberOfLines();
130
131   if( numberOfLines != 0u )
132   {
133     const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u );
134     const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex + data.ignoreOfGlyphs;
135
136     std::cout << "  last line alignment offset : " << lastLine.alignmentOffset << std::endl;
137
138     for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index )
139     {
140       if( *( data.positions + index ) != ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
141       {
142         std::cout << "  different layout :";
143         for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
144         {
145           std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
146         }
147         std::cout << std::endl;
148         std::cout << "          expected :";
149         for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
150         {
151           std::cout << " " << *( data.positions + i );
152         }
153         std::cout << std::endl;
154         return false;
155       }
156     }
157   }
158
159   return true;
160 }
161
162 } // namespace
163
164 int UtcDaliTextViewModel(void)
165 {
166   tet_infoline(" UtcDaliTextViewModel");
167   ToolkitTestApplication application;
168
169   // Creates a text controller.
170   ControllerPtr controller = Controller::New();
171
172   // Tests the rendering controller has been created.
173   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
174   DALI_TEST_CHECK( typesetter );
175
176   // Tests the view model has been created.
177   ViewModel* model = typesetter->GetViewModel();
178   DALI_TEST_CHECK( NULL != model );
179
180   tet_result(TET_PASS);
181   END_TEST;
182 }
183
184 int UtcDaliTextViewModelGetControlSize(void)
185 {
186   tet_infoline(" UtcDaliTextViewModelGetControlSize");
187   ToolkitTestApplication application;
188
189   // Creates a text controller.
190   ControllerPtr controller = Controller::New();
191
192   // Tests the rendering controller has been created.
193   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
194   DALI_TEST_CHECK( typesetter );
195
196   // Tests the view model has been created.
197   ViewModel* model = typesetter->GetViewModel();
198   DALI_TEST_CHECK( NULL != model );
199
200   // Configures the text controller similarly to the text-editor.
201   ConfigureTextEditor( controller );
202
203   // The text has not been laid-out. The stored control's size should be zero.
204   DALI_TEST_EQUALS( Size::ZERO, model->GetControlSize(), TEST_LOCATION );
205
206   // Sets a text and relais-out.
207   controller->SetText( "Hello world" );
208   controller->Relayout( CONTROL_SIZE );
209
210   // The control's size should be stored now.
211   DALI_TEST_EQUALS( CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION );
212
213   tet_result(TET_PASS);
214   END_TEST;
215 }
216
217 int UtcDaliTextViewModelGetLayoutSize(void)
218 {
219   tet_infoline(" UtcDaliTextViewModelGetLayoutSize");
220   ToolkitTestApplication application;
221
222   // Load some fonts.
223   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
224   fontClient.SetDpi( 93u, 93u );
225
226   char* pathNamePtr = get_current_dir_name();
227   const std::string pathName( pathNamePtr );
228   free( pathNamePtr );
229
230   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
231
232   // Creates a text controller.
233   ControllerPtr controller = Controller::New();
234
235   // Tests the rendering controller has been created.
236   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
237   DALI_TEST_CHECK( typesetter );
238
239   // Tests the view model has been created.
240   ViewModel* model = typesetter->GetViewModel();
241   DALI_TEST_CHECK( NULL != model );
242
243   // Configures the text controller similarly to the text-editor.
244   ConfigureTextEditor( controller );
245
246   // The text has not been laid-out. The stored control's size should be zero.
247   DALI_TEST_EQUALS( Size::ZERO, model->GetLayoutSize(), TEST_LOCATION );
248
249   // Sets a text and relais-out.
250   controller->SetMarkupProcessorEnabled( true );
251   controller->SetText( "<font family='TizenSansRegular' size='10'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>" );
252   controller->Relayout( CONTROL_SIZE );
253
254   // The control's size should be stored now.
255   DALI_TEST_EQUALS( LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION );
256
257   tet_result(TET_PASS);
258   END_TEST;
259 }
260
261 int UtcDaliTextViewModelGetScrollPosition(void)
262 {
263   tet_infoline(" UtcDaliTextViewModelGetScrollPosition");
264   ToolkitTestApplication application;
265
266   // Creates a text controller.
267   ControllerPtr controller = Controller::New();
268
269   // Tests the rendering controller has been created.
270   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
271   DALI_TEST_CHECK( typesetter );
272
273   // Tests the view model has been created.
274   ViewModel* model = typesetter->GetViewModel();
275   DALI_TEST_CHECK( NULL != model );
276
277   // Configures the text controller similarly to the text-editor.
278   ConfigureTextEditor( controller );
279
280   // No text has been set. The scroll position should be zero.
281   DALI_TEST_EQUALS( Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION );
282
283   // Gains the keyboard focus, sets a big text and relais-out.
284   controller->KeyboardFocusGainEvent();
285   controller->SetText( LOREM_IPSUM );
286   controller->Relayout( CONTROL_SIZE );
287
288   // The text should be scrolled to the end.
289   DALI_TEST_EQUALS( LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION );
290
291   tet_result(TET_PASS);
292   END_TEST;
293 }
294
295 int UtcDaliTextViewModelGetAlignment(void)
296 {
297   tet_infoline(" UtcDaliTextViewModelGetAlignment");
298   ToolkitTestApplication application;
299
300   // Creates a text controller.
301   ControllerPtr controller = Controller::New();
302
303   // Tests the rendering controller has been created.
304   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
305   DALI_TEST_CHECK( typesetter );
306
307   // Tests the view model has been created.
308   ViewModel* model = typesetter->GetViewModel();
309   DALI_TEST_CHECK( NULL != model );
310
311   DALI_TEST_EQUALS( Text::HorizontalAlignment::BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION );
312   DALI_TEST_EQUALS( Text::VerticalAlignment::TOP, model->GetVerticalAlignment(), TEST_LOCATION );
313
314   controller->SetHorizontalAlignment( Text::HorizontalAlignment::CENTER );
315   controller->SetVerticalAlignment( Text::VerticalAlignment::CENTER );
316
317   DALI_TEST_EQUALS( Text::HorizontalAlignment::CENTER, model->GetHorizontalAlignment(), TEST_LOCATION );
318   DALI_TEST_EQUALS( Text::VerticalAlignment::CENTER, model->GetVerticalAlignment(), TEST_LOCATION );
319
320   tet_result(TET_PASS);
321   END_TEST;
322 }
323
324 int UtcDaliTextViewModelIsTextElideEnabled(void)
325 {
326   tet_infoline(" UtcDaliTextViewModelIsTextElideEnabled");
327   ToolkitTestApplication application;
328
329   // Creates a text controller.
330   ControllerPtr controller = Controller::New();
331
332   // Tests the rendering controller has been created.
333   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
334   DALI_TEST_CHECK( typesetter );
335
336   // Tests the view model has been created.
337   ViewModel* model = typesetter->GetViewModel();
338   DALI_TEST_CHECK( NULL != model );
339
340   // Configures the text controller similarly to the text-editor.
341   ConfigureTextEditor( controller );
342
343   // Elide text should be disabled.
344   DALI_TEST_CHECK( !model->IsTextElideEnabled() );
345
346   // Configures the text controller similarly to the text-label.
347   ConfigureTextLabel( controller );
348
349   // Elide text should be enabled.
350   DALI_TEST_CHECK( model->IsTextElideEnabled() );
351
352   tet_result(TET_PASS);
353   END_TEST;
354 }
355
356 int UtcDaliTextViewModelGetLines(void)
357 {
358   tet_infoline(" UtcDaliTextViewModelGetLines");
359   ToolkitTestApplication application;
360
361   // Creates a text controller.
362   ControllerPtr controller = Controller::New();
363
364   // Tests the rendering controller has been created.
365   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
366   DALI_TEST_CHECK( typesetter );
367
368   // Tests the view model has been created.
369   ViewModel* model = typesetter->GetViewModel();
370   DALI_TEST_CHECK( NULL != model );
371
372   // Configures the text controller similarly to the text-editor.
373   ConfigureTextEditor( controller );
374
375   // The number of lines should be zero.
376   DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
377   DALI_TEST_CHECK( NULL == model->GetLines() );
378
379   // Sets a text and relais-out.
380   controller->SetText( LOREM_IPSUM );
381   controller->Relayout( CONTROL_SIZE );
382
383   DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
384   DALI_TEST_CHECK( NULL != model->GetLines() );
385
386   // Configures the text controller similarly to the text-label.
387   ConfigureTextLabel( controller );
388
389   // Relais-out for the text-label configuration.
390   controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
391   controller->Relayout( CONTROL_SIZE );
392
393   DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
394   DALI_TEST_CHECK( NULL != model->GetLines() );
395
396   tet_result(TET_PASS);
397   END_TEST;
398 }
399
400 int UtcDaliTextViewModelGetGlyphsLayout(void)
401 {
402   tet_infoline(" UtcDaliTextViewModelGetGlyphsLayout");
403   ToolkitTestApplication application;
404
405   // Creates a text controller.
406   ControllerPtr controller = Controller::New();
407
408   // Tests the rendering controller has been created.
409   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
410   DALI_TEST_CHECK( typesetter );
411
412   // Tests the view model has been created.
413   ViewModel* model = typesetter->GetViewModel();
414   DALI_TEST_CHECK( NULL != model );
415
416   // Configures the text controller similarly to the text-editor.
417   ConfigureTextEditor( controller );
418
419   // The number of glyphs should be zero.
420   DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
421   DALI_TEST_CHECK( NULL == model->GetGlyphs() );
422   DALI_TEST_CHECK( NULL == model->GetLayout() );
423
424   // Sets a text and relais-out.
425   controller->SetText( LOREM_IPSUM );
426   controller->Relayout( CONTROL_SIZE );
427
428   DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
429   DALI_TEST_CHECK( NULL != model->GetGlyphs() );
430   DALI_TEST_CHECK( NULL != model->GetLayout() );
431
432   // Configures the text controller similarly to the text-label.
433   ConfigureTextLabel( controller );
434
435   // Relais-out for the text-label configuration.
436   controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
437   controller->Relayout( CONTROL_SIZE );
438
439   // Elide the glyphs.
440   model->ElideGlyphs();
441
442   DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
443   DALI_TEST_CHECK( NULL != model->GetGlyphs() );
444   DALI_TEST_CHECK( NULL != model->GetLayout() );
445
446   tet_result(TET_PASS);
447   END_TEST;
448 }
449
450 int UtcDaliTextViewModelGetColors(void)
451 {
452   tet_infoline(" UtcDaliTextViewModelGetColors");
453   ToolkitTestApplication application;
454
455   // Creates a text controller.
456   ControllerPtr controller = Controller::New();
457
458   // Tests the rendering controller has been created.
459   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
460   DALI_TEST_CHECK( typesetter );
461
462   // Tests the view model has been created.
463   ViewModel* model = typesetter->GetViewModel();
464   DALI_TEST_CHECK( NULL != model );
465
466   // Configures the text controller similarly to the text-label.
467   ConfigureTextLabel( controller );
468
469   // Sets a text and relais-out.
470   controller->SetMarkupProcessorEnabled( true );
471   controller->SetText( "Lorem <color value='red'>ips<color value='blue'>um do</color>lor s<color value='green'>i</color>t a</color>met." );
472   controller->Relayout( CONTROL_SIZE );
473
474   DALI_TEST_EQUALS( Color::BLACK, model->GetDefaultColor(), TEST_LOCATION );
475
476   const ColorIndex* const colorIndicesBuffer = model->GetColorIndices();
477
478   const Length numberOfGlyphs = model->GetNumberOfGlyphs();
479   for( ColorIndex index = 0u; index < numberOfGlyphs; ++index )
480   {
481     DALI_TEST_EQUALS( COLOR_INDICES[index], *( colorIndicesBuffer + index ), TEST_LOCATION );
482   }
483
484   const Vector4* const colors = model->GetColors();
485   for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index )
486   {
487     DALI_TEST_EQUALS( COLORS[index], *( colors + index ), TEST_LOCATION );
488   }
489
490   tet_result(TET_PASS);
491   END_TEST;
492 }
493
494 int UtcDaliTextViewModelElideText01(void)
495 {
496   tet_infoline(" UtcDaliTextViewModelElideText01");
497   ToolkitTestApplication application;
498
499   // Creates a text controller.
500   ControllerPtr controller = Controller::New();
501
502   // Tests the rendering controller has been created.
503   TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
504   DALI_TEST_CHECK( typesetter );
505
506   // Tests the view model has been created.
507   ViewModel* model = typesetter->GetViewModel();
508   DALI_TEST_CHECK( NULL != model );
509
510   // Configures the text controller similarly to the text-editor.
511   ConfigureTextEditor( controller );
512
513   // The number of glyphs should be zero.
514   DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
515   DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
516   DALI_TEST_CHECK( NULL == model->GetGlyphs() );
517   DALI_TEST_CHECK( NULL == model->GetLayout() );
518
519   // Sets a text and relais-out.
520   controller->SetText( LOREM_IPSUM );
521   controller->Relayout( CONTROL_SIZE );
522
523   // Keep the pointers to the glyphs and layout.
524   // As the text is not elided with this configuration, the pointers shoud be the same after calling the ElideGlyphs() method.
525   const GlyphInfo* const glyphsModel = model->GetGlyphs();
526   const Vector2* layoutsModel = model->GetLayout();
527
528   // Elide the glyphs. Text shouldn't be elided with this configuration.
529   model->ElideGlyphs();
530
531   DALI_TEST_CHECK( glyphsModel == model->GetGlyphs() );
532   DALI_TEST_CHECK( layoutsModel == model->GetLayout() );
533
534   DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
535   DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
536
537   // Configures the text controller similarly to the text-label.
538   ConfigureTextLabel( controller );
539
540   // Clear the text and relais-out.
541   controller->SetText( "" );
542   controller->Relayout( CONTROL_SIZE );
543
544   DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
545   DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
546
547   // Elide the glyphs. Should not add the ellipsis glyph.
548   model->ElideGlyphs();
549
550   DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
551
552   // Sets a text that doesn't need to be elided.
553   controller->SetText( "Hello\n" );
554   controller->Relayout( CONTROL_SIZE );
555
556   // Elide the glyphs.
557   model->ElideGlyphs();
558
559   DALI_TEST_EQUALS( 6u, model->GetNumberOfGlyphs(), TEST_LOCATION );
560   DALI_TEST_EQUALS( 2u, model->GetNumberOfLines(), TEST_LOCATION );
561
562   // Sets a text and relais-out.
563   controller->SetText( LOREM_IPSUM );
564   controller->Relayout( CONTROL_SIZE );
565
566   // Elide the glyphs.
567   model->ElideGlyphs();
568
569   DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
570   DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
571   const GlyphInfo* const glyphs = model->GetGlyphs();
572   const Vector2* layouts = model->GetLayout();
573   DALI_TEST_CHECK( NULL != glyphs );
574   DALI_TEST_CHECK( NULL != layouts );
575
576   tet_result(TET_PASS);
577   END_TEST;
578 }
579
580 int UtcDaliTextViewModelElideText02(void)
581 {
582   tet_infoline(" UtcDaliTextViewModelElideText02");
583
584   Size textSize00( 100.f, 100.f );
585
586   Size textSize01( 80.f, 100.f );
587   float positions01[] = { 0.f, 9.f, 17.f, 27.f, 35.f, 37.f, 46.f, 56.f };
588
589   Size textSize02( 80.f, 100.f );
590   float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 11.f };
591
592   Size textSize03( 80.f, 100.f );
593   float positions03[] = { 77.f, 76.f, 71.f, 62.f, 59.f, 52.f, 47.f, 42.f, 39.f, 35.f, 32.f, 13.f };
594
595   Size textSize04( 80.f, 10.f );
596   float positions04[] = { 2.f };
597
598   Size textSize05( 180.f, 100.f );
599   float positions05[] = { 0.f, 0.f };
600
601   struct ElideData data[] =
602   {
603     {
604       "void text",
605       "",
606       textSize00,
607       0u,
608       0u,
609       NULL,
610       0u
611     },
612     {
613       "Latin script",
614       "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
615       textSize01,
616       5u,
617       42u,
618       positions01,
619       0u
620     },
621     {
622       "Hebrew script",
623       "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
624       textSize02,
625       5u,
626       49u,
627       positions02,
628       0u
629     },
630     {
631       "Arabic script",
632       "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
633       textSize03,
634       5u,
635       79u,
636       positions03,
637       0u
638     },
639     {
640       "Small control size, no line fits.",
641       "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
642       textSize04,
643       1u,
644       1u,
645       positions04,
646       0u
647     },
648     {
649       "Include newline character",
650       "<font family='TizenSans'>yesterday\n all\n my troubles\n seemed so far\n\n away now it looks</font>",
651       textSize05,
652       5u,
653       40,
654       positions05,
655       5u
656     },
657   };
658   const unsigned int numberOfTests = 6u;
659
660   for( unsigned int index = 0u; index < numberOfTests; ++index )
661   {
662     ToolkitTestApplication application;
663     if( !ElideTest( data[index] ) )
664     {
665       tet_result(TET_FAIL);
666     }
667   }
668
669   tet_result(TET_PASS);
670   END_TEST;
671 }