2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/integration-api/events/key-event-integ.h>
27 using namespace Toolkit;
29 void utc_dali_toolkit_text_input_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_toolkit_text_input_cleanup(void)
36 test_return_value = TET_PASS;
41 static bool gObjectCreatedCallBackCalled;
43 static void TestCallback(BaseHandle handle)
45 Actor actor = Actor::DownCast(handle);
49 TextInput handle = TextInput::DownCast(actor);
52 gObjectCreatedCallBackCalled = true;
57 static bool gHasEndSignalBeenReceived;
58 static bool gHasStartSignalBeenReceived;
60 // Callback test function
61 void OnStartInput(TextInput textInput)
63 gHasStartSignalBeenReceived = true;
66 // Callback test function
67 void OnEndInput(TextInput textInput)
69 gHasEndSignalBeenReceived = true;
74 // Positive test case for a method
75 int UtcDaliTextInputConstruction(void)
77 ToolkitTestApplication application;
79 tet_infoline("Testing New constructor");
81 TextInput textInput = TextInput::New();
82 DALI_TEST_CHECK(textInput);
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 );
88 gObjectCreatedCallBackCalled = false;
89 registry.ObjectCreatedSignal().Connect(&TestCallback);
91 TextInput textInput = TextInput::New();
93 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
98 static bool downCastToTextInput(Dali::Actor actor)
100 TextInput handle = TextInput::DownCast(actor);
103 tet_infoline("Downcasted to TextInput");
108 tet_infoline("Did not downcast to TextInput");
113 // Positive test case for a method
114 int UtcDaliTextInputDownCast(void)
116 ToolkitTestApplication application;
118 TextInput textInput = TextInput::New();
120 tet_infoline("Testing Downcasting with a TextInput");
121 DALI_TEST_EQUALS(true,downCastToTextInput(textInput), TEST_LOCATION); // downcast a TextInput
123 Dali::TextActor badHandle = Dali::TextActor::New("test");
125 tet_infoline("Testing Downcasting with the wrong actor");
126 DALI_TEST_EQUALS(false, downCastToTextInput(badHandle), TEST_LOCATION); // downcast a TextActor to TextInput
130 // Positive test case for a method
131 int UtcDaliTextInputGetText(void)
133 ToolkitTestApplication application;
135 tet_infoline("Testing GetText");
137 const std::string teststring = "test";
139 TextInput textInput = TextInput::New(); // create empty TextInput
141 DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty
143 textInput.SetInitialText(teststring);
145 DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string
150 int UtcDaliTextInputGetMarkupText(void)
152 ToolkitTestApplication application;
154 tet_infoline("Testing retrieval of Markup text after style set");
156 const std::string markup = "<i>Text with italic style</i>" ;
157 const std::string teststring = "Text with italic style";
159 TextInput textInput = TextInput::New();
161 tet_infoline("Set initial text");
163 textInput.SetInitialText( teststring );
165 tet_infoline("Check initial text");
166 DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty
169 style.SetItalics( true );
171 tet_infoline("Apply style to TextInput");
172 textInput.ApplyStyleToAll( style );
174 tet_infoline("Retreive Markup Text");
175 const std::string retreivedMarkupString = textInput.GetMarkupText();
177 tet_infoline("Test Retreived text and Markup text match");
178 DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION);
182 int UtcDaliTextInputSetMaxCharacterLength(void)
184 ToolkitTestApplication application;
186 tet_infoline("Testing Setting of max characters");
188 const int maxChars = 4;
189 const char* testChar = "v";
191 TextInput textInput = TextInput::New(); // create empty TextInput
192 Stage::GetCurrent().Add(textInput);
193 application.SendNotification();
194 application.Render();
196 textInput.SetMaxCharacterLength(maxChars);
198 Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
200 std::string testString = "";
202 tet_infoline("Starting editmode");
203 textInput.SetEditable( true );
205 tet_infoline("Sending Key Events");
206 // Send max number of characters
207 for (int i=0; i < maxChars; i++)
209 application.ProcessEvent(event);
210 testString.append(testChar);
213 tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
215 DALI_TEST_EQUALS(testString, textInput.GetText(), TEST_LOCATION);
217 tet_infoline("Sending Key Event which exceeds max characters");
219 application.ProcessEvent(event); // try to append additional character
221 DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
223 tet_infoline("Increase max characters limit");
225 textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1
227 tet_infoline("Send character again which should now fit");
228 application.ProcessEvent(event); // append additional character
229 testString.append(testChar);
231 DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
236 int UtcDaliTextInputSetAndGetNumberOfLines(void)
238 ToolkitTestApplication application;
240 tet_infoline("Ensuring API for setting and getting max number of lines is correct");
242 TextInput textInput = TextInput::New(); // create empty TextInput
244 unsigned int numberOfLines = 1;
246 textInput.SetNumberOfLinesLimit( numberOfLines );
248 DALI_TEST_EQUALS(numberOfLines ,textInput.GetNumberOfLinesLimit(), TEST_LOCATION);
252 int UtcDaliTextInputGetNumberOfCharacters(void)
254 ToolkitTestApplication application;
256 tet_infoline("Testing Getting number of characters");
258 const std::string initialString = "initial text";
259 const std::string newInitialString = "initial text new";
261 TextInput textInput = TextInput::New(); // create empty TextInput
263 textInput.SetInitialText( initialString );
265 tet_infoline("Testing TextInput contains correct number of characters ");
267 DALI_TEST_EQUALS( initialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
269 tet_infoline("Testing TextInput contains correct number of characters second phase ");
271 textInput.SetInitialText( newInitialString );
273 DALI_TEST_EQUALS( newInitialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
277 int UtcDaliTextInputSetAndGetPlaceholderText(void)
279 ToolkitTestApplication application;
281 tet_infoline("Testing Setting of PlaceholderText");
283 const std::string initialString = "initial text";
284 const std::string placeholderString = "placeholder";
286 TextInput textInput = TextInput::New(); // create empty TextInput
288 tet_infoline("Testing TextInput is empty at creation ");
290 DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
292 tet_infoline("Set placeholder text");
294 textInput.SetPlaceholderText( placeholderString );
296 tet_infoline("Testing TextInput contains placeholder text");
298 DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION);
300 tet_infoline("Set initial text which should replace placeholder text");
302 textInput.SetInitialText( initialString );
304 tet_infoline("Testing TextInput contains initial text when placeholder text set");
306 DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION);
310 // Positive test case for a method
311 int UtcDaliTextInputSetInitialText(void)
313 ToolkitTestApplication application;
315 tet_infoline("Testing Setting of Initial Text");
317 const std::string teststring = "test";
319 TextInput textInput = TextInput::New(); // create empty TextInput
321 tet_infoline("Testing TextInput is empty at creation ");
323 DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
325 tet_infoline("Set text to TextInput");
327 textInput.SetInitialText(teststring);
329 tet_infoline("Test TextInput contains set text");
331 DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION);
335 int UtcDaliTextInputSetEditableAndIsEditable(void)
337 ToolkitTestApplication application;
339 tet_infoline("Testing SetEditable And IsEditable");
341 const std::string initialString = "initial text";
343 TextInput textInput = TextInput::New(); // create empty TextInput
344 textInput.SetInitialText( initialString );
346 Stage::GetCurrent().Add(textInput);
347 application.SendNotification();
348 application.Render();
350 bool editableStateFalse ( false );
351 bool editableStateTrue ( true );
353 textInput.SetEditable ( editableStateFalse );
354 application.SendNotification();
355 application.Render();
356 DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION);
358 textInput.SetEditable ( editableStateTrue );
359 application.SendNotification();
360 application.Render();
361 DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION);
365 int UtcDaliTextInputSetEditOnTouch(void)
367 ToolkitTestApplication application;
369 tet_infoline("Testing SetEditOnTouch And IsEditOnTouch");
371 TextInput textInput = TextInput::New();
373 bool editableOnTouchOn ( true );
374 bool editableOnTouchOff( false );
376 tet_infoline("Testing SetEditOnTouch disabled");
377 textInput.SetEditOnTouch ( editableOnTouchOff );
378 DALI_TEST_EQUALS( editableOnTouchOff, textInput.IsEditOnTouch() , TEST_LOCATION);
380 tet_infoline("Testing SetEditOnTouch enabled");
381 textInput.SetEditOnTouch ( editableOnTouchOn );
382 DALI_TEST_EQUALS( editableOnTouchOn, textInput.IsEditOnTouch() , TEST_LOCATION);
386 int UtcDaliTextInputSetTextSelectable(void)
388 ToolkitTestApplication application;
390 tet_infoline("Testing SetTextSelectable and IsTextSelectable");
392 const std::string initialString = "initial text";
394 TextInput textInput = TextInput::New();
395 textInput.SetInitialText( initialString );
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);
405 int UtcDaliTextInputTextSelection(void)
407 ToolkitTestApplication application;
409 tet_infoline("Testing Text Selection");
411 const std::string initialString = "initial text";
413 TextInput textInput = TextInput::New();
414 textInput.SetInitialText( initialString );
416 Stage::GetCurrent().Add(textInput);
417 application.SendNotification();
418 application.Render();
420 textInput.SetEditable( true );
422 tet_infoline("Testing IsTextSelected negative");
423 DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
425 textInput.SelectText(1,7);
426 DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION);
428 textInput.DeSelectText();
429 DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
433 int UtcDaliTextInputEnableGrabHandleAndIsGrabHandleEnabled(void)
435 ToolkitTestApplication application;
437 TextInput textInput = TextInput::New();
439 bool grabHandleState = false;
441 textInput.EnableGrabHandle( grabHandleState );
443 DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
445 grabHandleState = true;
446 textInput.EnableGrabHandle( grabHandleState );
448 DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
453 int UtcDaliTextInputSetAndGetBoundingRectangle(void)
455 ToolkitTestApplication application;
457 TextInput textInput = TextInput::New();
459 Stage::GetCurrent().Add(textInput);
460 Vector2 stageSize = Stage::GetCurrent().GetSize();
462 const Rect<float> boundingRectangle( 100.0f, 100.0f, stageSize.width, stageSize.height );
464 textInput.SetBoundingRectangle( boundingRectangle );
466 const Rect<float> retreievedBoundingRectangle = textInput.GetBoundingRectangle();
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);
476 int UtcDaliTextInputSetAndGetTextAlignment01(void)
478 ToolkitTestApplication application;
480 TextInput textInput = TextInput::New();
481 Stage::GetCurrent().Add(textInput);
482 application.SendNotification();
483 application.Render();
485 textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
486 application.SendNotification();
487 application.Render();
489 DALI_TEST_CHECK( static_cast<Alignment::Type>( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ;
493 int UtcDaliTextInputSetAndGetTextAlignment02(void)
495 ToolkitTestApplication application;
497 TextInput textInput = TextInput::New();
498 textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
500 bool result = ( textInput.GetTextAlignment() & Alignment::HorizontalCenter ) ;
502 DALI_TEST_CHECK( result );
504 result = ( textInput.GetTextAlignment() & Alignment::HorizontalRight );
506 DALI_TEST_CHECK( !result );
510 int UtcDaliTextInputSetSortModifier(void)
512 tet_infoline("Testing SetSortModifier does not cause TextInput failure");
514 ToolkitTestApplication application;
516 TextInput textInput = TextInput::New();
518 const float offsetToUse = 1.5f;
520 textInput.SetSortModifier( offsetToUse );
522 DALI_TEST_CHECK( textInput );
526 int UtcDaliTextInputSetAndGetSnapshotModeEnabled(void)
528 ToolkitTestApplication application;
530 tet_infoline("Testing SetSnapshotModeEnabled and IsSnapshotModeEnabled");
532 TextInput textInput = TextInput::New(); // create empty TextInput
533 bool snapshotMode( true );
534 textInput.SetSnapshotModeEnabled( snapshotMode );
536 DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
538 snapshotMode = false;
539 textInput.SetSnapshotModeEnabled( snapshotMode );
541 DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
546 int UtcDaliTextInputEndSignalEmit(void)
548 ToolkitTestApplication application;
550 tet_infoline("Testing Set editable false emits end signal");
552 TextInput textInput = TextInput::New(); // create empty TextInput
554 Stage::GetCurrent().Add(textInput);
556 textInput.InputFinishedSignal().Connect( &OnEndInput );
558 textInput.SetEditable(true) ;
560 gHasEndSignalBeenReceived = false;
562 textInput.SetEditable(false) ;
564 DALI_TEST_EQUALS(true, gHasEndSignalBeenReceived, TEST_LOCATION);
570 int UtcDaliTextInputStartSignalEmit(void)
572 ToolkitTestApplication application;
574 tet_infoline("Testing SetEditable emits start signal");
576 TextInput textInput = TextInput::New(); // create empty TextInput
578 Stage::GetCurrent().Add(textInput);
580 textInput.InputStartedSignal().Connect( &OnStartInput );
582 gHasStartSignalBeenReceived = false;
584 textInput.SetEditable(true); // Set editable first time
586 DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
588 gHasStartSignalBeenReceived = false;
590 textInput.SetEditable(true); // Set editable second time, signal should not be sent again.
592 DALI_TEST_EQUALS(false, gHasStartSignalBeenReceived, TEST_LOCATION);
594 textInput.SetEditable(false);
596 gHasStartSignalBeenReceived = false;
598 textInput.SetEditable(true); // Set editable again
600 DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
604 int UtcDaliTextInputExceedMaxCharacters(void)
606 ToolkitTestApplication application;
608 tet_infoline("Testing Max characters is obeyed when inputting key events ");
610 TextInput textInput = TextInput::New(); // create empty TextInput
612 Stage::GetCurrent().Add(textInput);
613 textInput.SetMaxCharacterLength(4);
614 textInput.SetInitialText("");
615 textInput.SetEditable(true);
617 application.SendNotification();
618 application.Render();
620 Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
621 Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
623 application.ProcessEvent(eventA);
624 application.ProcessEvent(eventB);
625 application.ProcessEvent(eventA);
626 application.ProcessEvent(eventB);
628 application.ProcessEvent(eventA);
629 application.ProcessEvent(eventB);
631 tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
633 DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters
639 int UtcDaliTextInputSetAndGetFadeBoundary(void)
641 tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
643 ToolkitTestApplication application;
645 TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
647 TextInput textInput = TextInput::New();
648 textInput.SetInitialText( "Hello world!" );
650 Stage::GetCurrent().Add(textInput);
651 application.SendNotification();
652 application.Render();
654 textInput.SetFadeBoundary( fadeBoundary );
656 TextView::FadeBoundary fadeBoundary2 = textInput.GetFadeBoundary();
658 DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
659 DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
660 DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
661 DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
665 int UtcDaliTextInputSetAndGetWidthExceedPolicy(void)
667 ToolkitTestApplication application;
669 tet_infoline("UtcDaliTextInputSetAndGetWidthExceedPolicy: ");
671 const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
672 const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
674 TextInput textInput = TextInput::New();
675 textInput.SetInitialText( "Hello world!" );
677 for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
679 textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
681 DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
686 int UtcDaliTextInputSetAndGetHeightExceedPolicy(void)
688 ToolkitTestApplication application;
690 tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: ");
692 const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
693 const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
695 TextInput textInput = TextInput::New();
696 textInput.SetInitialText( "Hello world!" );
698 for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
700 textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
702 DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
707 int UtcDaliTextInputScroll(void)
709 tet_infoline("UtcDaliTextInputScroll: ");
710 ToolkitTestApplication application;
712 // Avoids the frame buffer texture to throw an exception.
713 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
715 TextInput view = TextInput::New();
716 view.SetMultilinePolicy( TextView::SplitByNewLineChar );
717 view.SetWidthExceedPolicy( TextView::Original );
718 view.SetHeightExceedPolicy( TextView::Original );
719 view.SetTextAlignment( static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ) );
720 view.SetInitialText( "Hello world! This is a scroll test." );
721 view.SetSize( 100.f, 100.f );
722 view.SetSnapshotModeEnabled( false );
724 Stage::GetCurrent().Add( view );
726 application.SendNotification();
727 application.Render();
729 DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
731 view.SetScrollEnabled( true );
733 DALI_TEST_CHECK( view.IsScrollEnabled() );
734 DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
736 view.SetScrollPosition( Vector2( 400.f, 400.f ) );
738 application.SendNotification();
739 application.Render();
741 const Vector2& scrollPosition = view.GetScrollPosition();
742 DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
746 int UtcDaliTextInputSetActiveStyle(void)
748 ToolkitTestApplication application;
750 tet_infoline("Testing Setting of Style to newly added text");
752 TextInput textInput = TextInput::New(); // create empty TextInput
754 Stage::GetCurrent().Add(textInput);
756 const std::string styledString = "Test String<i>ab</i>" ;
757 const std::string plainString = "Test String";
758 textInput.SetInitialText( plainString );
760 application.SendNotification();
761 application.Render();
763 textInput.SetEditable(true);
765 std::string retreivedMarkupString = textInput.GetMarkupText();
767 tet_infoline("Confirm markup text is a plain string ");
768 DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
771 style.SetItalics( true );
773 tet_infoline("Apply style to TextInput");
774 textInput.SetActiveStyle( style );
776 Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
777 Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
779 application.SendNotification();
780 application.Render();
782 application.ProcessEvent(eventA);
783 application.SendNotification();
784 application.Render();
786 application.ProcessEvent(eventB);
787 application.SendNotification();
788 application.Render();
790 retreivedMarkupString = textInput.GetMarkupText();
792 DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
796 int UtcDaliTextInputApplyStyleToSelectedText(void)
798 ToolkitTestApplication application;
800 tet_infoline("Testing application of style to selected text ");
802 TextInput textInput = TextInput::New(); // create empty TextInput
804 Stage::GetCurrent().Add(textInput);
806 const std::string styledString = "Test <i>String</i> to style";
807 const std::string plainString = "Test String to style";
808 textInput.SetInitialText( plainString );
810 application.SendNotification();
811 application.Render();
813 textInput.SetEditable(true);
815 std::string retreivedMarkupString = textInput.GetMarkupText();
817 tet_infoline("Confirm markup text is a plain string ");
818 DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
821 style.SetItalics( true );
823 textInput.SelectText( 5, 11 );
825 tet_infoline("Apply style to selected text");
826 textInput.ApplyStyle( style );
828 application.Render();
830 retreivedMarkupString = textInput.GetMarkupText();
832 DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
836 int UtcDaliTextInputApplyStyleToAll(void)
838 ToolkitTestApplication application;
840 tet_infoline("Testing application of style to all text ");
842 TextInput textInput = TextInput::New(); // create empty TextInput
844 Stage::GetCurrent().Add(textInput);
846 const std::string styledString = "<i>Test String to style</i>";
847 const std::string plainString = "Test String to style";
848 textInput.SetInitialText( plainString );
850 application.SendNotification();
851 application.Render();
853 textInput.SetEditable(true);
855 std::string retreivedMarkupString = textInput.GetMarkupText();
857 tet_infoline("Confirm markup text is a plain string ");
858 DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
861 style.SetItalics( true );
863 tet_infoline("Apply style to all text");
864 textInput.ApplyStyleToAll( style );
866 application.Render();
868 retreivedMarkupString = textInput.GetMarkupText();
870 DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
874 int UtcDaliTextInputGetStyleAtCursor(void)
876 ToolkitTestApplication application;
878 tet_infoline("Test getting style at cursor");
880 TextInput textInput = TextInput::New(); // create empty TextInput
882 Stage::GetCurrent().Add(textInput);
884 const std::string styledString = "Test Stringa<i>b</i>" ;
885 const std::string plainString = "Test String";
886 textInput.SetInitialText( plainString );
888 application.SendNotification();
889 application.Render();
891 textInput.SetEditable(true);
893 tet_infoline("Confirm style at cursor is default(plain)");
895 Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
896 application.ProcessEvent(eventA);
897 application.SendNotification();
898 application.Render();
900 TextStyle retreivedStyleAtCursor = textInput.GetStyleAtCursor();
902 DALI_TEST_CHECK( style == retreivedStyleAtCursor );
903 DALI_TEST_CHECK( !retreivedStyleAtCursor.IsItalicsEnabled() );
905 tet_infoline("Set style before adding new character");
906 style.SetItalics( true );
907 textInput.SetActiveStyle( style );
909 Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
910 application.ProcessEvent(eventB);
911 application.SendNotification();
912 application.Render();
914 tet_infoline("Confirm style at cursor is correct style");
915 retreivedStyleAtCursor = textInput.GetStyleAtCursor();
917 DALI_TEST_CHECK( retreivedStyleAtCursor.IsItalicsEnabled() );
919 tet_infoline("Confirm style at cursor is not a style that was not set");
920 DALI_TEST_CHECK( !retreivedStyleAtCursor.IsUnderlineEnabled() );
922 tet_infoline("Confirm markup text is correct");
923 DALI_TEST_EQUALS( styledString, textInput.GetMarkupText(), TEST_LOCATION);
930 int UtcDaliTextInputSetAndGetMultilinePolicy(void)
932 ToolkitTestApplication application;
934 const TextView::MultilinePolicy MULTILINE_POLICIES[] = { TextView::SplitByNewLineChar, TextView::SplitByWord, TextView::SplitByChar };
935 const unsigned int NUM_MULTILINE_POLICIES = sizeof( MULTILINE_POLICIES ) / sizeof( unsigned int );
937 TextInput textInput = TextInput::New();
938 Stage::GetCurrent().Add(textInput);
939 textInput.SetInitialText( "Hello world!" );
941 for( unsigned int epIndex = 0; epIndex < NUM_MULTILINE_POLICIES; ++epIndex )
943 textInput.SetMultilinePolicy( MULTILINE_POLICIES[epIndex] );
945 DALI_TEST_EQUALS( textInput.GetMultilinePolicy(), MULTILINE_POLICIES[epIndex], TEST_LOCATION );
950 int UtcDaliTextInputSetAndGetExceedEnabled(void)
952 ToolkitTestApplication application;
954 const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
955 const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
957 TextInput textInput = TextInput::New();
958 Stage::GetCurrent().Add(textInput);
959 textInput.SetInitialText( "Hello world!" );
961 for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
963 textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
965 DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );