X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=7e050ffa7a8f6eeab329591ed9e0b6ef8beef747;hp=893d26ab2ba0bbcd763e4ec35113fff6bcd5be01;hb=590ede8c5f4771821ff5ac3f3acef0d189525008;hpb=5a49c794732c6e87a5fa1fa3ae71be376a40434d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 893d26a..7e050ff 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -21,11 +21,10 @@ #include #include -#include #include -#include -#include + #include +#include #include #include #include @@ -102,6 +101,8 @@ const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection"; const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle"; const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection"; +const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup"; +const char* const PROPERTY_NAME_BACKGROUND = "textBackground"; const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. @@ -149,48 +150,6 @@ static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField) textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap ); } -// Generate a PanGestureEvent to send to Core -static Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, 16)); - - last.x = pos.x; - last.y = pos.y; -} - /* * Simulate time passed by. * @@ -266,34 +225,6 @@ static void TestInputStyleChangedCallback( TextField control, TextField::InputSt gInputStyleMask = mask; } -// Generate a TapGestureEvent to send to Core. -Integration::TapGestureEvent GenerateTap( - Gesture::State state, - unsigned int numberOfTaps, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::TapGestureEvent tap( state ); - - tap.numberOfTaps = numberOfTaps; - tap.numberOfTouches = numberOfTouches; - tap.point = point; - - return tap; -} - -Integration::LongPressGestureEvent GenerateLongPress( - Gesture::State state, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::LongPressGestureEvent longPress( state ); - - longPress.numberOfTouches = numberOfTouches; - longPress.point = point; - return longPress; -} - // Generate a KeyEvent to send to Core. Integration::KeyEvent GenerateKey( const std::string& keyName, const std::string& logicalKey, @@ -539,6 +470,8 @@ int UtcDaliTextFieldGetPropertyP(void) DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND ); END_TEST; } @@ -993,6 +926,15 @@ int UtcDaliTextFieldSetPropertyP(void) field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT ); DALI_TEST_EQUALS( field.GetProperty( Actor::Property::LAYOUT_DIRECTION ), static_cast( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION ); + // Test the ENABLE_GRAB_HANDLE_POPUP property + DALI_TEST_CHECK( field.GetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) ); + field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false ); + DALI_TEST_CHECK( !field.GetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) ); + + // Check the background property + field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED ); + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -1156,15 +1098,13 @@ int utcDaliTextFieldMaxCharactersReachedN(void) int utcDaliTextFieldInputStyleChanged01(void) { - ToolkitTestApplication application; - tet_infoline(" utcDaliTextFieldInputStyleChanged01"); - // The text-field emits signals when the input style changes. These changes of style are // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals // can't be emitted during the size negotiation as the callbacks may update the UI. // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation. - // This creates an implementation of the adaptor stub and a queue of idle callbacks. - application.CreateAdaptor(); + // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks. + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldInputStyleChanged01"); // Load some fonts. @@ -1209,8 +1149,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) ); + TestGenerateTap( application, 18.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1237,8 +1176,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) ); + TestGenerateTap( application, 30.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1255,8 +1193,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) ); + TestGenerateTap( application, 43.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1280,8 +1217,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) ); + TestGenerateTap( application, 88.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1313,8 +1249,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) ); + TestGenerateTap( application, 115.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1331,8 +1266,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) ); + TestGenerateTap( application, 164.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1356,8 +1290,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) ); + TestGenerateTap( application, 191.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1374,15 +1307,13 @@ int utcDaliTextFieldInputStyleChanged01(void) int utcDaliTextFieldInputStyleChanged02(void) { - ToolkitTestApplication application; - tet_infoline(" utcDaliTextFieldInputStyleChanged02"); - // The text-field emits signals when the input style changes. These changes of style are // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals // can't be emitted during the size negotiation as the callbacks may update the UI. // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation. - // This creates an implementation of the adaptor stub and a queue of idle callbacks. - application.CreateAdaptor(); + // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks. + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldInputStyleChanged02"); // Load some fonts. @@ -1399,7 +1330,6 @@ int utcDaliTextFieldInputStyleChanged02(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -1427,10 +1357,8 @@ int utcDaliTextFieldInputStyleChanged02(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) ); + TestGenerateTap( application, 53.0f, 25.0f, 100 ); + TestGenerateTap( application, 53.0f, 25.0f, 200 ); // Render and notify application.SendNotification(); @@ -1555,8 +1483,7 @@ int utcDaliTextFieldInputStyleChanged02(void) DALI_TEST_CHECK( !inputStyleChangedSignal ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) ); + TestGenerateTap( application, 63.0f, 25.0f, 300 ); // Render and notify application.SendNotification(); @@ -1603,6 +1530,10 @@ int utcDaliTextFieldEvent01(void) field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + // Render and notify + application.SendNotification(); + application.Render(); + // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1620,8 +1551,7 @@ int utcDaliTextFieldEvent01(void) DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1648,8 +1578,8 @@ int utcDaliTextFieldEvent01(void) field2.SetParentOrigin( ParentOrigin::TOP_LEFT ); field2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - field2.SetSize( 100.f, 100.f ); - field2.SetPosition( 100.f, 100.f ); + field2.SetSize( 100.f, 100.0f ); + field2.SetPosition( 100.0f, 100.0f ); Stage::GetCurrent().Add( field2 ); @@ -1658,8 +1588,7 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Create a tap event on the second text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); + TestGenerateTap( application, 150.0f, 125.0f ); // Render and notify application.SendNotification(); @@ -1693,7 +1622,7 @@ int utcDaliTextFieldEvent02(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -1711,8 +1640,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f, 300 ); // Render and notify application.SendNotification(); @@ -1781,8 +1709,7 @@ int utcDaliTextFieldEvent02(void) // Send some taps and check the cursor positions. // Try to tap at the beginning. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f, 900 ); // Render and notify application.SendNotification(); @@ -1794,8 +1721,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2. // Tap away from the start position. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) ); + TestGenerateTap( application, 16.0f, 25.0f, 1500 ); // Render and notify application.SendNotification(); @@ -1862,16 +1788,14 @@ int utcDaliTextFieldEvent03(void) application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1923,32 +1847,28 @@ int utcDaliTextFieldEvent04(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap grab handle - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) ); + TestGenerateTap( application, 0.0f, 40.0f ); END_TEST; } @@ -1980,45 +1900,25 @@ int utcDaliTextFieldEvent05(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); - // drag grab handle right - Vector2 pos(0.0f, 40.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); - pos.x += 5.0f; - Wait(application, 100); - - for(int i = 0;i<20;i++) - { - SendPan(application, Gesture::Continuing, pos); - pos.x += 5.0f; - Wait(application); - } - - SendPan(application, Gesture::Finished, pos); - Wait(application, RENDER_FRAME_INTERVAL); - Actor stencil = field.GetChildAt( 1u ); END_TEST; } @@ -2051,24 +1951,21 @@ int utcDaliTextFieldEvent06(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress(application, 1.0f, 25.0f); // Render and notify application.SendNotification(); @@ -2108,8 +2005,7 @@ int utcDaliTextFieldEvent07(void) application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress(application, 1.0f, 25.0f); // Render and notify application.SendNotification(); @@ -2149,8 +2045,7 @@ int utcDaliTextFieldEvent08(void) application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress( application, 1.0f, 25.0f, 20 ); // Render and notify application.SendNotification(); @@ -2158,12 +2053,12 @@ int utcDaliTextFieldEvent08(void) Wait(application, 500); + TestEndLongPress( application, 1.0f, 25.0f, 520 ); + // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress( application, 1.0f, 25.0f, 600 ); // Render and notify - application.SendNotification(); application.Render(); Wait(application, 500); @@ -2215,8 +2110,7 @@ int utcDaliTextFieldEvent09(void) application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); application.SendNotification(); application.Render(); @@ -2306,24 +2200,21 @@ int utcDaliTextFieldStyleWhilstSelected(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2422,8 +2313,7 @@ int utcDaliTextFieldEscKeyLoseFocus(void) DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2494,24 +2384,21 @@ int utcDaliTextFieldSomeSpecialKeys(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2765,7 +2652,7 @@ int UtcDaliTextFieldEnableShiftSelectionProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2793,7 +2680,7 @@ int UtcDaliTextFieldEnableGrabHandleProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2821,7 +2708,7 @@ int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2854,7 +2741,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -2870,8 +2757,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2885,8 +2771,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2896,8 +2781,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2907,8 +2791,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2927,7 +2810,6 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) END_TEST; } - int UtcDaliTextFieldGetInputMethodContext(void) { ToolkitTestApplication application; @@ -2939,3 +2821,54 @@ int UtcDaliTextFieldGetInputMethodContext(void) END_TEST; } +int UtcDaliTextFieldSelectWholeText(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldSelectWholeText "); + + TextField textField = TextField::New(); + + Stage::GetCurrent().Add( textField ); + + textField.SetSize( 300.f, 50.f ); + textField.SetParentOrigin( ParentOrigin::TOP_LEFT ); + textField.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION ); + + DevelTextField::SelectWholeText( textField ); + + application.SendNotification(); + application.Render(); + + // Nothing should have been selected. The number of children is still 1 + DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION ); + + textField.SetProperty( TextField::Property::TEXT, "Hello world" ); + + application.SendNotification(); + application.Render(); + + DevelTextField::SelectWholeText( textField ); + + application.SendNotification(); + application.Render(); + + // Should be 2 children, the stencil and the layer + DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION ); + + // The offscreen root actor should have two actors: the renderer and the highlight actor. + Actor stencil = textField.GetChildAt( 0u ); + + // The highlight actor is drawn first, so is the first actor in the list + Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u ); + DALI_TEST_CHECK( highlight ); + + END_TEST; +}