/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
static uint32_t oldSelectionStart;
static uint32_t oldSelectionEnd;
static bool gSelectionClearedCallbackCalled;
+static bool gSelectionStartedCallbackCalled;
static bool gAnchorClickedCallBackCalled;
static bool gAnchorClickedCallBackNotCalled;
static bool gTextChangedCallBackCalled;
gSelectionClearedCallbackCalled = true;
}
+static void TestSelectionStartedCallback(TextField control)
+{
+ tet_infoline(" TestSelectionStartedCallback");
+
+ gSelectionStartedCallbackCalled = true;
+}
+
static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
{
tet_infoline(" TestSelectionChangedCallback");
application.SendNotification();
application.Render();
- Actor layer = field.GetChildAt(1u);
+ Actor layer = field.GetChildAt(2u);
DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
// Checks the cursor and the renderer have been created.
DALI_TEST_EQUALS(layer.GetChildCount(), 1u, TEST_LOCATION); // The cursor.
- DALI_TEST_EQUALS(stencil.GetChildCount(), 1u, TEST_LOCATION); // The renderer
+ DALI_TEST_EQUALS(stencil.GetChildCount(), 2u, TEST_LOCATION); // The renderer, clipped cursor
Control cursor = Control::DownCast(layer.GetChildAt(0u));
DALI_TEST_CHECK(cursor);
DALI_TEST_EQUALS(position4, position7, TEST_LOCATION); // Should be in the same position2.
- // Should not be a renderer.
- DALI_TEST_EQUALS(stencil.GetChildCount(), 0u, TEST_LOCATION);
+ // 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.");
END_TEST;
}
+int utcDaliTextFieldSelectionStartedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldSelectionStartedSignal");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ // connect to the selection changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::SelectionStartedSignal(field).Connect(&TestSelectionStartedCallback);
+ bool selectionStartedSignal = false;
+ field.ConnectSignal(testTracker, "selectionStarted", CallbackFunctor(&selectionStartedSignal));
+
+ field.SetProperty(TextField::Property::TEXT, "Hello\nworld\nHello world");
+ field.SetProperty(TextField::Property::POINT_SIZE, 10.f);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text field
+ TestGenerateTap(application, 3.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move to second line of the text & Select some text in the right of the current cursor position
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
+
+ // remove selection
+ 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();
+
+ gSelectionStartedCallbackCalled = false;
+
+ DevelTextField::SelectText(field, 1, 3);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gSelectionStartedCallbackCalled);
+
+ END_TEST;
+}
+
int utcDaliTextFieldSelectionChangedSignal(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet3, underlineMapSet3), true, TEST_LOCATION);
application.GetScene().Add(field3);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldCharacterSpacing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldCharacterSpacing ");
+
+ TextField textField = TextField::New();
+
+ textField.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
+
+ application.GetScene().Add(textField);
+ application.SendNotification();
+ application.Render();
+
+ textField.SetProperty(TextField::Property::TEXT, "Hi Experiment");
+ textField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.f);
+ DALI_TEST_EQUALS(textField.GetProperty<float>(DevelTextField::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
application.SendNotification();
application.Render();
application.Render();
END_TEST;
+}
+
+int UtcDaliToolkitTextfieldParagraphTag(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextfieldParagraphTag");
+ TextField fieldNewlineSeparator = TextField::New();
+ TextField fieldParagraphTag = TextField::New();
+ DALI_TEST_CHECK(fieldNewlineSeparator);
+ DALI_TEST_CHECK(fieldParagraphTag);
+
+ application.GetScene().Add(fieldNewlineSeparator);
+ application.GetScene().Add(fieldParagraphTag);
+
+ //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
+ fieldNewlineSeparator.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ fieldNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ fieldNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ fieldNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ fieldNewlineSeparator.SetProperty(TextField::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
+
+ fieldParagraphTag.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ fieldParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ fieldParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ fieldParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ fieldParagraphTag.SetProperty(TextField::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 textNaturalSizeNewlineSeparator = fieldNewlineSeparator.GetNaturalSize();
+ Vector3 textNaturalSizeParagraphTag = fieldParagraphTag.GetNaturalSize();
+
+ DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
}
\ No newline at end of file