+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ field.SetProperty(TextField::Property::INPUT_COLOR, Color::YELLOW);
+
+ Property::Map fontStyleMapSet;
+ fontStyleMapSet.Insert("weight", "thin");
+ fontStyleMapSet.Insert("width", "condensed");
+ fontStyleMapSet.Insert("slant", "italic");
+
+ field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
+ field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 20.f);
+
+ field.SetProperty(TextField::Property::INPUT_UNDERLINE, "underline");
+ field.SetProperty(TextField::Property::INPUT_SHADOW, "shadow");
+ field.SetProperty(TextField::Property::INPUT_EMBOSS, "emboss");
+ field.SetProperty(TextField::Property::INPUT_OUTLINE, "outline");
+ field.SetProperty(DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough");
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 63.0f, 25.0f, 700);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask),
+ static_cast<unsigned int>(TextField::InputStyle::COLOR |
+ TextField::InputStyle::POINT_SIZE |
+ TextField::InputStyle::FONT_STYLE |
+ TextField::InputStyle::UNDERLINE |
+ TextField::InputStyle::SHADOW |
+ TextField::InputStyle::EMBOSS |
+ TextField::InputStyle::OUTLINE),
+ TEST_LOCATION);
+
+ const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
+ DALI_TEST_EQUALS(color, Color::BLACK, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent01");
+
+ // Creates a tap event. After creating a tap event the text field should
+ // have the focus and add text with key events should be possible.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(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);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Add a key event but as the text field has not the focus it should do nothing.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Pressing delete key should be fine even if there is no text in TextField.
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Now the text field has the focus, so it can handle the key events.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
+
+ // Create a second text field and send key events to it.
+ TextField field2 = TextField::New();
+
+ field2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ field2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
+ field2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f));
+
+ application.GetScene().Add(field2);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event on the second text field.
+ TestGenerateTap(application, 150.0f, 125.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // The second text field has the focus. It should handle the key events.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check the text has been added to the second text field.
+ DALI_TEST_EQUALS(field2.GetProperty<std::string>(TextField::Property::TEXT), std::string("aa"), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent02");
+
+ // Checks if the right number of actors are created.
+
+ TextField field = TextField::New();
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ DALI_TEST_CHECK(field);
+ LoadMarkerImages(application, field);
+
+ application.GetScene().Add(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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check there are the expected number of children ( stencil ).
+ DALI_TEST_EQUALS(field.GetChildCount(), 1u, TEST_LOCATION);
+
+ Actor stencil = field.GetChildAt(0u);
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f, 300);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor layer = field.GetChildAt(2u);
+ DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
+
+ // Now the text field has the focus, so it can handle the key events.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Checks the cursor and the renderer have been created.
+ DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
+
+ Control cursor = Control::DownCast(layer.GetChildAt(0u));
+ DALI_TEST_CHECK(cursor);
+
+ // The offscreen root actor has a container with all the actors which contain the text renderers.
+ Actor container = stencil.GetChildAt(0u);
+ for(unsigned int index = 0; index < container.GetChildCount(); ++index)
+ {
+ Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+ }
+
+ // Move the cursor and check the position changes.
+ 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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector3 position2 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+ DALI_TEST_CHECK(position2.x < position1.x);
+
+ 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();
+
+ Vector3 position3 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+ DALI_TEST_EQUALS(position1, position3, TEST_LOCATION); // Should be in the same position1.
+
+ // Move the cursor to the first 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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector3 position4 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+
+ // Send some taps and check the cursor positions.
+
+ // Try to tap at the beginning.
+ TestGenerateTap(application, 1.0f, 25.0f, 900);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Cursor position should be the same than position1.
+ Vector3 position5 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+
+ DALI_TEST_EQUALS(position4, position5, TEST_LOCATION); // Should be in the same position2.
+
+ // Tap away from the start position.
+ TestGenerateTap(application, 16.0f, 25.0f, 1500);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector3 position6 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+
+ DALI_TEST_CHECK(position6.x > position5.x);
+
+ // Remove all the text.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ field.SetProperty(TextField::Property::TEXT, "");
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Cursor position should be the same than position2.
+ Vector3 position7 = cursor.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
+
+ DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
+
+ // Should not be a renderer, there is only a clipped cursor.
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION);
+
+ // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL);
+
+ application.SendNotification();
+ application.Render();
+
+ // There are renderer and decorator layer
+ DALI_TEST_EQUALS(field.GetChildCount(), 2u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent03");
+
+ // Checks if the highlight actor is created.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ field.SetProperty(Actor::Property::SIZE, Vector2(30.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);
+ LoadMarkerImages(application, field);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word.
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // The offscreen root actor should have two actors: the renderer and the highlight actor.
+ Actor stencil = field.GetChildAt(0u);
+
+ // The highlight actor is drawn first, so is the first actor in the list
+ Renderer highlight = stencil.GetChildAt(0u).GetRendererAt(0u);
+ DALI_TEST_CHECK(highlight);
+
+ // The offscreen root actor has a container with all the actors which contain the text renderers.
+ Actor container = stencil.GetChildAt(1u);
+ for(unsigned int index = 0; index < container.GetChildCount(); ++index)
+ {
+ Renderer renderer = container.GetChildAt(index).GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+ }
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent04");
+
+ // Checks if the highlight actor is created.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap grab handle
+ TestGenerateTap(application, 0.0f, 40.0f);
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent05(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent05");
+
+ // Checks dragging of cursor/grab handle
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor stencil = field.GetChildAt(1u);
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent06(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent06");
+
+ // Checks Longpress when in edit mode
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent07(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent07");
+
+ // Checks Longpress to start edit mode
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+ Property::Map propertyMap;
+ propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
+ field.SetProperty(TextField::Property::INPUT_METHOD_SETTINGS, propertyMap);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent08(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent08");
+
+ Dali::Clipboard clipboard = Clipboard::Get();
+ clipboard.SetItem("testTextFieldEvent");
+
+ // Checks Longpress when only place holder text
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f, 20);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Wait(application, 500);
+
+ TestEndLongPress(application, 1.0f, 25.0f, 520);
+
+ // Long Press
+ TestGenerateLongPress(application, 1.0f, 25.0f, 600);
+
+ // Render and notify
+ application.Render();
+
+ Wait(application, 500);
+
+ Integration::Scene stage = application.GetScene();
+ Layer layer = stage.GetRootLayer();
+ Actor actor = layer.FindChildByName("optionPaste");
+
+ if(actor)
+ {
+ Vector3 worldPosition = actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION);
+ Vector2 halfStageSize = stage.GetSize() / 2.0f;
+ Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
+
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint(GetPointDownInside(position));
+ application.ProcessEvent(event);
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint(GetPointUpInside(position));
+ application.ProcessEvent(event);
+ }
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextEditor::Property::TEXT), std::string("testTextFieldEvent"), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEvent09(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEvent09");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "Hello");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ field.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);
+
+ // 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, 150.0f, 25.0f);
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_NONE;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL;
+ map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_COUNT;
+ map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ for(unsigned int index = 0u; index < 5u; ++index)
+ {
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+ }
+
+ map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_COUNT;
+ map[HiddenInput::Property::SUBSTITUTE_COUNT] = 2;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ for(unsigned int index = 0u; index < 5u; ++index)
+ {
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+ }
+
+ map[HiddenInput::Property::MODE] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
+ map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 0;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ map[HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = 100;
+ field.SetProperty(TextField::Property::HIDDEN_INPUT_SETTINGS, map);
+ application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ Property::Map mapGet;
+ mapGet = field.GetProperty<Property::Map>(TextField::Property::HIDDEN_INPUT_SETTINGS);
+ DALI_TEST_EQUALS(map.Count(), mapGet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(map, mapGet), true, TEST_LOCATION);
+ END_TEST;
+}
+
+int utcDaliTextFieldStyleWhilstSelected(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
+
+ // Change font and styles whilst text is selected whilst word selected
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::TEXT, "This is a long text for the size of the text-field.");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ 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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ field.SetProperty(TextField::Property::INPUT_FONT_FAMILY, "Setting input font family");
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::INPUT_FONT_FAMILY), "Setting input font family", TEST_LOCATION);
+
+ Property::Map fontStyleMapSet;
+ Property::Map fontStyleMapGet;
+
+ fontStyleMapSet.Insert("weight", "bold");
+ fontStyleMapSet.Insert("slant", "italic");
+ field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
+
+ fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
+ DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+
+ fontStyleMapSet.Clear();
+ fontStyleMapSet.Insert("width", "expanded");
+ fontStyleMapSet.Insert("slant", "italic");
+ field.SetProperty(TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet);
+
+ fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::INPUT_FONT_STYLE);
+ DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+
+ field.SetProperty(TextField::Property::INPUT_POINT_SIZE, 12.f);
+ DALI_TEST_EQUALS(field.GetProperty<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ field.SetProperty(TextField::Property::TEXT_COLOR, Color::RED);
+ DALI_TEST_EQUALS(field.GetProperty<Vector4>(TextField::Property::TEXT_COLOR), Color::RED, TEST_LOCATION);
+
+ fontStyleMapSet.Clear();
+ fontStyleMapSet.Insert("weight", "bold");
+ fontStyleMapSet.Insert("slant", "italic");
+
+ field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
+
+ fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
+ DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+
+ fontStyleMapSet.Clear();
+ fontStyleMapSet.Insert("width", "expanded");
+
+ field.SetProperty(TextField::Property::FONT_STYLE, fontStyleMapSet);
+
+ fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
+ DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+
+ // Press Escape to increase coverage
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!field.HasKeyInputFocus());
+
+ END_TEST;
+}
+
+int utcDaliTextFieldEscKeyLoseFocus(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
+
+ // Creates a tap event. After creating a tap event the text field should
+ // have the focus and add text with key events should be possible.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Add a key event but as the text field has not the focus it should do nothing.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string(""), TEST_LOCATION);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Now the text field has the focus, so it can handle the key events.
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ 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_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
+
+ // No more text should be introduced
+ application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "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));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("ad"), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldSomeSpecialKeys(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
+
+ // Checks some special keys when the text is selected.
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+ LoadMarkerImages(application, field);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ const std::string longText("This is a long text for the size of the text-field.");
+
+ field.SetProperty(TextField::Property::TEXT, longText);
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ field.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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap first to get the focus.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word.
+ TestGenerateTap(application, 1.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // The text shouldn't be deleted.
+ DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), longText, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldSizeUpdate(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("utcDaliTextFieldSizeUpdate");
+
+ // Checks some special keys when the text is selected.
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+
+ float previousHeight = 0.0f;
+ float currentHeight = 0.0f;
+ const float fieldWidth = 1920.0f;
+
+ // "ㅁ" is bigger then "ኢ"
+ field.SetProperty(Actor::Property::SIZE, Vector2(fieldWidth, 10.0f));
+ field.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
+ field.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT);
+
+ field.SetProperty(TextField::Property::TEXT, "ኢ");
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ KeyboardFocusManager::Get().SetCurrentFocusActor(field);
+
+ application.SendNotification();
+ application.Render();
+
+ previousHeight = field.GetHeightForWidth(fieldWidth);
+ DALI_TEST_EQUALS(previousHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
+
+ // Add another script characters ( glyph height is defferent )
+ application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ application.SendNotification();
+ application.Render();
+
+ currentHeight = field.GetHeightForWidth(fieldWidth);
+ DALI_TEST_EQUALS(currentHeight, field.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
+ DALI_TEST_EQUALS((previousHeight < currentHeight), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int utcDaliTextFieldExtremlyLargePointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
+
+ TextField field = TextField::New();
+
+ field.SetProperty(TextField::Property::TEXT, "Text");
+ field.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);
+ application.GetScene().Add(field);
+
+ try
+ {
+ field.SetProperty(TextField::Property::POINT_SIZE, 160.0f);
+ application.SendNotification();
+ DALI_TEST_CHECK(field);
+ }
+ catch(...)
+ {
+ tet_result(TET_FAIL);
+ }
+ END_TEST;
+}
+
+int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+
+ Property::Map fontStyleMapGet;
+
+ fontStyleMapGet = field.GetProperty<Property::Map>(TextField::Property::FONT_STYLE);
+
+ Property::Value* weightValue = NULL;
+ Property::Value* widthValue = NULL;
+ Property::Value* slantValue = NULL;
+ weightValue = fontStyleMapGet.Find("weight");
+ widthValue = fontStyleMapGet.Find("width");
+ slantValue = fontStyleMapGet.Find("slant");
+ DALI_TEST_CHECK(!weightValue);
+ DALI_TEST_CHECK(!widthValue);
+ DALI_TEST_CHECK(!slantValue);
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldSettingPlaceholder(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldSettingPlaceholder");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ application.GetScene().Add(field);
+
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::COLOR] = Color::BLUE;
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::ELLIPSIS] = true;
+
+ placeholderFontstyleMap.Insert("weight", "bold");
+ placeholderPixelSizeMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
+ field.SetProperty(TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet);
+
+ placeholderPixelSizeMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
+ DALI_TEST_EQUALS(placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderPixelSizeMapGet, placeholderPixelSizeMapSet), true, TEST_LOCATION);
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet[Text::PlaceHolder::Property::TEXT] = "Setting Placeholder Text";
+ placeholderMapSet[Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
+ placeholderMapSet[Text::PlaceHolder::Property::COLOR] = Color::RED;
+ placeholderMapSet[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
+ placeholderMapSet[Text::PlaceHolder::Property::POINT_SIZE] = 12.0f;
+ placeholderMapSet[Text::PlaceHolder::Property::ELLIPSIS] = false;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert("weight", "bold");
+ placeholderFontstyleMap.Insert("width", "condensed");
+ placeholderFontstyleMap.Insert("slant", "italic");
+ placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
+ field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
+
+ placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
+ DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert("weight", "normal");
+ placeholderFontstyleMap.Insert("slant", "oblique");
+ placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
+ field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
+
+ placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
+ DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert("slant", "roman");
+ placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
+ field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
+
+ placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet[Text::PlaceHolder::Property::FONT_STYLE] = placeholderFontstyleMap;
+
+ field.SetProperty(TextField::Property::PLACEHOLDER, placeholderMapSet);
+ placeholderMapGet = field.GetProperty<Property::Map>(TextField::Property::PLACEHOLDER);
+ DALI_TEST_EQUALS(placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(placeholderMapGet, placeholderMapSet), true, TEST_LOCATION);
+
+ 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;
+ tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
+
+ 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);
+ application.GetScene().Add(field);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 originalSize = field.GetNaturalSize();
+
+ field.SetProperty(Toolkit::Control::Property::PADDING, Extents(10, 10, 10, 10));
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(field.GetProperty<Extents>(Toolkit::Control::Property::PADDING), Extents(10, 10, 10, 10), TEST_LOCATION);
+
+ Vector3 paddingAddedSize = field.GetNaturalSize();
+
+ DALI_TEST_EQUALS(originalSize.width + 10 + 10, paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(originalSize.height + 10 + 10, paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldEnableShiftSelectionProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+ field.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);
+ application.GetScene().Add(field);
+
+ application.SendNotification();
+ application.Render();
+
+ // The default value of ENABLE_SHIFT_SELECTION is 'true'.
+ DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), true, TEST_LOCATION);
+
+ // Check the enable shift selection property
+ field.SetProperty(DevelTextField::Property::ENABLE_SHIFT_SELECTION, false);
+ DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_SHIFT_SELECTION), false, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldEnableGrabHandleProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
+
+ 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);
+ application.GetScene().Add(field);
+
+ application.SendNotification();
+ application.Render();
+
+ // The default value of ENABLE_GRAB_HANDLE is 'true'.
+ DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), true, TEST_LOCATION);
+
+ // Check the enable grab handle property
+ field.SetProperty(DevelTextField::Property::ENABLE_GRAB_HANDLE, false);
+ DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::ENABLE_GRAB_HANDLE), false, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
+
+ 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);
+ application.GetScene().Add(field);
+
+ application.SendNotification();
+ application.Render();
+
+ // 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, false);
+ DALI_TEST_EQUALS(field.GetProperty<bool>(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION), false, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int utcDaliTextFieldLayoutDirectionCoverage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
+
+ // Creates a tap event. After creating a tap event the text field should
+ // have the focus and add text with key events should be possible.
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(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);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // init direction for coverage
+ // Set horizontal alignment END
+ field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
+ field.SetProperty(DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
+ field.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
+
+ // Set horizontal alignment BEGIN
+ field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set horizontal alignment CENTER
+ field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set horizontal alignment END
+ field.SetProperty(TextField::Property::HORIZONTAL_ALIGNMENT, "END");
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 150.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Generate a Esc key event. The text field should lose the focus.
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ 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_EQUALS(false, field.HasKeyInputFocus(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldGetInputMethodContext(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldGetInputMethodContext");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(DevelTextField::GetInputMethodContext(field));
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldSelectWholeText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectWholeText ");