X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextField.cpp;h=d00dc75e826ed254cea23f4b683a26b8de943a77;hp=f6e24e67ebb8ed0ada0d2d0dc1eec1cd3043adf8;hb=2daa5af9afa208c6e58b5a69ff304b513777aa63;hpb=b0faad981257720e1a5fb15af45647f30b669adf diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index f6e24e6..d00dc75 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -3221,6 +3221,70 @@ int UtcDaliTextFieldSettingPlaceholder(void) 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; @@ -3482,6 +3546,66 @@ int UtcDaliTextFieldSelectWholeText(void) END_TEST; } +int UtcDaliTextFieldSelectText(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldSelectText "); + + 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(); + + DevelTextField::SelectText( textField, 0, 5 ); + + application.SendNotification(); + application.Render(); + + // Nothing is selected + std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION ); + + textField.SetProperty( TextField::Property::TEXT, "Hello world" ); + + application.SendNotification(); + application.Render(); + + // Hello is selected + DevelTextField::SelectText( textField, 0, 5 ); + + application.SendNotification(); + application.Render(); + + selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get(), 5, TEST_LOCATION ); + + // world is selected + DevelTextField::SelectText( textField, 6, 11 ); + + application.SendNotification(); + application.Render(); + + selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get(), 6, TEST_LOCATION ); + DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get(), 11, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliTextFieldSelectNone(void) { ToolkitTestApplication application; @@ -3675,6 +3799,7 @@ int UtcDaliTextFieldPrimaryCursorPosition(void) textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3); application.SendNotification(); application.Render(); + textField.SetKeyInputFocus(); application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );