+int UtcDaliTextFieldSelectWholeText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectWholeText ");
+
+ 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();
+
+ DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
+
+ DevelTextField::SelectWholeText( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ // Nothing should have been selected. The number of children is still 1
+ DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
+
+ textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+ application.SendNotification();
+ application.Render();
+
+ DevelTextField::SelectWholeText( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ // Should be 2 children, the stencil and the layer
+ DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
+
+ // The offscreen root actor should have two actors: the renderer and the highlight actor.
+ Actor stencil = textField.GetChildAt( 0u );
+
+ // The highlight actor is drawn first, so is the first actor in the list
+ Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
+ DALI_TEST_CHECK( highlight );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldSelectNone(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectWholeText ");
+
+ TextField textField = TextField::New();
+
+ 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();
+
+ // Nothing is selected
+ std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+ DevelTextField::SelectWholeText( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ // whole text is selected
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
+
+ DevelTextField::SelectNone( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ // Nothing is selected
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldSelectRange(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectRange ");
+
+ 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();
+
+ textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+ application.SendNotification();
+ application.Render();
+
+ textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
+ textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
+
+ // Hello is selected
+ std::string 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 );
+
+ textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
+ textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
+
+ // world is selected
+ 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 UtcDaliTextFieldEnableEditing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldEnableEditing ");
+
+ 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();
+
+ textField.SetKeyInputFocus();
+ textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
+ 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_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
+
+
+ textField.SetKeyInputFocus();
+ textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
+ 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_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextFieldFontSizeScale(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
+
+ TextField textField = TextField::New();
+ textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
+ textField.SetProperty( TextField::Property::TEXT, "Test" );
+ Vector3 nonScaledSize = textField.GetNaturalSize();
+
+ TextField textFieldScaled = TextField::New();
+ textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
+ textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
+ textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
+ Vector3 scaledSize = textFieldScaled.GetNaturalSize();
+
+ DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
+
+ textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
+ textField.SetProperty( TextField::Property::TEXT, "Test" );
+ nonScaledSize = textField.GetNaturalSize();
+
+ textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
+ textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
+ textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
+ scaledSize = textFieldScaled.GetNaturalSize();
+
+ DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldPrimaryCursorPosition(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
+
+ TextField textField = TextField::New();
+
+ application.GetScene().Add( textField );
+
+ textField.SetProperty( TextField::Property::TEXT, "ABCEF");
+ 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 );
+
+ textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+ 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 ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
+
+ END_TEST;
+}