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=b83c5e5242c7b926de43ed3594d08c3e8c53df14;hp=893d26ab2ba0bbcd763e4ec35113fff6bcd5be01;hb=0d07bc303ad28647afa1342319721384cc37d19f;hpb=c669b77c3ed3a677855e2320be85f91c4571445f diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 893d26a..b83c5e5 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,14 @@ #include #include -#include #include -#include -#include + #include +#include #include #include #include +#include #include "toolkit-clipboard.h" using namespace Dali; @@ -102,6 +102,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 +151,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 +226,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, @@ -486,7 +418,7 @@ int UtcDaliTextFieldGetPropertyP(void) DALI_TEST_CHECK( field ); // Check Property Indices are correct - DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED ); @@ -539,6 +471,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; } @@ -573,8 +507,11 @@ int UtcDaliTextFieldSetPropertyP(void) // Note - we can't check the defaults since the stylesheets are platform-specific // Check the render backend property. - field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); - DALI_TEST_EQUALS( (Text::RenderingType)field.GetProperty( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION ); + field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS ); + DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION ); + + field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED ); + DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION ); // Check text property. field.SetProperty( TextField::Property::TEXT, "Setting Text" ); @@ -993,6 +930,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(); @@ -1018,7 +964,7 @@ int utcDaliTextFieldAtlasRenderP(void) try { // Render some text with the shared atlas backend - field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); + field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS ); application.SendNotification(); application.Render(); } @@ -1156,15 +1102,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. @@ -1182,9 +1126,9 @@ int utcDaliTextFieldInputStyleChanged01(void) DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); field.SetProperty( TextField::Property::ENABLE_MARKUP, true ); field.SetProperty( TextField::Property::TEXT, "Hello world demo" ); @@ -1209,8 +1153,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 +1180,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 +1197,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 +1221,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 +1253,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 +1270,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 +1294,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 +1311,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,10 +1334,9 @@ 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 ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); field.SetProperty( TextField::Property::ENABLE_MARKUP, true ); field.SetProperty( TextField::Property::TEXT, "He llo world demo" ); @@ -1427,10 +1361,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 +1487,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(); @@ -1599,9 +1530,13 @@ int utcDaliTextFieldEvent01(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, 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 +1555,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(); @@ -1646,10 +1580,10 @@ int utcDaliTextFieldEvent01(void) // Create a second text field and send key events to it. TextField field2 = TextField::New(); - field2.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - field2.SetSize( 100.f, 100.f ); - field2.SetPosition( 100.f, 100.f ); + field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) ); + field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f )); Stage::GetCurrent().Add( field2 ); @@ -1658,8 +1592,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,9 +1626,9 @@ int utcDaliTextFieldEvent02(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1711,15 +1644,14 @@ 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(); application.Render(); Actor layer = field.GetChildAt( 1u ); - DALI_TEST_CHECK( layer.IsLayer() ); + DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) ); DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor. DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); @@ -1748,14 +1680,14 @@ int utcDaliTextFieldEvent02(void) } // Move the cursor and check the position changes. - Vector3 position1 = cursor.GetCurrentPosition(); + Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); // Render and notify application.SendNotification(); application.Render(); - Vector3 position2 = cursor.GetCurrentPosition(); + Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); DALI_TEST_CHECK( position2.x < position1.x ); application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); @@ -1764,7 +1696,7 @@ int utcDaliTextFieldEvent02(void) application.SendNotification(); application.Render(); - Vector3 position3 = cursor.GetCurrentPosition(); + Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1. @@ -1776,32 +1708,30 @@ int utcDaliTextFieldEvent02(void) application.SendNotification(); application.Render(); - Vector3 position4 = cursor.GetCurrentPosition(); + Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); // 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(); application.Render(); // Cursor position should be the same than position1. - Vector3 position5 = cursor.GetCurrentPosition(); + Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); 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(); application.Render(); - Vector3 position6 = cursor.GetCurrentPosition(); + Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); DALI_TEST_CHECK( position6.x > position5.x ); @@ -1815,7 +1745,7 @@ int utcDaliTextFieldEvent02(void) application.Render(); // Cursor position should be the same than position2. - Vector3 position7 = cursor.GetCurrentPosition(); + Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2. @@ -1849,9 +1779,9 @@ int utcDaliTextFieldEvent03(void) field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 30.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1862,16 +1792,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(); @@ -1912,9 +1840,9 @@ int utcDaliTextFieldEvent04(void) field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1923,32 +1851,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; } @@ -1969,9 +1893,9 @@ int utcDaliTextFieldEvent05(void) field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1980,45 +1904,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; } @@ -2040,9 +1944,9 @@ int utcDaliTextFieldEvent06(void) field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2051,24 +1955,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(); @@ -2094,9 +1995,9 @@ int utcDaliTextFieldEvent07(void) field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Property::Map propertyMap; propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD; field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap ); @@ -2108,8 +2009,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(); @@ -2138,9 +2038,9 @@ int utcDaliTextFieldEvent08(void) field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2149,8 +2049,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 +2057,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); @@ -2174,7 +2073,7 @@ int utcDaliTextFieldEvent08(void) if (actor) { - Vector3 worldPosition = actor.GetCurrentWorldPosition(); + Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ); Vector2 halfStageSize = stage.GetSize() / 2.0f; Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height); @@ -2207,16 +2106,15 @@ int utcDaliTextFieldEvent09(void) field.SetProperty( TextField::Property::TEXT, "Hello" ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. 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(); @@ -2295,9 +2193,9 @@ int utcDaliTextFieldStyleWhilstSelected(void) field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2306,24 +2204,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(); @@ -2400,9 +2295,9 @@ int utcDaliTextFieldEscKeyLoseFocus(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2422,8 +2317,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(); @@ -2483,9 +2377,9 @@ int utcDaliTextFieldSomeSpecialKeys(void) field.SetProperty( TextField::Property::TEXT, longText ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2494,24 +2388,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(); @@ -2563,15 +2454,15 @@ int utcDaliTextFieldSizeUpdate(void) // "ㅁ" is bigger then "ኢ" - field.SetSize( Vector2( fieldWidth ,10.0f ) ); + field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) ); field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH ); field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT ); field.SetProperty( TextField::Property::TEXT, "ኢ"); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - field.SetKeyboardFocusable(true); + field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true); KeyboardFocusManager::Get().SetCurrentFocusActor( field ); application.SendNotification(); @@ -2602,9 +2493,9 @@ int utcDaliTextFieldExtremlyLargePointSize(void) TextField field = TextField::New(); field.SetProperty( TextField::Property::TEXT, "Text" ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); try @@ -2732,9 +2623,9 @@ int UtcDaliTextFieldSetPaddingProperty(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 ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); application.SendNotification(); @@ -2765,9 +2656,9 @@ int UtcDaliTextFieldEnableShiftSelectionProperty(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 ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); application.SendNotification(); @@ -2793,9 +2684,9 @@ int UtcDaliTextFieldEnableGrabHandleProperty(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 ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); application.SendNotification(); @@ -2821,9 +2712,9 @@ int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(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 ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); application.SendNotification(); @@ -2854,9 +2745,9 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); - field.SetParentOrigin( ParentOrigin::TOP_LEFT ); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2870,8 +2761,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 +2775,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 +2785,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 +2795,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 +2814,6 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) END_TEST; } - int UtcDaliTextFieldGetInputMethodContext(void) { ToolkitTestApplication application; @@ -2939,3 +2825,103 @@ int UtcDaliTextFieldGetInputMethodContext(void) END_TEST; } +int UtcDaliTextFieldSelectWholeText(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldSelectWholeText "); + + TextField textField = TextField::New(); + + Stage::GetCurrent().Add( textField ); + + textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textField.SetProperty( Actor::Property::ANCHOR_POINT, 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; +} + +int UtcDaliTextFieldSelectNone(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldSelectWholeText "); + + TextField textField = TextField::New(); + + Stage::GetCurrent().Add( textField ); + + textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + application.SendNotification(); + application.Render(); + + textField.SetProperty( TextField::Property::TEXT, "Hello world" ); + + application.SendNotification(); + application.Render(); + + // Nothing is selected + std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION ); + + DevelTextField::SelectWholeText( textField ); + + application.SendNotification(); + application.Render(); + + // whole text is selected + selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION ); + + DevelTextField::SelectNone( textField ); + + application.SendNotification(); + application.Render(); + + // Nothing is selected + selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION ); + + END_TEST; +}