const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
+static bool gAnchorClickedCallBackCalled;
+static bool gAnchorClickedCallBackNotCalled;
static bool gTextChangedCallBackCalled;
static bool gMaxCharactersCallBackCalled;
static bool gInputStyleChangedCallbackCalled;
bool* mCallbackFlag;
};
+static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
+{
+ tet_infoline(" TestAnchorClickedCallback");
+
+ gAnchorClickedCallBackNotCalled = false;
+
+ if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
+ {
+ gAnchorClickedCallBackCalled = true;
+ }
+}
+
static void TestTextChangedCallback( TextField control )
{
tet_infoline(" TestTextChangedCallback");
END_TEST;
}
+// Positive test for the anchorClicked signal.
+int utcDaliTextFieldAnchorClicked01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldAnchorClicked01");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ // connect to the anchor clicked signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
+ bool anchorClickedSignal = false;
+ field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
+
+ gAnchorClickedCallBackCalled = false;
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ application.SendNotification();
+ application.Render();
+ field.SetKeyInputFocus();
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 5.0f, 25.0f);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+ DALI_TEST_CHECK(anchorClickedSignal);
+
+ gAnchorClickedCallBackNotCalled = true;
+ // Tap the outside of anchor, callback should not be called.
+ TestGenerateTap(application, 150.f, 100.f);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
+
+ END_TEST;
+}
+
+// Positive test for the anchorClicked signal.
+int utcDaliTextFieldAnchorClicked02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldAnchorClicked02");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+
+ // connect to the anchor clicked signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
+ bool anchorClickedSignal = false;
+ field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
+
+ gAnchorClickedCallBackCalled = false;
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ application.SendNotification();
+ application.Render();
+ field.SetKeyInputFocus();
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 100);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+ DALI_TEST_CHECK(anchorClickedSignal);
+
+
+ // For coverage InsertTextAnchor, RemoveTextAnchor
+ // first index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 700);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // last index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 1300);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // mid index insert
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 1900);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // first index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 2500);
+ application.SendNotification();
+ field.SetKeyInputFocus();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // last index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 3100);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // middle index
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 3700);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 0 ~ 1 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 4300);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 1 ~ 3 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 4900);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // 3 ~ 4 index remove
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
+ field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ gAnchorClickedCallBackCalled = false;
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f, 5500);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
+
+ // Remove front of anchor
+ field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove whole text
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
+ DevelTextField::SelectWholeText(field);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove all with backspace
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ // Remove all with delete
+ field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
+ field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
+ application.SendNotification();
+ application.Render();
+
+ application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
// Positive test for the textChanged signal.
int utcDaliTextFieldTextChangedP(void)
{
DALI_TEST_CHECK( !inputStyleChangedSignal );
// Create a tap event to touch the text field.
- TestGenerateTap( application, 63.0f, 25.0f, 300 );
+ TestGenerateTap( application, 63.0f, 25.0f, 700 );
// Render and notify
application.SendNotification();
END_TEST;
}
+
+// test max length when set after setting long text
+int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+
+ application.GetScene().Add( field );
+
+ field.SetProperty(TextField::Property::TEXT, "123456789");
+
+ const int maxNumberOfCharacters = 3;
+ field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
+
+ field.SetKeyInputFocus();
+
+ // connect to the text max lengh reached signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ bool maxLengthReachedSignal = false;
+ field.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
+
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ DALI_TEST_CHECK( maxLengthReachedSignal );
+
+ DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ // Create a text field
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
+ //Specify font-family
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ application.GetScene().Add( textField );
+
+ application.SendNotification();
+ application.Render();
+ //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ Vector3 naturalSize = textField.GetNaturalSize();
+
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ // Create a text editor
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ const int numberOfCases = 6;
+ int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
+
+ for (int index=0; index < numberOfCases; index++)
+ {
+ tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
+ textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
+ application.GetScene().Add( textField );
+ application.SendNotification();
+ application.Render();
+ naturalSize = textField.GetNaturalSize();
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ }
+
+ END_TEST;
+}
\ No newline at end of file