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=d9a70d29e135835045b3bf354b06de166e2e503f;hp=9b1d0ff1a5b86da04f856d20f2be97a3d56d45ab;hb=75fe6c4a2f784bd52ccf8eb16049317825338a6e;hpb=b65eaebffecede94f9c089f40448a499ab516f0c diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 9b1d0ff..d9a70d2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -140,6 +140,8 @@ static bool gInputFilteredAcceptedCallbackCalled; static bool gInputFilteredRejectedCallbackCalled; static bool gInputStyleChangedCallbackCalled; static bool gMaxCharactersCallBackCalled; +static bool gCursorPositionChangedCallbackCalled; +static uint32_t oldCursorPos; static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask; struct CallbackFunctor @@ -168,6 +170,14 @@ static void TestAnchorClickedCallback(TextEditor control, const char* href, unsi } } +static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos ) +{ + tet_infoline(" TestCursorPositionChangedCallback"); + + gCursorPositionChangedCallbackCalled = true; + oldCursorPos = oldPos; +} + static void TestTextChangedCallback( TextEditor control ) { tet_infoline(" TestTextChangedCallback"); @@ -1005,6 +1015,11 @@ int UtcDaliTextEditorSetPropertyP(void) application.SendNotification(); application.Render(); + // Check the line size property + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f ); + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + END_TEST; } @@ -3975,4 +3990,156 @@ int UtcDaliToolkitTextEditorEllipsisPositionProperty(void) DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION ); END_TEST; +} + +int UtcDaliTextEditorLineSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorLineSpacing "); + + TextEditor textEditor = TextEditor::New(); + textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) ); + application.GetScene().Add( textEditor ); + application.SendNotification(); + application.Render(); + + textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" ); + textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 ); + + Vector3 sizeBefore = textEditor.GetNaturalSize(); + + textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 ); + + //add 20 for each line 20 * 3 + DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorMinLineSize(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMinLineSize "); + + TextEditor textEditor = TextEditor::New(); + textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) ); + application.GetScene().Add( textEditor ); + application.SendNotification(); + application.Render(); + + textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" ); + textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 ); + + Vector3 sizeBefore = textEditor.GetNaturalSize(); + + textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 ); + + DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION); + + //60 * 3 lines + DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION); + + END_TEST; +} + +int utcDaliTextEditorCursorPositionChangedSignal(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK( editor ); + + application.GetScene().Add( editor ); + + // connect to the selection changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback); + bool cursorPositionChangedSignal = false; + editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) ); + + editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" ); + editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f ); + editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) ); + editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + editor.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(); + + editor.SetKeyInputFocus(); + + // Tap on the text editor + TestGenerateTap( application, 3.0f, 25.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION); + + gCursorPositionChangedCallbackCalled = false; + + // Move to left. + 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(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION); + + gCursorPositionChangedCallbackCalled = false; + + // Insert C + application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION); + + gCursorPositionChangedCallbackCalled = false; + + //delete one character + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION); + + gCursorPositionChangedCallbackCalled = false; + + editor.SetProperty( TextEditor::Property::TEXT, "Hello" ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION); + + gCursorPositionChangedCallbackCalled = false; + + editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION); + + END_TEST; } \ No newline at end of file