X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-Controller.cpp;h=d39a88fb964d1a337a3dd096bd6a39e8bb700456;hb=f950b22d3cb695337678869d767979dede0d90b1;hp=c67f6220e6839859af3a7893798f8e17d1520d56;hpb=42d2c0d276f9821adf75b66b190d6dcfb65238f3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index c67f622..d39a88f 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -42,32 +43,6 @@ const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup const Size CONTROL_SIZE( 300.f, 60.f ); -class ControlImpl : public ControlInterface, public Text::EditableControlInterface -{ -public: - ControlImpl() - : ControlInterface() - {} - - virtual ~ControlImpl() - {} - - virtual void AddDecoration( Actor& actor, bool needsClipping ) - {} - - virtual void RequestTextRelayout() - {} - - virtual void TextChanged() - {} - - virtual void MaxLengthReached() - {} - - virtual void InputStyleChanged( InputStyle::Mask inputStyleMask ) - {} -}; - std::string gClipboardText; void ContentSelectedCallback( ClipboardEventNotifier& notifier ) { @@ -83,9 +58,73 @@ int UtcDaliTextController(void) // Creates a text controller. ControllerPtr controller = Controller::New(); + DALI_TEST_CHECK( controller ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetGetScrollEnabled(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetScrollEnabled"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + DALI_TEST_CHECK( controller ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( controller->IsVerticalScrollEnabled() ); + + // Configures the text controller similarly to the text-field. + ConfigureTextField( controller ); + + DALI_TEST_CHECK( controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() ); + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetIsTextElide(void) +{ + tet_infoline(" UtcDaliTextControllerSetIsTextElide"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); DALI_TEST_CHECK( controller ); + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( true ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + // Configures the text controller similarly to the text-field. + ConfigureTextField( controller ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( true ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( false ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + tet_result(TET_PASS); END_TEST; } @@ -97,7 +136,6 @@ int UtcDaliTextControllerEnableCursorBlinking(void) // Creates a text controller. ControllerPtr controller = Controller::New(); - DALI_TEST_CHECK( controller ); // There is no text input enabled. @@ -328,3 +366,146 @@ int UtcDaliTextControllerTextPopupButtonTouched(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextControllerGetInputShadowProperty(void) +{ + tet_infoline(" UtcDaliTextControllerGetInputShadowProperty"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + const std::string& shadowProperties = controller->GetInputShadowProperties(); + + DALI_TEST_CHECK( shadowProperties.empty() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerGetInputUnderlineProperty(void) +{ + tet_infoline(" UtcDaliTextControllerGetInputUnderlineProperty"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + const std::string& underlineProperties = controller->GetInputUnderlineProperties(); + + DALI_TEST_CHECK( underlineProperties.empty() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetGetAutoScrollEnabled(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetAutoScrollEnabled"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + DALI_TEST_CHECK( !controller->IsAutoScrollEnabled() ); + + // The auto scrolling shouldn't be enabled if the multi-line is enabled. + + // Enable multi-line. + controller->SetMultiLineEnabled( true ); + + // Enable text scrolling. + controller->SetAutoScrollEnabled( true ); + + DALI_TEST_CHECK( !controller->IsAutoScrollEnabled() ); + + // Disable multi-line. + controller->SetMultiLineEnabled( false ); + + // Enable text scrolling. + controller->SetAutoScrollEnabled( true ); + + // Should be ebabled now. + DALI_TEST_CHECK( controller->IsAutoScrollEnabled() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetGetCheckProperty(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetCheckProperty"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + // Enable the text input. + // Creates a decorator. + Text::DecoratorPtr decorator = Text::Decorator::New( *controller, *controller ); + + // Enables the text input. + controller->EnableTextInput( decorator ); + + DALI_TEST_CHECK( !controller->IsInputModePassword() ); + + // Set the text input to password. + controller->SetInputModePassword( true ); + + DALI_TEST_CHECK( controller->IsInputModePassword() ); + + // Unset the text input to password. + controller->SetInputModePassword( false ); + + DALI_TEST_CHECK( !controller->IsInputModePassword() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetGetTapLongPressAction(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetTapLongPressAction"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + // Test first with no decorator. + + DALI_TEST_EQUALS( Controller::NoTextTap::NO_ACTION, controller->GetNoTextDoubleTapAction(), TEST_LOCATION ); + controller->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT ); + DALI_TEST_EQUALS( Controller::NoTextTap::NO_ACTION, controller->GetNoTextDoubleTapAction(), TEST_LOCATION ); + + DALI_TEST_EQUALS( Controller::NoTextTap::NO_ACTION, controller->GetNoTextLongPressAction(), TEST_LOCATION ); + controller->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT ); + DALI_TEST_EQUALS( Controller::NoTextTap::NO_ACTION, controller->GetNoTextLongPressAction(), TEST_LOCATION ); + + // Add a decorator and re-test. + + // Creates a decorator. + Text::DecoratorPtr decorator = Text::Decorator::New( *controller, *controller ); + + // Enables the text input. + controller->EnableTextInput( decorator ); + + DALI_TEST_EQUALS( Controller::NoTextTap::NO_ACTION, controller->GetNoTextDoubleTapAction(), TEST_LOCATION ); + controller->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT ); + DALI_TEST_EQUALS( Controller::NoTextTap::HIGHLIGHT, controller->GetNoTextDoubleTapAction(), TEST_LOCATION ); + + DALI_TEST_EQUALS( Controller::NoTextTap::SHOW_SELECTION_POPUP, controller->GetNoTextLongPressAction(), TEST_LOCATION ); // The default is SHOW_SELECTION_POPUP + controller->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT ); + DALI_TEST_EQUALS( Controller::NoTextTap::HIGHLIGHT, controller->GetNoTextLongPressAction(), TEST_LOCATION ); + + END_TEST; +}