Add a TextEditor property to limit input to maximum characters
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
old mode 100755 (executable)
new mode 100644 (file)
index f56c3c1..b3decd1
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/rendering/renderer.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/adaptor-framework/key-devel.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+#include <dali-toolkit/devel-api/text/rendering-backend.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -99,6 +101,7 @@ const char* const PROPERTY_NAME_PLACEHOLDER                          = "placehol
 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
+const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
 
 
 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
@@ -125,6 +128,7 @@ const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
 
 static bool gTextChangedCallBackCalled;
 static bool gInputStyleChangedCallbackCalled;
+static bool gMaxCharactersCallBackCalled;
 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
 
 struct CallbackFunctor
@@ -156,6 +160,13 @@ static void TestInputStyleChangedCallback( TextEditor control, TextEditor::Input
   gInputStyleMask = mask;
 }
 
+static void TestMaxLengthReachedCallback( TextEditor control )
+{
+  tet_infoline(" TestMaxLengthReachedCallback");
+
+  gMaxCharactersCallBackCalled = true;
+}
+
 // Generate a KeyEvent to send to Core.
 Integration::KeyEvent GenerateKey( const std::string& keyName,
                                    const std::string& logicalKey,
@@ -389,7 +400,7 @@ int UtcDaliTextEditorGetPropertyP(void)
   DALI_TEST_CHECK( editor );
 
   // Check Property Indices are correct
-  DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
+  DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
@@ -444,6 +455,7 @@ int UtcDaliTextEditorGetPropertyP(void)
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
+  DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
 
   END_TEST;
 }
@@ -473,13 +485,13 @@ int UtcDaliTextEditorSetPropertyP(void)
   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   // Note - we can't check the defaults since the stylesheets are platform-specific
 
   // Check the render backend property.
-  editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
-  DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
+  editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
+  DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
 
   // Check text property.
   editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
@@ -874,12 +886,12 @@ int utcDaliTextEditorAtlasRenderP(void)
 
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   try
   {
     // Render some text with the shared atlas backend
-    editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
+    editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
     application.SendNotification();
     application.Render();
   }
@@ -898,7 +910,7 @@ int utcDaliTextEditorTextChangedP(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   // connect to the text changed signal.
   ConnectionTracker* testTracker = new ConnectionTracker();
@@ -924,15 +936,13 @@ int utcDaliTextEditorTextChangedP(void)
 
 int utcDaliTextEditorInputStyleChanged01(void)
 {
-  ToolkitTestApplication application;
-  tet_infoline(" utcDaliTextEditorInputStyleChanged01");
-
   // The text-editor 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-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
-  // This creates an implementation of the adaptor stub and a queue of idle callbacks.
-  application.CreateAdaptor();
+  // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorInputStyleChanged01");
 
   // Load some fonts.
 
@@ -950,9 +960,9 @@ int utcDaliTextEditorInputStyleChanged01(void)
   DALI_TEST_CHECK( editor );
 
 
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
@@ -963,7 +973,7 @@ int utcDaliTextEditorInputStyleChanged01(void)
   bool inputStyleChangedSignal = false;
   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   // Render and notify
   application.SendNotification();
@@ -1140,15 +1150,13 @@ int utcDaliTextEditorInputStyleChanged01(void)
 
 int utcDaliTextEditorInputStyleChanged02(void)
 {
-  ToolkitTestApplication application;
-  tet_infoline(" utcDaliTextEditorInputStyleChanged02");
-
   // The text-editor 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-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
-  // This creates an implementation of the adaptor stub and a queue of idle callbacks.
-  application.CreateAdaptor();
+  // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorInputStyleChanged02");
 
   // Load some fonts.
 
@@ -1166,9 +1174,9 @@ int utcDaliTextEditorInputStyleChanged02(void)
   DALI_TEST_CHECK( editor );
 
 
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>" );
@@ -1179,7 +1187,7 @@ int utcDaliTextEditorInputStyleChanged02(void)
   bool inputStyleChangedSignal = false;
   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   // Render and notify
   application.SendNotification();
@@ -1401,11 +1409,11 @@ int utcDaliTextEditorEvent01(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -1443,12 +1451,12 @@ int utcDaliTextEditorEvent01(void)
   // Create a second text editor and send key events to it.
   TextEditor editor2 = TextEditor::New();
 
-  editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  editor2.SetSize( 100.f, 100.f );
-  editor2.SetPosition( 100.f, 100.f );
+  editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+  editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
 
-  Stage::GetCurrent().Add( editor2 );
+  application.GetScene().Add( editor2 );
 
   // Render and notify
   application.SendNotification();
@@ -1486,11 +1494,11 @@ int utcDaliTextEditorEvent02(void)
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -1512,7 +1520,7 @@ int utcDaliTextEditorEvent02(void)
   application.Render();
 
   Actor layer = editor.GetChildAt( 1u );
-  DALI_TEST_CHECK( layer.IsLayer() );
+  DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
 
   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
@@ -1541,7 +1549,7 @@ int utcDaliTextEditorEvent02(void)
   }
 
   // Move the cursor and check the position changes.
-  Vector3 position1 = cursor.GetCurrentPosition();
+  Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
@@ -1550,7 +1558,7 @@ int utcDaliTextEditorEvent02(void)
   application.SendNotification();
   application.Render();
 
-  Vector3 position2 = cursor.GetCurrentPosition();
+  Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   DALI_TEST_CHECK( position2.x < position1.x );
 
@@ -1561,7 +1569,7 @@ int utcDaliTextEditorEvent02(void)
   application.SendNotification();
   application.Render();
 
-  Vector3 position3 = cursor.GetCurrentPosition();
+  Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
 
@@ -1575,7 +1583,7 @@ int utcDaliTextEditorEvent02(void)
   application.Render();
 
   // Cursor position should be the same than position1.
-  Vector3 position4 = cursor.GetCurrentPosition();
+  Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
 
@@ -1586,7 +1594,7 @@ int utcDaliTextEditorEvent02(void)
   application.SendNotification();
   application.Render();
 
-  Vector3 position5 = cursor.GetCurrentPosition();
+  Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   DALI_TEST_CHECK( position5.x > position4.x );
 
@@ -1600,7 +1608,7 @@ int utcDaliTextEditorEvent02(void)
   application.Render();
 
   // Cursor position should be the same than position2.
-  Vector3 position6 = cursor.GetCurrentPosition();
+  Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
 
   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
 
@@ -1620,13 +1628,13 @@ int utcDaliTextEditorEvent03(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 30.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -1713,13 +1721,13 @@ int utcDaliTextEditorEvent04(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 100.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -1802,13 +1810,13 @@ int utcDaliTextEditorEvent05(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 50.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
   editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
@@ -1884,13 +1892,13 @@ int utcDaliTextEditorEvent06(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 100.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -1974,13 +1982,13 @@ int utcDaliTextEditorEvent07(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 100.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -2118,13 +2126,13 @@ int utcDaliTextEditorEvent08(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 100.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -2312,7 +2320,7 @@ int utcDaliTextEditorHandles(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
@@ -2329,9 +2337,9 @@ int utcDaliTextEditorHandles(void)
   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
 
-  editor.SetSize( 30.f, 500.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   // Avoid a crash when core load gl resources.
   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
@@ -2359,7 +2367,7 @@ int utcDaliTextEditorHandles(void)
 
   // Get the handle's actor.
   Actor handle = activeLayer.GetChildAt( 1u );
-  handle.SetSize( 100.f, 100.f );
+  handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
 
   // Render and notify
   application.SendNotification();
@@ -2431,7 +2439,7 @@ int utcDaliTextEditorUnderPropertyStringP(void)
 
   std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
@@ -2475,7 +2483,7 @@ int utcDaliTextEditorShadowPropertyStringP(void)
 
   std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
 
@@ -2497,7 +2505,7 @@ int utcDaliTextEditorFontStylePropertyStringP(void)
 
   std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
 
@@ -2523,13 +2531,13 @@ int utcDaliTextEditorGetPropertyLinecountP(void)
   editor.SetProperty( TextEditor::Property::TEXT,
                        "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
-  editor.SetSize( 100.0f, 100.0f );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
   DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
 
-  editor.SetSize( 50.0f, 100.0f );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
   lineCount =  editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
   DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
 
@@ -2545,14 +2553,14 @@ int utcDaliTextEditorScrollStateChangedSignalTest(void)
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
-  editor.SetSize( 50.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
   editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
-  editor.SetKeyboardFocusable(true);
+  editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
 
   bool startedCalled = false;
   bool finishedCalled = false;
@@ -2585,10 +2593,10 @@ int UtcDaliToolkitTextEditorTextWrapMode(void)
   int lineCount =0 ;
 
   TextEditor editor = TextEditor::New();
-  editor.SetSize( 150.0f, 300.f );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
   editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
 
-  Stage::GetCurrent().Add( editor );
+  application.GetScene().Add( editor );
 
   editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
   DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
@@ -2636,10 +2644,10 @@ int UtcDaliTextEditorSetPaddingProperty(void)
 
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  Stage::GetCurrent().Add( editor );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  application.GetScene().Add( editor );
 
   application.SendNotification();
   application.Render();
@@ -2669,10 +2677,10 @@ int UtcDaliTextEditorEnableShiftSelectionProperty(void)
 
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  Stage::GetCurrent().Add( editor );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  application.GetScene().Add( editor );
 
   application.SendNotification();
   application.Render();
@@ -2697,10 +2705,10 @@ int UtcDaliTextEditorEnableGrabHandleProperty(void)
 
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  Stage::GetCurrent().Add( editor );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  application.GetScene().Add( editor );
 
   application.SendNotification();
   application.Render();
@@ -2725,10 +2733,10 @@ int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
 
   TextEditor editor = TextEditor::New();
   DALI_TEST_CHECK( editor );
-  editor.SetSize( 300.f, 50.f );
-  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  Stage::GetCurrent().Add( editor );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  application.GetScene().Add( editor );
 
   application.SendNotification();
   application.Render();
@@ -2756,3 +2764,36 @@ int UtcDaliTextEditorGetInputMethodContext(void)
 
   END_TEST;
 }
+
+int utcDaliTextEditorMaxCharactersReached(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("utcDaliTextEditorMaxCharactersReached");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  const int maxNumberOfCharacters = 1;
+  editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
+  DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
+
+  editor.SetKeyInputFocus();
+
+  // connect to the text changed signal.
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
+  bool maxLengthReachedSignal = false;
+  editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
+
+  gMaxCharactersCallBackCalled = false;
+
+  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( gMaxCharactersCallBackCalled );
+  DALI_TEST_CHECK( maxLengthReachedSignal );
+
+  END_TEST;
+}