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