#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
#include <dali-toolkit/devel-api/text/rendering-backend.h>
#include "toolkit-clipboard.h"
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
using namespace Dali;
using namespace Toolkit;
const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
+const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
+const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
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.
const int KEY_RETURN_CODE = 36;
const int KEY_A_CODE = 38;
const int KEY_D_CODE = 40;
+const int KEY_SHIFT_MODIFIER = 257;
const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
+static bool gSelectionChangedCallbackCalled;
+static uint32_t oldSelectionStart;
+static uint32_t oldSelectionEnd;
+static bool gAnchorClickedCallBackCalled;
+static bool gAnchorClickedCallBackNotCalled;
static bool gTextChangedCallBackCalled;
static bool gMaxCharactersCallBackCalled;
+static bool gInputFilteredAcceptedCallbackCalled;
+static bool gInputFilteredRejectedCallbackCalled;
static bool gInputStyleChangedCallbackCalled;
+static bool gCursorPositionChangedCallbackCalled;
+static uint32_t oldCursorPos;
static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
bool* mCallbackFlag;
};
+static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
+{
+ tet_infoline(" TestSelectionChangedCallback");
+
+ gSelectionChangedCallbackCalled = true;
+ oldSelectionStart = oldStart;
+ oldSelectionEnd = oldEnd;
+}
+
+static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
+{
+ tet_infoline(" TestAnchorClickedCallback");
+
+ gAnchorClickedCallBackNotCalled = false;
+
+ if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
+ {
+ gAnchorClickedCallBackCalled = true;
+ }
+}
+
+static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
+{
+ tet_infoline(" TestCursorPositionChangedCallback");
+
+ gCursorPositionChangedCallbackCalled = true;
+ oldCursorPos = oldPos;
+}
+
static void TestTextChangedCallback( TextField control )
{
tet_infoline(" TestTextChangedCallback");
gMaxCharactersCallBackCalled = true;
}
+static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
+{
+ tet_infoline(" TestInputFilteredCallback");
+
+ if(type == Toolkit::InputFilter::Property::ACCEPTED)
+ {
+ gInputFilteredAcceptedCallbackCalled = true;
+ }
+ else if(type == Toolkit::InputFilter::Property::REJECTED)
+ {
+ gInputFilteredRejectedCallbackCalled = true;
+ }
+}
+
static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
{
tet_infoline(" TestInputStyleChangedCallback");
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 );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
END_TEST;
}
field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
+ //Check handle color
+ field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
+ DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
+
+ // Check the input filter property
+ Property::Map inputFilterMapSet;
+ Property::Map inputFilterMapGet;
+ inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
+ inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
+
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
+
+ inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
+ DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
+
+ // Clear
+ inputFilterMapSet.Clear();
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
+
application.SendNotification();
application.Render();
END_TEST;
}
+// Positive test for the anchorClicked signal.
+int utcDaliTextFieldAnchorClicked01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldAnchorClicked01");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ // connect to the anchor clicked signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
+ bool anchorClickedSignal = false;
+ field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
+
+ gAnchorClickedCallBackCalled = false;
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ application.SendNotification();
+ application.Render();
+ field.SetKeyInputFocus();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 5.0f, 25.0f);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+ DALI_TEST_CHECK(anchorClickedSignal);
+
+ gAnchorClickedCallBackNotCalled = true;
+ // Tap the outside of anchor, callback should not be called.
+ TestGenerateTap(application, 150.f, 100.f);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
+
+ END_TEST;
+}
+
+// Positive test for the anchorClicked signal.
+int utcDaliTextFieldAnchorClicked02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldAnchorClicked02");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ // connect to the anchor clicked signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
+ bool anchorClickedSignal = false;
+ field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
+
+ gAnchorClickedCallBackCalled = false;
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ application.SendNotification();
+ application.Render();
+ field.SetKeyInputFocus();
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 100);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+ DALI_TEST_CHECK(anchorClickedSignal);
+
+
+ // For coverage InsertTextAnchor, RemoveTextAnchor
+ // first index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 700);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // last index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 1300);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // mid index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 1900);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // first index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 2500);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // last index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 3100);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // middle index
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 3700);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 0 ~ 1 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 4300);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 1 ~ 3 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 4900);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 3 ~ 4 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 5500);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // Remove front of anchor
+ field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove whole text
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ DevelTextField::SelectWholeText(field);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove all with backspace
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove all with delete
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
// Positive test for the textChanged signal.
int utcDaliTextFieldTextChangedP(void)
{
gTextChangedCallBackCalled = false;
field.SetProperty( TextField::Property::TEXT, "ABC" );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
DALI_TEST_CHECK( textChangedSignal );
+ application.SendNotification();
field.SetKeyInputFocus();
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
// Remove all text
field.SetProperty( TextField::Property::TEXT, "" );
- application.SendNotification();
- application.Render();
// Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
// Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
END_TEST;
END_TEST;
}
-int utcDaliTextFieldInputStyleChanged01(void)
+// Positive test for Input Filtered signal.
+int utcDaliTextFieldInputFilteredP(void)
{
- // 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.
- // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
ToolkitTestApplication application;
- tet_infoline(" utcDaliTextFieldInputStyleChanged01");
+ tet_infoline(" utcDaliTextFieldInputFilteredP");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
- // Load some fonts.
+ application.GetScene().Add(field);
- char* pathNamePtr = get_current_dir_name();
- const std::string pathName( pathNamePtr );
- free( pathNamePtr );
+ Property::Map inputFilter;
- TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
- fontClient.SetDpi( 93u, 93u );
+ // Only digit is accepted.
+ inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
+ // Set input filter to TextField.
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
- TextField field = TextField::New();
- DALI_TEST_CHECK( field );
+ field.SetKeyInputFocus();
+ // connect to the input filtered signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
+ bool inputFilteredSignal = false;
+ field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
- 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 );
+ gInputFilteredAcceptedCallbackCalled = false;
- field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
- field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
+ application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
- // connect to the text changed signal.
- ConnectionTracker* testTracker = new ConnectionTracker();
- field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
- bool inputStyleChangedSignal = false;
- field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
+ DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
+ DALI_TEST_CHECK(inputFilteredSignal);
- application.GetScene().Add( field );
+ // Word is rejected.
+ inputFilter[InputFilter::Property::ACCEPTED] = "";
+ inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
- // Render and notify
- application.SendNotification();
- application.Render();
+ // Set input filter to TextField.
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
- // Executes the idle callbacks added by the text control on the change of input style.
- application.RunIdles();
+ field.SetKeyInputFocus();
- gInputStyleChangedCallbackCalled = false;
- gInputStyleMask = TextField::InputStyle::NONE;
- inputStyleChangedSignal = false;
+ inputFilteredSignal = false;
+ gInputFilteredRejectedCallbackCalled = false;
- // Create a tap event to touch the text field.
- TestGenerateTap( application, 18.0f, 25.0f );
+ application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
- // Render and notify
- application.SendNotification();
+ DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
+ DALI_TEST_CHECK(inputFilteredSignal);
+
+ END_TEST;
+}
+
+// Negative test for Input Filtered signal.
+int utcDaliTextFieldInputFilteredN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldInputFilteredP");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ Property::Map inputFilter;
+
+ // Only word is accepted.
+ inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
+
+ // Set input filter to TextField.
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
+
+ field.SetKeyInputFocus();
+
+ // connect to the input filtered signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
+ bool inputFilteredSignal = false;
+ field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
+
+ gInputFilteredAcceptedCallbackCalled = false;
+
+ // Key a, d should not be filtered.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Backspace, Delete should not be filtered.
+ application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
+ DALI_TEST_CHECK(!inputFilteredSignal);
+
+ // Digit is rejected.
+ inputFilter[InputFilter::Property::ACCEPTED] = "";
+ inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
+
+ field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
+
+ field.SetKeyInputFocus();
+
+ inputFilteredSignal = false;
+ gInputFilteredRejectedCallbackCalled = false;
+
+ // Key a, d should not be filtered.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Backspace, Delete should not be filtered.
+ application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
+ DALI_TEST_CHECK(!inputFilteredSignal);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldInputStyleChanged01(void)
+{
+ // 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.
+ // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldInputStyleChanged01");
+
+ // Load some fonts.
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName( pathNamePtr );
+ free( pathNamePtr );
+
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi( 93u, 93u );
+
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+
+ 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, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
+
+ // connect to the text changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
+ bool inputStyleChangedSignal = false;
+ field.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
+
+ application.GetScene().Add( field );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap( application, 18.0f, 25.0f );
+
+ // Render and notify
+ application.SendNotification();
application.Render();
// Executes the idle callbacks added by the text control on the change of input style.
DALI_TEST_CHECK( !inputStyleChangedSignal );
// Create a tap event to touch the text field.
- TestGenerateTap( application, 63.0f, 25.0f, 300 );
+ TestGenerateTap( application, 63.0f, 25.0f, 700 );
// Render and notify
application.SendNotification();
END_TEST;
}
+int UtcDaliTextFieldPlaceholderCoverage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ TextField fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderFontFamily() coverage.
+ Property::Map fontFamilyMap;
+ fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontSize coverage.
+ Property::Map fontSizeMap;
+ fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontWeight coverage.
+ Property::Map fontStyleWeightMap;
+ Property::Map fontStyleWeightPropertyMap;
+ fontStyleWeightPropertyMap.Insert("weight", "bold");
+ fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontWidth coverage.
+ Property::Map fontStyleWidthMap;
+ Property::Map fontStyleWidthPropertyMap;
+ fontStyleWidthPropertyMap.Insert("width", "expanded");
+ fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontSlant coverage.
+ Property::Map fontStyleSlantMap;
+ Property::Map fontStyleSlantPropertyMap;
+ fontStyleSlantPropertyMap.Insert("slant", "italic");
+ fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
+
+ END_TEST;
+}
+
int UtcDaliTextFieldSetPaddingProperty(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render();
- // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
- DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
+ // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
// Check the match system language direction property
- field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
- DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
+ field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
application.SendNotification();
application.Render();
END_TEST;
}
+int UtcDaliTextFieldSelectText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectText ");
+
+ TextField textField = TextField::New();
+
+ application.GetScene().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();
+
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ // Nothing is selected
+ std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+ textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+ application.SendNotification();
+ application.Render();
+
+ // Hello is selected
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+ // world is selected
+ DevelTextField::SelectText( textField, 6, 11 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliTextFieldSelectNone(void)
{
ToolkitTestApplication application;
textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
application.SendNotification();
application.Render();
+ textField.SetKeyInputFocus();
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
END_TEST;
}
+
+// test max length when set after setting long text
+int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+ application.GetScene().Add( field );
+
+ field.SetProperty(TextField::Property::TEXT, "123456789");
+
+ const int maxNumberOfCharacters = 3;
+ field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
+
+ field.SetKeyInputFocus();
+
+ // connect to the text max lengh reached signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ bool maxLengthReachedSignal = false;
+ field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
+
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ DALI_TEST_CHECK( maxLengthReachedSignal );
+
+ DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ // Create a text field
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
+ //Specify font-family
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ application.GetScene().Add( textField );
+
+ application.SendNotification();
+ application.Render();
+ //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ Vector3 naturalSize = textField.GetNaturalSize();
+
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ // Create a text editor
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ const int numberOfCases = 6;
+ int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
+
+ for (int index=0; index < numberOfCases; index++)
+ {
+ tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
+ textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
+ application.GetScene().Add( textField );
+ application.SendNotification();
+ application.Render();
+ naturalSize = textField.GetNaturalSize();
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
+ TextField textField = TextField::New();
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
+
+ tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
+ textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
+ DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldCopyText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldCopyText ");
+
+ TextField textField = TextField::New();
+
+ std::string selectedText = "";
+ std::string copiedText = "";
+
+ application.GetScene().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();
+
+ // Hello is selected
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+ // Hello is copied
+ copiedText = DevelTextField::CopyText( textField );
+ DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
+
+ // world is selected
+ DevelTextField::SelectText( textField, 6, 11 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+ // world is copied
+ copiedText = DevelTextField::CopyText( textField );
+ DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
+
+ // "lo wo" is selected
+ DevelTextField::SelectText( textField, 3, 8 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
+
+ // "lo wo" is copied
+ copiedText = DevelTextField::CopyText( textField );
+ DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldCutText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldCutText ");
+
+ TextField textField = TextField::New();
+
+ std::string selectedText = "";
+
+ application.GetScene().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();
+
+ // Hello is selected
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+ // Hello is cut
+ DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
+
+ // " w" is selected
+ DevelTextField::SelectText( textField, 0, 2 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+ // " w" is cut
+ DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
+
+ // Test Cut from the middle
+
+ // "rl" is selected
+ DevelTextField::SelectText( textField, 1, 3 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
+
+ // "rl" is cut
+ DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
+
+ // Test Cut from the end
+
+ // "d" is selected
+ DevelTextField::SelectText( textField, 1, 2 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+ // "d" is cut
+ DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldPasteText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldPasteText ");
+
+ TextField textField = TextField::New();
+
+ application.GetScene().Add( textField );
+
+ std::string cutText = "";
+ std::string copiedText = "";
+
+ 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();
+
+ // Tap on the text editor
+ TestGenerateTap( application, 3.0f, 25.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Select some text in the right of the current cursor position
+ DevelTextField::SelectText( textField, 0, 3 );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Cut the selected text
+ cutText = DevelTextField::CutText(textField);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
+
+ DevelTextField::SelectText( textField, 0, 3 );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Copy the selected text
+ copiedText = DevelTextField::CopyText(textField);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
+ DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
+
+ // Move the cursor to the end of the line
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Paste the selected text at the current cursor position
+ DevelTextField::PasteText(textField);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
+
+ END_TEST;
+}
+int utcDaliTextFieldCursorPositionChangedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+ application.GetScene().Add( field );
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
+ bool cursorPositionChangedSignal = false;
+ field.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
+
+ field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
+ field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
+ field.SetProperty( Actor::Property::SIZE, Vector2( 100.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 );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetKeyInputFocus();
+
+ // Tap on the text field
+ TestGenerateTap( application, 3.0f, 25.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ // Move to left.
+ 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();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ // Insert D
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ //delete one character
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ field.SetProperty( TextField::Property::TEXT, "Hello" );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
+
+ gCursorPositionChangedCallbackCalled = false;
+
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldSelectionChangedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+ application.GetScene().Add( field );
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
+ bool selectionChangedSignal = false;
+ field.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
+
+ field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
+ field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
+ field.SetProperty( Actor::Property::SIZE, Vector2( 100.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 );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text field
+ TestGenerateTap( application, 3.0f, 25.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Select some text in the right of the current cursor position
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+ field.SetKeyInputFocus();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DevelTextField::SelectText( field ,0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ // select all text
+ DevelTextField::SelectWholeText(field);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
+
+ gSelectionChangedCallbackCalled = false;
+
+ // select none
+ DevelTextField::SelectNone(field);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
+ DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
+
+ END_TEST;
+}
\ No newline at end of file