License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextInput.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
20 #include <stdlib.h>
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25
26 using namespace Dali;
27 using namespace Toolkit;
28
29 void utc_dali_toolkit_text_input_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_toolkit_text_input_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41 static bool gObjectCreatedCallBackCalled;
42
43 static void TestCallback(BaseHandle handle)
44 {
45   Actor actor = Actor::DownCast(handle);
46
47   if(actor)
48   {
49     TextInput handle = TextInput::DownCast(actor);
50      if (handle)
51      {
52        gObjectCreatedCallBackCalled = true;
53      }
54   }
55 }
56
57 static bool gHasEndSignalBeenReceived;
58 static bool gHasStartSignalBeenReceived;
59
60 // Callback test function
61 void OnStartInput(TextInput textInput)
62 {
63   gHasStartSignalBeenReceived = true;
64 }
65
66 // Callback test function
67 void OnEndInput(TextInput textInput)
68 {
69   gHasEndSignalBeenReceived = true;
70 }
71
72 }
73
74 // Positive test case for a method
75 int UtcDaliTextInputConstruction(void)
76 {
77   ToolkitTestApplication application;
78
79   tet_infoline("Testing New constructor");
80
81   TextInput textInput = TextInput::New();
82   DALI_TEST_CHECK(textInput);
83
84   //Additional check to ensure object is created by checking if it's registered
85   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
86   DALI_TEST_CHECK( registry );
87
88   gObjectCreatedCallBackCalled = false;
89   registry.ObjectCreatedSignal().Connect(&TestCallback);
90   {
91     TextInput textInput = TextInput::New();
92   }
93   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
94   END_TEST;
95 }
96
97
98 static bool downCastToTextInput(Dali::Actor actor)
99 {
100   TextInput handle = TextInput::DownCast(actor);
101   if (handle)
102   {
103     tet_infoline("Downcasted to TextInput");
104     return true;
105   }
106   else
107   {
108     tet_infoline("Did not downcast to TextInput");
109     return false;
110   }
111 }
112
113 // Positive test case for a method
114 int UtcDaliTextInputDownCast(void)
115 {
116   ToolkitTestApplication application;
117
118   TextInput textInput = TextInput::New();
119
120   tet_infoline("Testing Downcasting with a TextInput");
121   DALI_TEST_EQUALS(true,downCastToTextInput(textInput), TEST_LOCATION); // downcast a TextInput
122
123   Dali::TextActor badHandle = Dali::TextActor::New("test");
124
125   tet_infoline("Testing Downcasting with the wrong actor");
126   DALI_TEST_EQUALS(false, downCastToTextInput(badHandle), TEST_LOCATION); // downcast a TextActor to TextInput
127   END_TEST;
128 }
129
130 // Positive test case for a method
131 int UtcDaliTextInputGetText(void)
132 {
133   ToolkitTestApplication application;
134
135   tet_infoline("Testing GetText");
136
137   const std::string teststring = "test";
138
139   TextInput textInput = TextInput::New();  // create empty TextInput
140
141   DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty
142
143   textInput.SetInitialText(teststring);
144
145   DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string
146
147   END_TEST;
148 }
149
150 int UtcDaliTextInputGetMarkupText(void)
151 {
152   ToolkitTestApplication application;
153
154   tet_infoline("Testing retrieval of Markup text after style set");
155
156   const std::string markup = "<i>Text with italic style</i>" ;
157   const std::string teststring = "Text with italic style";
158
159   TextInput textInput = TextInput::New();
160
161   tet_infoline("Set initial text");
162
163   textInput.SetInitialText( teststring );
164
165   tet_infoline("Check initial text");
166   DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty
167
168   TextStyle style;
169   style.SetItalics( true );
170
171   tet_infoline("Apply style to TextInput");
172   textInput.ApplyStyleToAll( style );
173
174   tet_infoline("Retreive Markup Text");
175   const std::string retreivedMarkupString = textInput.GetMarkupText();
176
177   tet_infoline("Test Retreived text and Markup text match");
178   DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION);
179   END_TEST;
180 }
181
182 int UtcDaliTextInputSetMaxCharacterLength(void)
183 {
184   ToolkitTestApplication application;
185
186   tet_infoline("Testing Setting of max characters");
187
188   const int maxChars = 4;
189   const char* testChar  = "v";
190
191   TextInput textInput = TextInput::New();  // create empty TextInput
192   Stage::GetCurrent().Add(textInput);
193   application.SendNotification();
194   application.Render();
195
196   textInput.SetMaxCharacterLength(maxChars);
197
198   Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
199
200   std::string testString = "";
201
202   tet_infoline("Starting editmode");
203   textInput.SetEditable( true );
204
205   tet_infoline("Sending Key Events");
206   // Send max number of characters
207   for (int i=0; i < maxChars; i++)
208     {
209       application.ProcessEvent(event);
210       testString.append(testChar);
211     }
212
213   tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
214
215   DALI_TEST_EQUALS(testString, textInput.GetText(), TEST_LOCATION);
216
217   tet_infoline("Sending Key Event which exceeds max characters");
218
219   application.ProcessEvent(event); // try to append additional character
220
221   DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
222
223   tet_infoline("Increase max characters limit");
224
225   textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1
226
227   tet_infoline("Send character again which should now fit");
228   application.ProcessEvent(event); // append additional character
229   testString.append(testChar);
230
231   DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
232   END_TEST;
233 }
234
235
236 int UtcDaliTextInputSetAndGetNumberOfLines(void)
237 {
238   ToolkitTestApplication application;
239
240   tet_infoline("Ensuring API for setting and getting max number of lines is correct");
241
242   TextInput textInput = TextInput::New();  // create empty TextInput
243
244   unsigned int numberOfLines = 1;
245
246   textInput.SetNumberOfLinesLimit( numberOfLines );
247
248   DALI_TEST_EQUALS(numberOfLines ,textInput.GetNumberOfLinesLimit(),  TEST_LOCATION);
249   END_TEST;
250 }
251
252 int UtcDaliTextInputGetNumberOfCharacters(void)
253 {
254   ToolkitTestApplication application;
255
256   tet_infoline("Testing Getting number of characters");
257
258   const std::string initialString = "initial text";
259   const std::string newInitialString = "initial text new";
260
261   TextInput textInput = TextInput::New();  // create empty TextInput
262
263   textInput.SetInitialText( initialString );
264
265   tet_infoline("Testing TextInput contains correct number of characters ");
266
267   DALI_TEST_EQUALS( initialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
268
269   tet_infoline("Testing TextInput contains correct number of characters second phase ");
270
271   textInput.SetInitialText( newInitialString );
272
273   DALI_TEST_EQUALS( newInitialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
274   END_TEST;
275 }
276
277 int UtcDaliTextInputSetAndGetPlaceholderText(void)
278 {
279   ToolkitTestApplication application;
280
281   tet_infoline("Testing Setting of PlaceholderText");
282
283   const std::string initialString = "initial text";
284   const std::string placeholderString = "placeholder";
285
286   TextInput textInput = TextInput::New();  // create empty TextInput
287
288   tet_infoline("Testing TextInput is empty at creation ");
289
290   DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
291
292   tet_infoline("Set placeholder text");
293
294   textInput.SetPlaceholderText( placeholderString );
295
296   tet_infoline("Testing TextInput contains placeholder text");
297
298   DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION);
299
300   tet_infoline("Set initial text which should replace placeholder text");
301
302   textInput.SetInitialText( initialString );
303
304   tet_infoline("Testing TextInput contains initial text when placeholder text set");
305
306   DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION);
307   END_TEST;
308 }
309
310 // Positive test case for a method
311 int UtcDaliTextInputSetInitialText(void)
312 {
313   ToolkitTestApplication application;
314
315   tet_infoline("Testing Setting of Initial Text");
316
317   const std::string teststring = "test";
318
319   TextInput textInput = TextInput::New();  // create empty TextInput
320
321   tet_infoline("Testing TextInput is empty at creation ");
322
323   DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
324
325   tet_infoline("Set text to TextInput");
326
327   textInput.SetInitialText(teststring);
328
329   tet_infoline("Test TextInput contains set text");
330
331   DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION);
332   END_TEST;
333 }
334
335 int UtcDaliTextInputSetEditableAndIsEditable(void)
336 {
337   ToolkitTestApplication application;
338
339   tet_infoline("Testing SetEditable And IsEditable");
340
341   const std::string initialString = "initial text";
342
343   TextInput textInput = TextInput::New();  // create empty TextInput
344   textInput.SetInitialText( initialString );
345
346   Stage::GetCurrent().Add(textInput);
347   application.SendNotification();
348   application.Render();
349
350   bool editableStateFalse ( false );
351   bool editableStateTrue ( true );
352
353   textInput.SetEditable ( editableStateFalse );
354   application.SendNotification();
355   application.Render();
356   DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION);
357
358   textInput.SetEditable ( editableStateTrue );
359   application.SendNotification();
360   application.Render();
361   DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION);
362   END_TEST;
363 }
364
365 int UtcDaliTextInputSetEditOnTouch(void)
366 {
367   ToolkitTestApplication application;
368
369   tet_infoline("Testing SetEditOnTouch And IsEditOnTouch");
370
371   TextInput textInput = TextInput::New();
372
373   bool editableOnTouchOn ( true );
374   bool editableOnTouchOff( false );
375
376   tet_infoline("Testing SetEditOnTouch disabled");
377   textInput.SetEditOnTouch ( editableOnTouchOff );
378   DALI_TEST_EQUALS( editableOnTouchOff, textInput.IsEditOnTouch() , TEST_LOCATION);
379
380   tet_infoline("Testing SetEditOnTouch enabled");
381   textInput.SetEditOnTouch ( editableOnTouchOn );
382   DALI_TEST_EQUALS( editableOnTouchOn, textInput.IsEditOnTouch() , TEST_LOCATION);
383   END_TEST;
384 }
385
386 int UtcDaliTextInputSetTextSelectable(void)
387 {
388   ToolkitTestApplication application;
389
390   tet_infoline("Testing SetTextSelectable and IsTextSelectable");
391
392   const std::string initialString = "initial text";
393
394   TextInput textInput = TextInput::New();
395   textInput.SetInitialText( initialString );
396
397   tet_infoline("Testing SetTextSelectable");
398   textInput.SetTextSelectable();
399   DALI_TEST_EQUALS( true, textInput.IsTextSelectable() , TEST_LOCATION);
400   textInput.SetTextSelectable( false );
401   DALI_TEST_EQUALS( false, textInput.IsTextSelectable() , TEST_LOCATION);
402   END_TEST;
403 }
404
405 int UtcDaliTextInputTextSelection(void)
406 {
407   ToolkitTestApplication application;
408
409   tet_infoline("Testing Text Selection");
410
411   const std::string initialString = "initial text";
412
413   TextInput textInput = TextInput::New();
414   textInput.SetInitialText( initialString );
415
416   Stage::GetCurrent().Add(textInput);
417   application.SendNotification();
418   application.Render();
419
420   textInput.SetEditable( true );
421
422   tet_infoline("Testing IsTextSelected negative");
423   DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
424
425   textInput.SelectText(1,7);
426   DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION);
427
428   textInput.DeSelectText();
429   DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
430   END_TEST;
431 }
432
433 int UtcDaliTextInputEnableGrabHandleAndIsGrabHandleEnabled(void)
434 {
435   ToolkitTestApplication application;
436
437   TextInput textInput = TextInput::New();
438
439   bool grabHandleState = false;
440
441   textInput.EnableGrabHandle( grabHandleState );
442
443   DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
444
445   grabHandleState = true;
446   textInput.EnableGrabHandle( grabHandleState );
447
448   DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
449
450   END_TEST;
451 }
452
453 int UtcDaliTextInputSetAndGetBoundingRectangle(void)
454 {
455   ToolkitTestApplication application;
456
457   TextInput textInput = TextInput::New();
458
459   Stage::GetCurrent().Add(textInput);
460   Vector2 stageSize = Stage::GetCurrent().GetSize();
461
462   const Rect<float> boundingRectangle( 100.0f, 100.0f, stageSize.width, stageSize.height );
463
464   textInput.SetBoundingRectangle( boundingRectangle );
465
466   const Rect<float> retreievedBoundingRectangle = textInput.GetBoundingRectangle();
467
468   DALI_TEST_EQUALS( boundingRectangle.x, retreievedBoundingRectangle.x, TEST_LOCATION);
469   DALI_TEST_EQUALS( boundingRectangle.y, retreievedBoundingRectangle.y, TEST_LOCATION);
470   DALI_TEST_EQUALS( boundingRectangle.width, retreievedBoundingRectangle.width, TEST_LOCATION);
471   DALI_TEST_EQUALS( boundingRectangle.height, retreievedBoundingRectangle.height, TEST_LOCATION);
472   END_TEST;
473 }
474
475
476 int UtcDaliTextInputSetAndGetTextAlignment(void)
477 {
478   ToolkitTestApplication application;
479
480   TextInput textInput = TextInput::New();
481   Stage::GetCurrent().Add(textInput);
482   application.SendNotification();
483   application.Render();
484
485   textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
486   application.SendNotification();
487   application.Render();
488
489   DALI_TEST_CHECK( static_cast<Alignment::Type>( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ;
490   END_TEST;
491 }
492
493
494 int UtcDaliTextInputSetSortModifier(void)
495 {
496   tet_infoline("Testing SetSortModifier does not cause TextInput failure");
497
498   ToolkitTestApplication application;
499
500   TextInput textInput = TextInput::New();
501
502   const float offsetToUse = 1.5f;
503
504   textInput.SetSortModifier( offsetToUse );
505
506   DALI_TEST_CHECK( textInput );
507   END_TEST;
508 }
509
510 int UtcDaliTextInputSetAndGetSnapshotModeEnabled(void)
511 {
512   ToolkitTestApplication application;
513
514   tet_infoline("Testing SetSnapshotModeEnabled and IsSnapshotModeEnabled");
515
516   TextInput textInput = TextInput::New();  // create empty TextInput
517   bool snapshotMode( true );
518   textInput.SetSnapshotModeEnabled( snapshotMode );
519
520   DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
521
522   snapshotMode = false;
523   textInput.SetSnapshotModeEnabled( snapshotMode );
524
525   DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
526   END_TEST;
527 }
528
529
530 int UtcDaliTextInputEndSignalEmit(void)
531 {
532   ToolkitTestApplication application;
533
534   tet_infoline("Testing Set editable false emits end signal");
535
536   TextInput textInput = TextInput::New();  // create empty TextInput
537
538   Stage::GetCurrent().Add(textInput);
539
540   textInput.InputFinishedSignal().Connect( &OnEndInput );
541
542   textInput.SetEditable(true) ;
543
544   gHasEndSignalBeenReceived = false;
545
546   textInput.SetEditable(false) ;
547
548   DALI_TEST_EQUALS(true, gHasEndSignalBeenReceived, TEST_LOCATION);
549   END_TEST;
550 }
551
552
553
554 int UtcDaliTextInputStartSignalEmit(void)
555 {
556   ToolkitTestApplication application;
557
558   tet_infoline("Testing SetEditable emits start signal");
559
560   TextInput textInput = TextInput::New();  // create empty TextInput
561
562   Stage::GetCurrent().Add(textInput);
563
564   textInput.InputStartedSignal().Connect( &OnStartInput );
565
566   gHasStartSignalBeenReceived = false;
567
568   textInput.SetEditable(true);  // Set editable first time
569
570   DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
571
572   gHasStartSignalBeenReceived = false;
573
574   textInput.SetEditable(true); // Set editable second time, signal should not be sent again.
575
576   DALI_TEST_EQUALS(false, gHasStartSignalBeenReceived, TEST_LOCATION);
577
578   textInput.SetEditable(false);
579
580   gHasStartSignalBeenReceived = false;
581
582   textInput.SetEditable(true);  // Set editable again
583
584   DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
585   END_TEST;
586 }
587
588 int UtcDaliTextInputExceedMaxCharacters(void)
589 {
590   ToolkitTestApplication application;
591
592   tet_infoline("Testing Max characters is obeyed when inputting key events ");
593
594   TextInput textInput = TextInput::New();  // create empty TextInput
595
596   Stage::GetCurrent().Add(textInput);
597   textInput.SetMaxCharacterLength(4);
598   textInput.SetInitialText("");
599   textInput.SetEditable(true);
600
601   application.SendNotification();
602   application.Render();
603
604   Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
605   Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
606
607   application.ProcessEvent(eventA);
608   application.ProcessEvent(eventB);
609   application.ProcessEvent(eventA);
610   application.ProcessEvent(eventB);
611
612   application.ProcessEvent(eventA);
613   application.ProcessEvent(eventB);
614
615   tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
616
617   DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters
618   END_TEST;
619 }
620
621
622
623 int UtcDaliTextInputSetAndGetFadeBoundary(void)
624 {
625   tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
626
627   ToolkitTestApplication application;
628
629   TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
630
631   TextInput textInput = TextInput::New();
632   textInput.SetInitialText( "Hello world!" );
633
634   Stage::GetCurrent().Add(textInput);
635   application.SendNotification();
636   application.Render();
637
638   textInput.SetFadeBoundary( fadeBoundary );
639
640   TextView::FadeBoundary fadeBoundary2 = textInput.GetFadeBoundary();
641
642   DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
643   DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
644   DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
645   DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
646   END_TEST;
647 }
648
649 int UtcDaliTextInputSetAndGetWidthExceedPolicy(void)
650 {
651   ToolkitTestApplication application;
652
653   tet_infoline("UtcDaliTextInputSetAndGetWidthExceedPolicy: ");
654
655   const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
656   const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
657
658   TextInput textInput = TextInput::New();
659   textInput.SetInitialText( "Hello world!" );
660
661   for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
662   {
663     textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
664
665     DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
666   }
667   END_TEST;
668 }
669
670 int UtcDaliTextInputSetAndGetHeightExceedPolicy(void)
671 {
672   ToolkitTestApplication application;
673
674   tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: ");
675
676   const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
677   const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
678
679   TextInput textInput = TextInput::New();
680   textInput.SetInitialText( "Hello world!" );
681
682   for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
683   {
684     textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
685
686     DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
687   }
688   END_TEST;
689 }
690
691 int UtcDaliTextInputScroll(void)
692 {
693   tet_infoline("UtcDaliTextInputScroll: ");
694   ToolkitTestApplication application;
695
696   // Avoids the frame buffer texture to throw an exception.
697   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
698
699   TextInput view = TextInput::New();
700   view.SetMultilinePolicy( TextView::SplitByNewLineChar );
701   view.SetWidthExceedPolicy( TextView::Original );
702   view.SetHeightExceedPolicy( TextView::Original );
703   view.SetTextAlignment( static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ) );
704   view.SetInitialText( "Hello world! This is a scroll test." );
705   view.SetSize( 100.f, 100.f );
706   view.SetSnapshotModeEnabled( false );
707
708   Stage::GetCurrent().Add( view );
709
710   application.SendNotification();
711   application.Render();
712
713   DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
714
715   view.SetScrollEnabled( true );
716
717   DALI_TEST_CHECK( view.IsScrollEnabled() );
718   DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
719
720   view.SetScrollPosition( Vector2( 400.f, 400.f ) );
721
722   application.SendNotification();
723   application.Render();
724
725   const Vector2& scrollPosition = view.GetScrollPosition();
726   DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
727   END_TEST;
728 }