+
+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 );
+
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ 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 );
+
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ 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;
+}
+
+int UtcDaliTextControllerSetGetLineSpacingProperty(void)
+{
+ tet_infoline(" UtcDaliTextControllerSetGetLineSpacingProperty");
+ ToolkitTestApplication application;
+
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+
+ // single line text
+ const std::string textSingle("A Quick Brown Fox Jumps Over The Lazy Dog");
+
+ // multi-line text
+ const std::string textMulti("A Quick Brown\nFox Jumps Over\nThe Lazy Dog");
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // single line, line spacing = 0px
+ {
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 343.0f, 19.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE( 344.0f, 20.0f, 0.0f );
+
+ controller->SetText(textSingle);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( false );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // single line, line spacing = 20px
+ {
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 343.0f, 19.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 344.0f, 40.0f, 0.0f );
+
+ controller->SetText(textSingle);
+ controller->Relayout(size);
+ controller->SetDefaultLineSpacing( 20 );
+ controller->SetMultiLineEnabled( false );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 0px
+ {
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 333.0f, 39.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 120.0f, 58.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 0 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 20px
+ {
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 119.0f, 57.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 120.0f, 118.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 20 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+ // multi-line, line spacing = 30px
+ {
+ const float EXPECTED_SPACING = 30.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE( 119.0f, 117.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 120.0f, 148.0f, 0.0f );
+
+ controller->SetText(textMulti);
+ controller->Relayout(size);
+ controller->SetMultiLineEnabled( true );
+ controller->SetDefaultLineSpacing( 30 );
+
+ Vector3 naturalSize = controller->GetNaturalSize();
+ Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
+ float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+ DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+ }
+
+
+ END_TEST;
+
+}
+
+int UtcDaliTextControllerCheckBufferIndices(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckBufferIndices");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Set the text
+ const std::string text("A Quick Brown Fox Jumps Over The Lazy Dog");
+ controller->SetText(text);
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Tweak some parameters to make the indices to access the text buffer invalid
+ mImpl.mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl.mModel->mLogicalModel->mText.Count() * 10u;
+ mImpl.mTextUpdateInfo.mNumberOfCharactersToRemove = 0u;
+ mImpl.mTextUpdateInfo.mPreviousNumberOfCharacters = 0u;
+ mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputColorChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputColorChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+
+ const Vector4 inputColor( 0.0f, 0.0f, 0.0f, 1.0f );
+ controller->SetInputColor( inputColor );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input color
+ const Vector4 newInputColor( 1.0f, 0.0f, 0.0f, 1.0f );
+ controller->SetInputColor( newInputColor );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::COLOR, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::COLOR ), TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontFamilyChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontFamilyChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text and font family
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontFamily("SamsungOneUI_200");
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input font family
+ controller->SetInputFontFamily("SamsungOneUI_300");
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontWeightChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontWeightChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontWeight( TextAbstraction::FontWeight::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input font weight
+ controller->SetInputFontWeight( TextAbstraction::FontWeight::BOLD );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontWidthChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontWidthChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontWidth( TextAbstraction::FontWidth::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input font width
+ controller->SetInputFontWidth( TextAbstraction::FontWidth::EXPANDED );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontSlantChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontSlantChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontSlant( TextAbstraction::FontSlant::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input font slant
+ controller->SetInputFontSlant( TextAbstraction::FontSlant::ROMAN );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontPointSizeChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontPointSizeChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontPointSize( 1.0f );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::Down ) );
+
+ // change the input font point size
+ controller->SetInputFontPointSize( 1.2f );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}