Dali 3D User Interface Engine
utc-Dali-TextField.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <iostream>
19 #include <stdlib.h>
26 
27 using namespace Dali;
28 using namespace Toolkit;
29 
31 {
33 }
34 
36 {
38 }
39 
40 namespace
41 {
42 
43 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
44 const char* const PROPERTY_NAME_TEXT = "text";
45 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
46 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
47 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
48 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
49 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
50 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
51 const char* const PROPERTY_NAME_EXCEED_POLICY = "exceedPolicy";
52 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
53 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
54 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
55 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
56 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
57 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
67 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
73 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
74 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
75 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
76 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
77 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
78 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
79 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
80 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
81 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
82 
84 
85 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
86 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
87 
88 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
89 const float TO_MILLISECONDS = 1000.f;
90 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
91 
92 const float SCROLL_THRESHOLD = 10.f;
93 const float SCROLL_SPEED = 300.f;
94 
97 
98 static void TestTextChangedCallback( TextField control )
99 {
100  tet_infoline(" TestTextChangedCallback");
101 
102  gTextChangedCallBackCalled = true;
103 }
104 
106 {
107  tet_infoline(" TestMaxLengthReachedCallback");
108 
109  gMaxCharactersCallBackCalled = true;
110 }
111 
112 // Generate a TapGestureEvent to send to Core.
113 Integration::TapGestureEvent GenerateTap(
114  Gesture::State state,
115  unsigned int numberOfTaps,
116  unsigned int numberOfTouches,
117  Vector2 point)
118 {
119  Integration::TapGestureEvent tap( state );
120 
121  tap.numberOfTaps = numberOfTaps;
122  tap.numberOfTouches = numberOfTouches;
123  tap.point = point;
124 
125  return tap;
126 }
127 
128 // Generate a KeyEvent to send to Core.
129 Integration::KeyEvent GenerateKey( const std::string& keyName,
130  const std::string& keyString,
131  int keyCode,
132  int keyModifier,
133  unsigned long timeStamp,
134  const Integration::KeyEvent::State& keyState )
135 {
136  return Integration::KeyEvent( keyName,
137  keyString,
138  keyCode,
139  keyModifier,
140  timeStamp,
141  keyState );
142 }
143 
144 } // namespace
145 
147 {
148  ToolkitTestApplication application;
149  tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
150  TextField textField;
151  DALI_TEST_CHECK( !textField );
152  END_TEST;
153 }
154 
156 {
157  ToolkitTestApplication application;
158  tet_infoline(" UtcDaliToolkitTextFieldNewP");
159  TextField textField = TextField::New();
160  DALI_TEST_CHECK( textField );
161  END_TEST;
162 }
163 
165 {
166  ToolkitTestApplication application;
167  tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
168  TextField textField1 = TextField::New();
169  BaseHandle object( textField1 );
170 
171  TextField textField2 = TextField::DownCast( object );
172  DALI_TEST_CHECK( textField2 );
173 
174  TextField textField3 = DownCast< TextField >( object );
175  DALI_TEST_CHECK( textField3 );
176  END_TEST;
177 }
178 
180 {
181  ToolkitTestApplication application;
182  tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
183  BaseHandle uninitializedObject;
184  TextField textField1 = TextField::DownCast( uninitializedObject );
185  DALI_TEST_CHECK( !textField1 );
186 
187  TextField textField2 = DownCast< TextField >( uninitializedObject );
188  DALI_TEST_CHECK( !textField2 );
189  END_TEST;
190 }
191 
193 {
194  ToolkitTestApplication application;
195  tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
196  TextField textField = TextField::New();
197  textField.SetProperty( TextField::Property::TEXT, "Test" );
198 
199  TextField copy( textField );
200  DALI_TEST_CHECK( copy );
201  DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
202  END_TEST;
203 }
204 
206 {
207  ToolkitTestApplication application;
208  tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
209  TextField textField = TextField::New();
210  textField.SetProperty( TextField::Property::TEXT, "Test" );
211 
212  TextField copy = textField;
213  DALI_TEST_CHECK( copy );
214  DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
215  END_TEST;
216 }
217 
219 {
220  ToolkitTestApplication application;
221  tet_infoline(" UtcDaliToolkitTextFieldNewP");
222  TextField textField = TextField::New();
223  DALI_TEST_CHECK( textField );
224  END_TEST;
225 }
226 
227 // Positive test case for a method
229 {
230  ToolkitTestApplication application;
231  tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
232  TextField field = TextField::New();
233  DALI_TEST_CHECK( field );
234 
235  // Check Property Indices are correct
275  END_TEST;
276 }
277 
278 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
279 {
280  bool result = false;
281  Property::Map imageMap;
282  imageMap[mapKey] =mapValue;
283 
284  field.SetProperty( property , imageMap );
285  Property::Value propValue = field.GetProperty( property );
286  Property::Map* resultMap = propValue.GetMap();
287 
288  if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
289  {
290  result = true;
291  }
292 
293  return result;
294 }
295 
296 // Positive test case for a method
298 {
299  ToolkitTestApplication application;
300  tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
301  TextField field = TextField::New();
302  DALI_TEST_CHECK( field );
303  Stage::GetCurrent().Add( field );
304 
305  // Note - we can't check the defaults since the stylesheets are platform-specific
306 
307  // Check the render backend property.
310 
311  // Check text property.
312  field.SetProperty( TextField::Property::TEXT, "Setting Text" );
313  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
314 
315  // Check placeholder text properties.
316  field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
317  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
318 
319  field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
320  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
321 
322  // Check font properties.
323  field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
324  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
325  field.SetProperty( TextField::Property::FONT_STYLE, "Setting font style" );
326  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION );
329 
330  // Check that the MAX_LENGTH property can be correctly set
331  const int maxNumberOfCharacters = 20;
332  field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
333  DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
334 
335  // Check exceed policy
336  // Set a different exceed policy is not implemented.
337 
338  // Check that the Alignment properties can be correctly set
343 
344  // Check text's color property
347 
348  // Check placeholder text's color property.
351 
352  // Check shadow properties.
357 
358  // Check cursor properties
363 
372 
373  // Check scroll properties.
378 
379  // Check handle images
385 
386  // Check handle images
393 
394  // Check the highlight color
397 
398  // Decoration bounding box
401 
402  // Check input color property.
405 
406  // Check the enable markup property.
410 
411  // Check input font properties.
412  field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
413  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
414  field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "Setting input font style" );
415  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "Setting input font style", TEST_LOCATION );
418 
419  END_TEST;
420 }
421 
422 // Positive Atlas Text Renderer test
424 {
425  ToolkitTestApplication application;
426  tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
427  StyleManager styleManager = StyleManager::Get();
428  styleManager.RequestDefaultTheme();
429  TextField field = TextField::New();
430  DALI_TEST_CHECK( field );
431 
433 
435 
436  Stage::GetCurrent().Add( field );
437 
438  try
439  {
440  // Render some text with the shared atlas backend
442  application.SendNotification();
443  application.Render();
444  }
445  catch( ... )
446  {
448  }
449  END_TEST;
450 }
451 
452 // Positive test for the textChanged signal.
454 {
455  ToolkitTestApplication application;
456  tet_infoline(" utcDaliTextFieldTextChangedP");
457  TextField field = TextField::New();
458  DALI_TEST_CHECK( field );
459 
460  Stage::GetCurrent().Add( field );
461 
462  field.TextChangedSignal().Connect(&TestTextChangedCallback);
463 
465  field.SetProperty( TextField::Property::TEXT, "ABC" );
467 
468  application.SendNotification();
469 
470  field.SetKeyInputFocus();
471 
473  application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
475 
476  END_TEST;
477 }
478 
479 // Negative test for the textChanged signal.
481 {
482  ToolkitTestApplication application;
483  tet_infoline(" utcDaliTextFieldTextChangedN");
484  TextField field = TextField::New();
485  DALI_TEST_CHECK( field );
486 
487  Stage::GetCurrent().Add( field );
488 
489  field.TextChangedSignal().Connect(&TestTextChangedCallback);
490 
492  field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
494 
495  END_TEST;
496 }
497 
498 // Positive test for Max Characters reached signal.
500 {
501  ToolkitTestApplication application;
502  tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
503  TextField field = TextField::New();
504  DALI_TEST_CHECK( field );
505 
506  Stage::GetCurrent().Add( field );
507 
508  const int maxNumberOfCharacters = 1;
509  field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
510 
511  field.SetKeyInputFocus();
512 
515 
516  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
517  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
518 
520 
521  END_TEST;
522 }
523 
524 // Negative test for Max Characters reached signal.
526 {
527  ToolkitTestApplication application;
528  tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
529  TextField field = TextField::New();
530  DALI_TEST_CHECK( field );
531 
532  Stage::GetCurrent().Add( field );
533 
534  const int maxNumberOfCharacters = 3;
535  field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
536 
537  field.SetKeyInputFocus();
538 
541 
542  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
543  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
544 
546 
547  END_TEST;
548 }
549 
551 {
552  ToolkitTestApplication application;
553  tet_infoline(" utcDaliTextFieldEvent01");
554 
555  // Creates a tap event. After creating a tap event the text field should
556  // have the focus and add text with key events should be possible.
557 
558  TextField field = TextField::New();
559  DALI_TEST_CHECK( field );
560 
561  Stage::GetCurrent().Add( field );
562 
563  field.SetSize( 300.f, 50.f );
566 
567  // Avoid a crash when core load gl resources.
569 
570  // Render and notify
571  application.SendNotification();
572  application.Render();
573 
574  // Add a key event but as the text field has not the focus it should do nothing.
575  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
576 
577  // Render and notify
578  application.SendNotification();
579  application.Render();
580 
581  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
582 
583  // Create a tap event to touch the text field.
584  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
585  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
586 
587  // Render and notify
588  application.SendNotification();
589  application.Render();
590 
591  // Now the text field has the focus, so it can handle the key events.
592  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
593  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
594 
595  // Render and notify
596  application.SendNotification();
597  application.Render();
598 
599  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
600 
601  // Create a second text field and send key events to it.
602  TextField field2 = TextField::New();
603 
606  field2.SetSize( 100.f, 100.f );
607  field2.SetPosition( 100.f, 100.f );
608 
609  Stage::GetCurrent().Add( field2 );
610 
611  // Render and notify
612  application.SendNotification();
613  application.Render();
614 
615  // Create a tap event on the second text field.
616  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
617  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
618 
619  // Render and notify
620  application.SendNotification();
621  application.Render();
622 
623  // The second text field has the focus. It should handle the key events.
624  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
625  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
626 
627  // Render and notify
628  application.SendNotification();
629  application.Render();
630 
631  // Check the text has been added to the second text field.
632  DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
633 
634  END_TEST;
635 }
636 
638 {
639  ToolkitTestApplication application;
640  tet_infoline(" utcDaliTextFieldEvent02");
641 
642  // Checks if the right number of actors are created.
643 
644  TextField field = TextField::New();
646  DALI_TEST_CHECK( field );
647 
648  Stage::GetCurrent().Add( field );
649 
650  field.SetSize( 300.f, 50.f );
653 
654  // Avoid a crash when core load gl resources.
656 
657  // Render and notify
658  application.SendNotification();
659  application.Render();
660 
661  // Check there are the expected number of children ( active layer, offscreen root actor, and the offscreen image actor
663 
664  Actor layer = field.GetChildAt( 0u );
665  DALI_TEST_CHECK( layer.IsLayer() );
666 
667  Actor offscreenRoot = field.GetChildAt( 1u );
668  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
669  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
670 
671  Actor offscreenImage = field.GetChildAt( 2u );
672  ImageActor imageActor = ImageActor::DownCast( offscreenImage );
673  DALI_TEST_CHECK( imageActor );
674 
675  // Create a tap event to touch the text field.
676  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
677  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
678 
679  // Render and notify
680  application.SendNotification();
681  application.Render();
682 
683  DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
684  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
685 
686  // Now the text field has the focus, so it can handle the key events.
687  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
688  application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
689 
690  // Render and notify
691  application.SendNotification();
692  application.Render();
693 
694  // Checks the cursor and the renderer have been created.
695  DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
696  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
697 
698  Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
699  DALI_TEST_CHECK( cursor );
700 
701  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
702  DALI_TEST_CHECK( camera );
703 
704  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
705  DALI_TEST_CHECK( renderer );
706 
707  // Move the cursor and check the position changes.
708  Vector3 position1 = cursor.GetCurrentPosition();
709 
712 
713  // Render and notify
714  application.SendNotification();
715  application.Render();
716 
717  Vector3 position2 = cursor.GetCurrentPosition();
718 
719  DALI_TEST_CHECK( position2.x < position1.x );
720 
723 
724  // Render and notify
725  application.SendNotification();
726  application.Render();
727 
728  Vector3 position3 = cursor.GetCurrentPosition();
729 
730  DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
731 
732  // Send some taps and check the cursor positions.
733 
734  // Try to tap at the beginning.
735  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
736  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
737 
738  // Render and notify
739  application.SendNotification();
740  application.Render();
741 
742  // Cursor position should be the same than position1.
743  Vector3 position4 = cursor.GetCurrentPosition();
744 
745  DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
746 
747  // Tap away from the start position.
748  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
749  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
750 
751  // Render and notify
752  application.SendNotification();
753  application.Render();
754 
755  Vector3 position5 = cursor.GetCurrentPosition();
756 
757  DALI_TEST_CHECK( position5.x > position4.x );
758 
759  // Remove all the text.
763 
764  // Render and notify
765  application.SendNotification();
766  application.Render();
767 
768  // Cursor position should be the same than position2.
769  Vector3 position6 = cursor.GetCurrentPosition();
770 
771  DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
772 
773  // Should not be a renderer.
774  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
775 
776  END_TEST;
777 }
778 
780 {
781  ToolkitTestApplication application;
782  tet_infoline(" utcDaliTextFieldEvent03");
783 
784  // Checks if the highlight actor is created.
785 
786  TextField field = TextField::New();
787  DALI_TEST_CHECK( field );
788 
789  Stage::GetCurrent().Add( field );
790 
791  field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
793  field.SetSize( 30.f, 50.f );
796 
797  // Avoid a crash when core load gl resources.
799 
800  // Render and notify
801  application.SendNotification();
802  application.Render();
803 
804  // Tap first to get the focus.
805  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
806  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
807 
808  // Render and notify
809  application.SendNotification();
810  application.Render();
811 
812  // Double tap to select a word.
813  application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
814  application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
815 
816  // Render and notify
817  application.SendNotification();
818  application.Render();
819 
820  // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
821  Actor offscreenRoot = field.GetChildAt( 1u );
822  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
823 
824  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
825  DALI_TEST_CHECK( camera );
826 
827  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
828  DALI_TEST_CHECK( renderer );
829 
830  Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
831  DALI_TEST_CHECK( highlight );
832 
833  END_TEST;
834 }
Dali Docs Home
Read more about Dali