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=fac21a0dc59a87f342ec888d228566eeea6244d6;hp=c3a08ed5ba116f6f870bdcc1c661fd2cbdbf681c;hb=9d379104c45c7979f7dcd1ef2f9df84e8cc902c1;hpb=38f0ea9fcdf1dc5037144fa19c8a52316c8af763 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index c3a08ed..fac21a0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -20,11 +20,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -65,6 +67,7 @@ const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBl const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth"; const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage"; const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage"; +const char* const PROPERTY_NAME_SELECTION_POPUP_STYLE = "selectionPopupStyle"; const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft"; const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight"; const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft"; @@ -388,6 +391,57 @@ public: bool& mFinishedCalled; }; + +// Stores data that is populated in the callback and will be read by the test cases +struct SignalData +{ + SignalData() + : functorCalled(false), + voidFunctorCalled(false), + receivedGesture() + { + } + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.Reset(); + + pannedActor.Reset(); + } + + bool functorCalled; + bool voidFunctorCalled; + PanGesture receivedGesture; + Actor pannedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) + : signalData(data) + { + } + + void operator()(Actor actor, const PanGesture& pan) + { + signalData.functorCalled = true; + signalData.receivedGesture = pan; + signalData.pannedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + + } // namespace int UtcDaliToolkitTextEditorConstructorP(void) @@ -581,6 +635,7 @@ int UtcDaliTextEditorGetPropertyP(void) DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_FILTER) == DevelTextEditor::Property::INPUT_FILTER); DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextEditor::Property::STRIKETHROUGH); DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_INPUT_STRIKETHROUGH) == DevelTextEditor::Property::INPUT_STRIKETHROUGH); + DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE); END_TEST; } @@ -735,6 +790,64 @@ int UtcDaliTextEditorSetPropertyP(void) DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage")); DALI_TEST_CHECK(SetPropertyMapRetrieved(editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage")); + // Check the selection popup style + const Vector2 popupMaxSize(200.0f, 300.0f); + const Vector2 optionDividerSize(30.0f, 5.0f); + const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f); + const Vector4 labelPadding(5.0f, 5.0f, 50.0f, 25.0f); + + Property::Map selectionPopupStyle; + selectionPopupStyle.Insert(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize); + selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize); + selectionPopupStyle.Insert(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding); + selectionPopupStyle.Insert(TextSelectionPopup::Property::LABEL_PADDING, labelPadding); + + editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle); + + Property::Map selectionPopupStyleGet; + selectionPopupStyleGet = editor.GetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE); + + Property::Value* popupValue; + popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::POPUP_MAX_SIZE); + DALI_TEST_CHECK(NULL != popupValue); + if(popupValue) + { + Vector2 popupMaxSizeGet; + popupValue->Get(popupMaxSizeGet); + DALI_TEST_EQUALS(popupMaxSizeGet, popupMaxSize, TEST_LOCATION); + } + + popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE); + DALI_TEST_CHECK(NULL != popupValue); + if(popupValue) + { + Vector2 optionDividerSizeGet; + popupValue->Get(optionDividerSizeGet); + DALI_TEST_EQUALS(optionDividerSizeGet, optionDividerSize, TEST_LOCATION); + } + + popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING); + DALI_TEST_CHECK(NULL != popupValue); + if(popupValue) + { + Vector4 optionDividerPaddingGet; + popupValue->Get(optionDividerPaddingGet); + DALI_TEST_EQUALS(optionDividerPaddingGet, optionDividerPadding, TEST_LOCATION); + } + + popupValue = selectionPopupStyleGet.Find(TextSelectionPopup::Property::LABEL_PADDING); + DALI_TEST_CHECK(NULL != popupValue); + if(popupValue) + { + Vector4 labelPaddingGet; + popupValue->Get(labelPaddingGet); + DALI_TEST_EQUALS(labelPaddingGet, labelPadding, TEST_LOCATION); + } + + // Reset selection popup style + selectionPopupStyle.Clear(); + editor.SetProperty(DevelTextEditor::Property::SELECTION_POPUP_STYLE, selectionPopupStyle); + // Check the highlight color editor.SetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN); DALI_TEST_EQUALS(editor.GetProperty(TextEditor::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION); @@ -5011,6 +5124,44 @@ int utcDaliTextEditorGeometryOneGlyph(void) END_TEST; } +int utcDaliTextEditorGeometryNullPtr(void) +{ + ToolkitTestApplication application; + tet_infoline("utcDaliTextEditorGeometryNullPtr"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + application.GetScene().Add(editor); + + editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f); + editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, ""); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + unsigned int expectedCount = 0; + unsigned int startIndex = 0; + unsigned int endIndex = 0; + + Vector positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex); + Vector sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION); + DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION); + + END_TEST; +} + + int utcDaliTextEditorSelectionClearedSignal(void) { ToolkitTestApplication application; @@ -6172,4 +6323,76 @@ int utcDaliTextEditorClusteredEmojiDeletionDeleteKey(void) application.Render(); END_TEST; -} \ No newline at end of file +} + +int utcDaliTextEditorPanGesturePropagation(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorPanGesturePropagation"); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + editor.SetProperty(TextEditor::Property::TEXT, "This is a long text for the size of the text-editor."); + editor.SetProperty(TextEditor::Property::POINT_SIZE, 10.f); + + editor.SetProperty(Actor::Property::SIZE, Vector2(30.f, 500.f)); + editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + actor.Add(editor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Tap first to get the focus. + TestGenerateTap(application, 3.0f, 25.0f, 100); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Pan the text editor + uint32_t time = 100; + TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time); + TestMovePan(application, Vector2(10.0f, 30.0f), time); + TestEndPan(application, Vector2(10.0f, 50.0f), time); + application.SendNotification(); + application.Render(); + + // The text scrolls because there is text that is scrolling. + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Set the size large enough to prevent scrolling. + editor.SetProperty(Actor::Property::SIZE, Vector2(500.f, 500.f)); + + // Render and notify + application.SendNotification(); + application.Render(); + + time = 200; + TestStartPan(application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time); + TestMovePan(application, Vector2(10.0f, 30.0f), time); + TestEndPan(application, Vector2(10.0f, 50.0f), time); + + // Because scrolling is not possible, the pan gesture is propagated. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + + END_TEST; +}