#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/pan-gesture-event.h>
#include <dali/integration-api/events/long-press-gesture-event.h>
+#include <dali/devel-api/adaptor-framework/key-devel.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.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_ENABLE_SELECTION = "enableSelection";
const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
+const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
const unsigned int DEFAULT_FONT_SIZE = 1152u;
const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
+const int KEY_RETURN_CODE = 36;
const int KEY_A_CODE = 38;
const int KEY_D_CODE = 40;
{
const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
- if( valueGet.first.type == Property::Key::STRING )
+ Property::Value* valueSet = NULL;
+ if ( valueGet.first.type == Property::Key::INDEX )
{
- Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
- if( NULL != valueSet )
+ valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+ }
+ else
+ {
+ // Get Key is a string so searching Set Map for a string key
+ valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+ }
+
+ if( NULL != valueSet )
+ {
+ if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
{
- 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;
- }
+ tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+ return false;
}
- else
+ else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
{
- tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+ tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
+ return false;
+ }
+ else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
+ {
+ tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+ return false;
+ }
+ else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
+ {
+ tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
+ return false;
+ }
+ else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
+ {
+ Vector2 vector2Get = valueGet.second.Get<Vector2>();
+ Vector2 vector2Set = valueSet->Get<Vector2>();
+ tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
+ return false;
+ }
+ else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
+ {
+ Vector4 vector4Get = valueGet.second.Get<Vector4>();
+ Vector4 vector4Set = valueSet->Get<Vector4>();
+ tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
return false;
}
}
else
{
- Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
- if( NULL != valueSet )
+ if ( valueGet.first.type == Property::Key::INDEX )
{
- 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;
- }
+ tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
}
else
{
- tet_printf( " The Int key %d doesn't exist.", valueGet.first.indexKey );
- return false;
+ tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
}
+ return false;
}
}
}
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
END_TEST;
}
Property::Map shadowMapSet;
Property::Map shadowMapGet;
- shadowMapSet.Insert( "color", "green" );
- shadowMapSet.Insert( "offset", "2 2" );
+ shadowMapSet.Insert( "color", Color::GREEN );
+ shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
+ shadowMapSet.Insert( "blurRadius", 3.0f );
field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
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 );
field.SetProperty( TextField::Property::ELLIPSIS, true );
DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
+ field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
DALI_TEST_CHECK( !maxLengthReachedSignal );
+ application.ProcessEvent( GenerateKey( "Return", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
+ DALI_TEST_CHECK( !maxLengthReachedSignal );
+
END_TEST;
}
application.SendNotification();
application.Render();
+ // Pressing delete key should be fine even if there is no text in TextField.
+ application.ProcessEvent( GenerateKey( "Delete", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::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, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
END_TEST;
}
+
+int UtcDaliTextFieldSetPaddingProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ field.SetSize( 300.f, 50.f );
+ field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( field );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 originalSize = field.GetNaturalSize();
+
+ field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
+
+ Vector3 paddingAddedSize = field.GetNaturalSize();
+
+ DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldEnableShiftSelectionProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ field.SetSize( 300.f, 50.f );
+ field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( field );
+
+ application.SendNotification();
+ application.Render();
+
+ // The default value of ENABLE_SHIFT_SELECTION is 'true'.
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
+
+ // Check the enable shift selection property
+ field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}