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-TextEditor.cpp;h=9b1d0ff1a5b86da04f856d20f2be97a3d56d45ab;hp=626432eaa2c6a585a66f0bf3fbf5e44c1762f4d1;hb=699c8c5f00b8ea4bba12b4e6e6f91b022cb261b4;hpb=d48f1af617203f1dee78e3914f6080ec72cab38e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 626432e..9b1d0ff 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -105,7 +105,9 @@ const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSys const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength"; const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor"; - +const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup"; +const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings"; +const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter"; const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. @@ -134,6 +136,8 @@ const std::string DEFAULT_DEVICE_NAME("hwKeyboard"); static bool gAnchorClickedCallBackCalled; static bool gAnchorClickedCallBackNotCalled; static bool gTextChangedCallBackCalled; +static bool gInputFilteredAcceptedCallbackCalled; +static bool gInputFilteredRejectedCallbackCalled; static bool gInputStyleChangedCallbackCalled; static bool gMaxCharactersCallBackCalled; static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask; @@ -186,6 +190,20 @@ static void TestMaxLengthReachedCallback( TextEditor control ) gMaxCharactersCallBackCalled = true; } +static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type) +{ + tet_infoline(" TestInputFilteredCallback"); + + if(type == Toolkit::InputFilter::Property::ACCEPTED) + { + gInputFilteredAcceptedCallbackCalled = true; + } + else if(type == Toolkit::InputFilter::Property::REJECTED) + { + gInputFilteredRejectedCallbackCalled = true; + } +} + // Generate a KeyEvent to send to Core. Integration::KeyEvent GenerateKey( const std::string& keyName, const std::string& logicalKey, @@ -512,7 +530,9 @@ int UtcDaliTextEditorGetPropertyP(void) DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR ); - + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER ); END_TEST; } @@ -931,6 +951,57 @@ int UtcDaliTextEditorSetPropertyP(void) editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN ); DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION ); + // Test the ENABLE_GRAB_HANDLE_POPUP property + editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false ); + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION); + + // Check the input method setting + Property::Map propertyMap; + InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER; + InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD; + InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO; + int inputVariation = 1; + propertyMap["PANEL_LAYOUT"] = panelLayout; + propertyMap["AUTO_CAPITALIZE"] = autoCapital; + propertyMap["BUTTON_ACTION"] = buttonAction; + propertyMap["VARIATION"] = inputVariation; + editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap ); + + Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS ); + Property::Map map; + DALI_TEST_CHECK( value.Get( map ) ); + + int layout = 0; + DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) ); + DALI_TEST_EQUALS( static_cast(panelLayout), layout, TEST_LOCATION ); + + int capital = 0; + DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) ); + DALI_TEST_EQUALS( static_cast(autoCapital), capital, TEST_LOCATION ); + + int action = 0; + DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) ); + DALI_TEST_EQUALS( static_cast(buttonAction), action, TEST_LOCATION ); + + int variation = 0; + DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) ); + DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION ); + + // Check the input filter property + Property::Map inputFilterMapSet; + Property::Map inputFilterMapGet; + inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]"; + inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]"; + + editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet); + + inputFilterMapGet = editor.GetProperty(DevelTextEditor::Property::INPUT_FILTER); + DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION); + + // Clear + inputFilterMapSet.Clear(); + editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet); + application.SendNotification(); application.Render(); @@ -3010,13 +3081,13 @@ int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void) application.SendNotification(); application.Render(); - // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'. - DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); - - // Check the enable match system language direction property - editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true ); + // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'. DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION ); + // Check the disable match system language direction property + editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false ); + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); + application.SendNotification(); application.Render(); @@ -3067,6 +3138,58 @@ int utcDaliTextEditorMaxCharactersReached(void) END_TEST; } +int utcDaliTextEditorInputFiltered(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorInputFiltered"); + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + application.GetScene().Add(editor); + + Property::Map inputFilter; + + // Only digit is accepted. + inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]"; + + // Set input filter to TextEditor. + editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter); + + editor.SetKeyInputFocus(); + + // connect to the input filtered signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback); + bool inputFilteredSignal = false; + editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal)); + + gInputFilteredAcceptedCallbackCalled = false; + + 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(gInputFilteredAcceptedCallbackCalled); + DALI_TEST_CHECK(inputFilteredSignal); + + // Word is rejected. + inputFilter[InputFilter::Property::ACCEPTED] = ""; + inputFilter[InputFilter::Property::REJECTED] = "[\\w]"; + + // Set input filter to TextEditor. + editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter); + + editor.SetKeyInputFocus(); + + inputFilteredSignal = false; + gInputFilteredRejectedCallbackCalled = false; + + 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(gInputFilteredAcceptedCallbackCalled); + DALI_TEST_CHECK(inputFilteredSignal); + + END_TEST; +} + int UtcDaliTextEditorSelectWholeText(void) { ToolkitTestApplication application; @@ -3119,6 +3242,65 @@ int UtcDaliTextEditorSelectWholeText(void) END_TEST; } +int UtcDaliTextEditorSelectText(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorSelectText "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add( textEditor ); + + textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) ); + textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + textEditor.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(); + + DevelTextEditor::SelectText( textEditor ,0, 5 ); + + application.SendNotification(); + application.Render(); + + // Nothing is selected + std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION ); + + textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" ); + + application.SendNotification(); + application.Render(); + + DevelTextEditor::SelectText( textEditor, 0, 5 ); + + application.SendNotification(); + application.Render(); + + selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get(), 5, TEST_LOCATION ); + + // world is selected + DevelTextEditor::SelectText( textEditor, 6, 11 ); + + application.SendNotification(); + application.Render(); + + selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get(); + DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION ); + + DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get(), 6, TEST_LOCATION ); + DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get(), 11, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliTextEditorSelectNone(void) { ToolkitTestApplication application; @@ -3342,6 +3524,7 @@ int UtcDaliTextEditorPrimaryCursorPosition(void) textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3); application.SendNotification(); application.Render(); + textEditor.SetKeyInputFocus(); application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); @@ -3481,6 +3664,49 @@ int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(voi END_TEST; } +int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void) +{ + ToolkitTestApplication application; + + tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged "); + + int lineCountBefore =0 ; + int lineCountAfter =0 ; + + // Create a text editor + TextEditor textEditor = TextEditor::New(); + //Set very large font-size using point-size + textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ; + //Specify font-family + textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans"); + //Specify size + textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) ); + //Set text longer than width of textEditor + textEditor.SetProperty( TextEditor::Property::TEXT, "Short text"); + //Set line wrap mode Character + textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER"); + + application.GetScene().Add( textEditor ); + + application.SendNotification(); + application.Render(); + + + lineCountBefore = textEditor.GetProperty( TextEditor::Property::LINE_COUNT ); + + textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test"); + lineCountAfter = textEditor.GetProperty( TextEditor::Property::LINE_COUNT ); + + // When the text changed, the Line-count should be updated according to new text. + // Because the GetHeightForWidth is called in Controller::GetLineCount(float width) + DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION ); + DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION ); + + + END_TEST; +} + + int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void) { ToolkitTestApplication application; @@ -3689,4 +3915,64 @@ int UtcDaliTextEditorHyphenWrapMode(void) DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION ); END_TEST; +} + +int UtcDaliToolkitTextEditorEllipsisPositionProperty(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty "); + TextEditor textEditor = TextEditor::New(); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION ); + + tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase"); + textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end"); + DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); + + END_TEST; } \ No newline at end of file