#include <dali/integration-api/events/long-press-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/hidden-input-properties.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
#include "toolkit-clipboard.h"
using namespace Dali;
const char* const PROPERTY_NAME_OUTLINE = "outline";
const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
+const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
+const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
+const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
+const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
+const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
+
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
const int KEY_A_CODE = 38;
const int KEY_D_CODE = 40;
+const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
+
static bool gTextChangedCallBackCalled;
static bool gMaxCharactersCallBackCalled;
static bool gInputStyleChangedCallbackCalled;
int keyCode,
int keyModifier,
unsigned long timeStamp,
- const Integration::KeyEvent::State& keyState )
+ const Integration::KeyEvent::State& keyState,
+ const std::string& deviceName = DEFAULT_DEVICE_NAME,
+ const DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
+ const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE )
{
return Integration::KeyEvent( keyName,
keyString,
keyCode,
keyModifier,
timeStamp,
- keyState );
+ keyState,
+ deviceName,
+ deviceClass,
+ deviceSubclass );
}
bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
{
const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
- Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
- if( NULL != valueSet )
+ if( valueGet.first.type == Property::Key::STRING )
{
- if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+ Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+ if( NULL != valueSet )
{
- tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+ if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+ {
+ tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+ return false;
+ }
+ }
+ else
+ {
+ tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
return false;
}
}
else
{
- tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
- return false;
+ Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+ if( NULL != valueSet )
+ {
+ if( valueGet.second.Get<int>() != valueSet->Get<int>() )
+ {
+ tet_printf( " Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+ return false;
+ }
+ }
+ else
+ {
+ tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
+ return false;
+ }
}
}
}
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextField::Property::ELLIPSIS );
END_TEST;
}
DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
// Check the outline property
- field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
+ Property::Map outlineMapSet;
+ Property::Map outlineMapGet;
+
+ outlineMapSet["color"] = Color::RED;
+ outlineMapSet["width"] = 2.0f;
+
+ field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
+
+ outlineMapSet["color"] = "red";
+ outlineMapSet["width"] = "2";
+ outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
+ DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
// Check the input outline property
field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
+ // Check the hidden input settings property
+ Property::Map hiddenMapSet;
+ Property::Map hiddenMapGet;
+ hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
+ hiddenMapSet[ HiddenInput::Property::SHOW_DURATION ] = 2;
+ hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
+ hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
+
+ hiddenMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
+ DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
+
+ // Check the pixel size of font
+ field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
+ DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ // Check the enable selection property
+ field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
+
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
+ placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
+ placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
+ placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+ placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
+
+ placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
+ placeholderMapSet["placeholderColor"] = Color::RED;
+ placeholderMapSet["placeholderFontFamily"] = "Arial";
+ placeholderMapSet["placeholderPointSize"] = 12.0f;
+ placeholderMapSet["placeholderEllipsis"] = false;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderFontstyleMap.Insert( "width", "condensed" );
+ placeholderFontstyleMap.Insert( "slant", "italic" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "weight", "normal" );
+ placeholderFontstyleMap.Insert( "slant", "oblique" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "slant", "roman" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Check the ellipsis property
+ DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
+ field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
+ DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
+
END_TEST;
}
field.SetKeyInputFocus();
gTextChangedCallBackCalled = false;
- application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
DALI_TEST_CHECK( gTextChangedCallBackCalled );
END_TEST;
gMaxCharactersCallBackCalled = false;
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
DALI_TEST_CHECK( maxLengthReachedSignal );
gMaxCharactersCallBackCalled = false;
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
DALI_TEST_CHECK( !maxLengthReachedSignal );
gInputStyleMask = TextField::InputStyle::NONE;
inputStyleChangedSignal = false;
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
gInputStyleMask = TextField::InputStyle::NONE;
inputStyleChangedSignal = false;
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
gInputStyleMask = TextField::InputStyle::NONE;
inputStyleChangedSignal = false;
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
application.Render();
// Add a key event but as the text field has not the focus it should do nothing.
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
application.Render();
// Now the text field has the focus, so it can handle the key events.
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
application.Render();
// The second text field has the focus. It should handle the key events.
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
// Now the text field has the focus, so it can handle the key events.
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
// Move the cursor and check the position changes.
Vector3 position1 = cursor.GetCurrentPosition();
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
DALI_TEST_CHECK( position2.x < position1.x );
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
// Render and notify
application.SendNotification();
DALI_TEST_CHECK( position5.x > position4.x );
// Remove all the text.
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
field.SetProperty( TextField::Property::TEXT, "" );
// Render and notify
// Should not be a renderer.
DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
+ // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
+ field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
+ field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
+
+ application.SendNotification();
+ application.Render();
+
+ // There are renderer and decorator layer
+ DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
+
END_TEST;
}
// The offscreen root actor should have two actors: the renderer and the highlight actor.
Actor stencil = field.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 );
+
// The offscreen root actor has a container with all the actors which contain the text renderers.
- Actor container = stencil.GetChildAt( 0u );
+ Actor container = stencil.GetChildAt( 1u );
for( unsigned int index = 0; index < container.GetChildCount(); ++index )
{
Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
DALI_TEST_CHECK( renderer );
}
- Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
- DALI_TEST_CHECK( highlight );
-
END_TEST;
}
Wait(application, 500);
+ // Long Press
+ application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Wait(application, 500);
+
Stage stage = Stage::GetCurrent();
Layer layer = stage.GetRootLayer();
Actor actor = layer.FindChildByName("optionPaste");
application.ProcessEvent( event );
}
DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent09(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent09");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ Stage::GetCurrent().Add( field );
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ 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 );
+
+ // 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 ) ) );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
+ map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
+ map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ for( unsigned int index = 0u; index < 5u; ++index )
+ {
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+ }
+
+ map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
+ map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ for( unsigned int index = 0u; index < 5u; ++index )
+ {
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+ }
+
+ map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
+ map[ HiddenInput::Property::SHOW_DURATION ] = 0;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ map[ HiddenInput::Property::SHOW_DURATION ] = 100;
+ field.SetProperty( DevelTextField::Property::HIDDEN_INPUT_SETTINGS, map );
+ application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map mapGet;
+ mapGet = field.GetProperty<Property::Map>( DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
+ DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
END_TEST;
}
+
int utcDaliTextFieldStyleWhilstSelected(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
// Press Escape to increase coverage
- application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
application.SendNotification();
application.Render();
END_TEST;
}
+
+int utcDaliTextFieldEscKeyLoseFocus(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
+
+ // Creates a tap event. After creating a tap event the text field should
+ // have the focus and add text with key events should be possible.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+ Stage::GetCurrent().Add( field );
+
+ field.SetSize( 300.f, 50.f );
+ field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Add a key event but as the text field has not the focus it should do nothing.
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( field.GetProperty<std::string>( 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 ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Now the text field has the focus, so it can handle the key events.
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
+
+ // No more text should be introduced
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextFieldSomeSpecialKeys(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
+
+ // Checks some special keys when the text is selected.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ Stage::GetCurrent().Add( field );
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ const std::string longText( "This is a long text for the size of the text-field." );
+
+ 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 );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ // Render and notify
+ application.SendNotification();
+ 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 ) ) );
+
+ // 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 ) ) );
+
+ // 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 ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "XF86PowerOff", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "XF86Menu", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "XF86Home", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // The text shouldn't be deleted.
+ DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextFieldSizeUpdate(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("utcDaliTextFieldSizeUpdate");
+
+ // Checks some special keys when the text is selected.
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ Stage::GetCurrent().Add( field );
+
+ float previousHeight = 0.0f;
+ float currentHeight = 0.0f;
+ const float fieldWidth = 1920.0f;
+
+
+ // "ㅁ" is bigger then "ኢ"
+ field.SetSize( 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.SetKeyboardFocusable(true);
+ KeyboardFocusManager::Get().SetCurrentFocusActor( field );
+
+ application.SendNotification();
+ application.Render();
+
+ previousHeight = field.GetHeightForWidth( fieldWidth );
+ DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
+
+ // Add another script characters ( glyph height is defferent )
+ application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+
+ application.SendNotification();
+ application.Render();
+
+ currentHeight = field.GetHeightForWidth( fieldWidth );
+ DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextFieldExtremlyLargePointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
+
+ 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 );
+ Stage::GetCurrent().Add( field );
+
+ try
+ {
+ field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
+ application.SendNotification();
+ DALI_TEST_CHECK( field );
+ }
+ catch (...)
+ {
+ tet_result(TET_FAIL);
+ }
+ END_TEST;
+}
+
+int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ Stage::GetCurrent().Add( field );
+
+ Property::Map fontStyleMapGet;
+
+ fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
+
+ Property::Value* weightValue = NULL;
+ Property::Value* widthValue = NULL;
+ Property::Value* slantValue = NULL;
+ weightValue = fontStyleMapGet.Find( "weight" );
+ widthValue = fontStyleMapGet.Find( "width" );
+ slantValue = fontStyleMapGet.Find( "slant" );
+ DALI_TEST_CHECK( !weightValue );
+ DALI_TEST_CHECK( !widthValue );
+ DALI_TEST_CHECK( !slantValue );
+
+ END_TEST;
+}