/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-utils.h>
-#include <dali/devel-api/events/key-event-devel.h>
#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
-#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/controller/text-controller-impl.h>
+#include <dali-toolkit/internal/text/controller/text-controller.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
+#include <dali/devel-api/events/key-event-devel.h>
+#include <toolkit-text-utils.h>
using namespace Dali;
using namespace Toolkit;
namespace
{
+const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
+const char* const OPTION_CUT("optionCut"); // "Cut" popup option.
+const char* const OPTION_COPY("optionCopy"); // "Copy" popup option.
+const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option.
+const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option.
-const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
-const char* const OPTION_CUT("optionCut"); // "Cut" popup option.
-const char* const OPTION_COPY("optionCopy"); // "Copy" popup option.
-const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option.
-const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option.
-
-const Size CONTROL_SIZE( 300.f, 60.f );
+const Size CONTROL_SIZE(300.f, 60.f);
std::string gClipboardText;
-void ContentSelectedCallback( ClipboardEventNotifier& notifier )
+void ContentSelectedCallback(ClipboardEventNotifier& notifier)
{
gClipboardText = notifier.GetContent();
}
// Generate a KeyEvent to send to Core.
-Dali::KeyEvent GenerateKey( const std::string& keyName,
- const std::string& keyString,
- int keyCode,
- int keyModifier,
- unsigned long timeStamp,
- const Dali::KeyEvent::State& keyState )
+Dali::KeyEvent GenerateKey(const std::string& keyName,
+ const std::string& keyString,
+ int keyCode,
+ int keyModifier,
+ unsigned long timeStamp,
+ const Dali::KeyEvent::State& keyState)
{
- return DevelKeyEvent::New( keyName, "", keyString, keyCode, keyModifier, timeStamp, keyState, "", "", Device::Class::NONE, Device::Subclass::NONE );
+ return DevelKeyEvent::New(keyName, "", keyString, keyCode, keyModifier, timeStamp, keyState, "", "", Device::Class::NONE, Device::Subclass::NONE);
}
} // namespace
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
- DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
- DALI_TEST_CHECK( controller->IsVerticalScrollEnabled() );
+ DALI_TEST_CHECK(!controller->IsHorizontalScrollEnabled());
+ DALI_TEST_CHECK(controller->IsVerticalScrollEnabled());
// Configures the text controller similarly to the text-field.
- ConfigureTextField( controller );
+ ConfigureTextField(controller);
- DALI_TEST_CHECK( controller->IsHorizontalScrollEnabled() );
- DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+ DALI_TEST_CHECK(controller->IsHorizontalScrollEnabled());
+ DALI_TEST_CHECK(!controller->IsVerticalScrollEnabled());
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
- DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
- DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+ DALI_TEST_CHECK(!controller->IsHorizontalScrollEnabled());
+ DALI_TEST_CHECK(!controller->IsVerticalScrollEnabled());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
- DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+ ConfigureTextEditor(controller);
+ DALI_TEST_EQUALS(false, controller->IsTextElideEnabled(), TEST_LOCATION);
- controller->SetTextElideEnabled( true );
- DALI_TEST_EQUALS( true, 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 );
+ ConfigureTextField(controller);
+ DALI_TEST_EQUALS(false, controller->IsTextElideEnabled(), TEST_LOCATION);
- controller->SetTextElideEnabled( true );
- DALI_TEST_EQUALS( true, 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 );
+ ConfigureTextLabel(controller);
+ DALI_TEST_EQUALS(true, controller->IsTextElideEnabled(), TEST_LOCATION);
- controller->SetTextElideEnabled( false );
- DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+ controller->SetTextElideEnabled(false);
+ DALI_TEST_EQUALS(false, controller->IsTextElideEnabled(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// There is no text input enabled.
- DALI_TEST_CHECK( !controller->GetEnableCursorBlink() );
+ DALI_TEST_CHECK(!controller->GetEnableCursorBlink());
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Enables the cursor blink.
- controller->SetEnableCursorBlink( true );
+ controller->SetEnableCursorBlink(true);
- DALI_TEST_CHECK( controller->GetEnableCursorBlink() );
+ DALI_TEST_CHECK(controller->GetEnableCursorBlink());
// Disables the cursor blink.
- controller->SetEnableCursorBlink( false );
+ controller->SetEnableCursorBlink(false);
- DALI_TEST_CHECK( !controller->GetEnableCursorBlink() );
+ DALI_TEST_CHECK(!controller->GetEnableCursorBlink());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- std::string text;
+ std::string text;
InputMethodContext::EventData imfEvent;
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the placeholder text.
- controller->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, "Hello Dali" );
+ controller->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, "Hello Dali");
// For coverage.
- imfEvent = InputMethodContext::EventData( InputMethodContext::GET_SURROUNDING, "", 0, 0 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::GET_SURROUNDING, "", 0, 0);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Send VOID event.
- imfEvent = InputMethodContext::EventData( InputMethodContext::VOID, "", 0, 0 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::VOID, "", 0, 0);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
- controller->GetText( text );
- DALI_TEST_CHECK( text.empty() );
+ controller->GetText(text);
+ DALI_TEST_CHECK(text.empty());
+ DALI_TEST_EQUALS(0u, controller->GetNumberOfCharacters(), TEST_LOCATION); // We should ignore Placeholder text here
- imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "Hello ", 0, 6 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello ", 0, 6);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
controller->GetNaturalSize();
// Check 'Delete All' key which means the input panel send a big range
- imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -100, 100 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::DELETE_SURROUNDING, "", -100, 100);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(0u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send COMMIT event.
- imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "Hello ", 0, 6 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello ", 0, 6);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello ", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(6u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send PRE_EDIT event
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send DELETE_SURROUNDING event
- imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -1, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::DELETE_SURROUNDING, "", -1, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello ", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(6u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// for coverage
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::UNDERLINE );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::UNDERLINE);
// Send PRE_EDIT event
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "wo", 6, 2 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "wo", 6, 2);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello wo", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello wo", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(8u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send GET_SURROUNDING event
- imfEvent = InputMethodContext::EventData( InputMethodContext::GET_SURROUNDING, "", 0, 0 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::GET_SURROUNDING, "", 0, 0);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello wo", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello wo", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(8u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send PRIVATE_COMMAND event
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRIVATE_COMMAND, "", 0, 0 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRIVATE_COMMAND, "", 0, 0);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello wo", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello wo", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(8u, controller->GetNumberOfCharacters(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- std::string text;
+ std::string text;
InputMethodContext::EventData imfEvent;
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// Configures the text controller similarly to the text-field.
- ConfigureTextField( controller );
+ ConfigureTextField(controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Send COMMIT event.
- imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "Hello ", 0, 6 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello ", 0, 6);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello ", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(6u, controller->GetNumberOfCharacters(), TEST_LOCATION);
// Send PRE_EDIT event
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::NONE );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::NONE);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as REVERSE
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::REVERSE );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::REVERSE);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as HIGHLIGHT
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::HIGHLIGHT );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::HIGHLIGHT);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as CUSTOM_PLATFORM_STYLE_1
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1 );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as CUSTOM_PLATFORM_STYLE_2
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2 );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as CUSTOM_PLATFORM_STYLE_3
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3 );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
- imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "w", 6, 1);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Set the preedit style as CUSTOM_PLATFORM_STYLE_4
- inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4 );
+ inputMethodContext.SetPreeditStyle(InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4);
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+ controller->GetText(text);
+ DALI_TEST_EQUALS("Hello w", text, TEST_LOCATION);
+ DALI_TEST_EQUALS(7u, controller->GetNumberOfCharacters(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- std::string text;
+ std::string text;
InputMethodContext::EventData imfEvent;
DALI_TEST_CHECK(controller);
// For coverage, mEditableControlInterface is required.
// Creates a temporary text-field to use mEditableControlInterface.
- TextField field = TextField::New();
- Toolkit::Internal::TextField& fieldImpl = GetImpl(field);
- ControllerPtr fieldController = fieldImpl.GetTextController();
- Controller::Impl& fieldControllerImpl = Controller::Impl::GetImplementation(*fieldController.Get());
- Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
+ TextField field = TextField::New();
+ Toolkit::Internal::TextField& fieldImpl = GetImpl(field);
+ ControllerPtr fieldController = fieldImpl.GetTextController();
+ Controller::Impl& fieldControllerImpl = Controller::Impl::GetImplementation(*fieldController.Get());
+ Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
// For coverage, mEditableControlInterface is required.
controllerImpl.mEditableControlInterface = fieldControllerImpl.mEditableControlInterface;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
- std::string text;
- PushButton button;
+ std::string text;
+ PushButton button;
Property::Map attributes;
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Creates the text's popup.
TextSelectionPopupCallbackInterface& callbackInterface = *controller;
- TextSelectionPopup textPopup = TextSelectionPopup::New( &callbackInterface );
+ TextSelectionPopup textPopup = TextSelectionPopup::New(&callbackInterface);
- Toolkit::TextSelectionPopup::Buttons buttonsToEnable = static_cast<Toolkit::TextSelectionPopup::Buttons>( TextSelectionPopup::CUT |
- TextSelectionPopup::COPY |
- TextSelectionPopup::PASTE |
- TextSelectionPopup::SELECT |
- TextSelectionPopup::SELECT_ALL |
- TextSelectionPopup::CLIPBOARD );
+ Toolkit::TextSelectionPopup::Buttons buttonsToEnable = static_cast<Toolkit::TextSelectionPopup::Buttons>(TextSelectionPopup::CUT |
+ TextSelectionPopup::COPY |
+ TextSelectionPopup::PASTE |
+ TextSelectionPopup::SELECT |
+ TextSelectionPopup::SELECT_ALL |
+ TextSelectionPopup::CLIPBOARD);
- textPopup.EnableButtons( buttonsToEnable );
- application.GetScene().Add( textPopup );
+ textPopup.EnableButtons(buttonsToEnable);
+ application.GetScene().Add(textPopup);
textPopup.ShowPopup();
// Render and notify
application.Render();
// Sets some text.
- controller->SetText( "Hello world" );
+ controller->SetText("Hello world");
// When the TextSelectionPopup is active, the controller has focus.
controller->KeyboardFocusGainEvent();
// Select the whole text.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_SELECT_ALL ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_SELECT_ALL));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Call relayout to process the input events.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(CONTROL_SIZE);
// Cut the text.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CUT ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_CUT));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_CHECK( text.empty() );
+ controller->GetText(text);
+ DALI_TEST_CHECK(text.empty());
// Set text again.
- controller->SetText( "Hello world" );
+ controller->SetText("Hello world");
// Select the whole text.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_SELECT_ALL ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_SELECT_ALL));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Call relayout to process the input events.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(CONTROL_SIZE);
// Copy to the clipboard.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_COPY ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_COPY));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Call relayout to process the input events.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(CONTROL_SIZE);
// Cut the text.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CUT ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_CUT));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Force to update the model.
controller->GetNaturalSize();
- controller->GetText( text );
- DALI_TEST_CHECK( text.empty() );
+ controller->GetText(text);
+ DALI_TEST_CHECK(text.empty());
ClipboardEventNotifier clipboardEventNotifier = ClipboardEventNotifier::Get();
- clipboardEventNotifier.ContentSelectedSignal().Connect( &ContentSelectedCallback );
+ clipboardEventNotifier.ContentSelectedSignal().Connect(&ContentSelectedCallback);
// Paste the text.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_PASTE ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_PASTE));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
// Call relayout to process the input events.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( "Hello world", gClipboardText, TEST_LOCATION );
+ DALI_TEST_EQUALS("Hello world", gClipboardText, TEST_LOCATION);
// Show the clipboard.
- button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CLIPBOARD ) );
- DALI_TEST_CHECK( button );
+ button = PushButton::DownCast(textPopup.FindChildByName(OPTION_CLIPBOARD));
+ DALI_TEST_CHECK(button);
- button.DoAction( "buttonClick", attributes );
+ button.DoAction("buttonClick", attributes);
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
const std::string& shadowProperties = controller->GetInputShadowProperties();
- DALI_TEST_CHECK( shadowProperties.empty() );
+ DALI_TEST_CHECK(shadowProperties.empty());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
const std::string& underlineProperties = controller->GetInputUnderlineProperties();
- DALI_TEST_CHECK( underlineProperties.empty() );
+ DALI_TEST_CHECK(underlineProperties.empty());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
- DALI_TEST_CHECK( !controller->IsAutoScrollEnabled() );
+ DALI_TEST_CHECK(!controller->IsAutoScrollEnabled());
// The auto scrolling shouldn't be enabled if the multi-line is enabled.
// Enable multi-line.
- controller->SetMultiLineEnabled( true );
+ controller->SetMultiLineEnabled(true);
// Enable text scrolling.
- controller->SetAutoScrollEnabled( true );
+ controller->SetAutoScrollEnabled(true);
- DALI_TEST_CHECK( !controller->IsAutoScrollEnabled() );
+ DALI_TEST_CHECK(!controller->IsAutoScrollEnabled());
// Disable multi-line.
- controller->SetMultiLineEnabled( false );
+ controller->SetMultiLineEnabled(false);
// Enable text scrolling.
- controller->SetAutoScrollEnabled( true );
+ controller->SetAutoScrollEnabled(true);
// Should be ebabled now.
- DALI_TEST_CHECK( controller->IsAutoScrollEnabled() );
+ DALI_TEST_CHECK(controller->IsAutoScrollEnabled());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ DALI_TEST_CHECK(controller);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller, *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller, *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
- DALI_TEST_CHECK( !controller->IsInputModePassword() );
+ DALI_TEST_CHECK(!controller->IsInputModePassword());
// Set the text input to password.
- controller->SetInputModePassword( true );
+ controller->SetInputModePassword(true);
- DALI_TEST_CHECK( controller->IsInputModePassword() );
+ DALI_TEST_CHECK(controller->IsInputModePassword());
// Unset the text input to password.
- controller->SetInputModePassword( false );
+ controller->SetInputModePassword(false);
- DALI_TEST_CHECK( !controller->IsInputModePassword() );
+ DALI_TEST_CHECK(!controller->IsInputModePassword());
tet_result(TET_PASS);
END_TEST;
// Creates a text controller.
ControllerPtr controller = Controller::New();
- DALI_TEST_CHECK( controller );
+ 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->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 );
+ 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 );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller, *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ 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::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 );
+ 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;
}
tet_infoline(" UtcDaliTextControllerSetGetLineSpacingProperty");
ToolkitTestApplication application;
- const Size size( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
// single line text
const std::string textSingle("A Quick Brown Fox Jumps Over The Lazy Dog");
// single line, line spacing = 0px
{
- const float EXPECTED_SPACING = 0.0f;
- const Vector2 EXPECTED_LAYOUT_SIZE( 349.0f, 19.0f);
- const Vector3 EXPECTED_NATURAL_SIZE( 350.0f, 20.0f, 0.0f );
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE(349.0f, 19.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE(350.0f, 20.0f, 0.0f);
controller->SetText(textSingle);
controller->Relayout(size);
- controller->SetMultiLineEnabled( false );
+ controller->SetMultiLineEnabled(false);
Vector3 naturalSize = controller->GetNaturalSize();
Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
- float lineSpacing0 = controller->GetDefaultLineSpacing();
+ 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 );
+ 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( 349.0f, 19.0f );
- const Vector3 EXPECTED_NATURAL_SIZE( 350.0f, 40.0f, 0.0f );
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE(349.0f, 19.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE(350.0f, 40.0f, 0.0f);
controller->SetText(textSingle);
controller->Relayout(size);
- controller->SetDefaultLineSpacing( 20 );
- controller->SetMultiLineEnabled( false );
+ controller->SetDefaultLineSpacing(20);
+ controller->SetMultiLineEnabled(false);
Vector3 naturalSize = controller->GetNaturalSize();
Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
- float lineSpacing0 = controller->GetDefaultLineSpacing();
+ 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 );
+ 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( 339.0f, 39.0f );
- const Vector3 EXPECTED_NATURAL_SIZE( 122.0f, 58.0f, 0.0f );
+ const float EXPECTED_SPACING = 0.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE(339.0f, 39.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE(122.0f, 58.0f, 0.0f);
controller->SetText(textMulti);
controller->Relayout(size);
- controller->SetMultiLineEnabled( true );
- controller->SetDefaultLineSpacing( 0 );
+ controller->SetMultiLineEnabled(true);
+ controller->SetDefaultLineSpacing(0);
Vector3 naturalSize = controller->GetNaturalSize();
Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
- float lineSpacing0 = controller->GetDefaultLineSpacing();
+ 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 );
+ 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( 121.0f, 57.0f );
- const Vector3 EXPECTED_NATURAL_SIZE( 122.0f, 118.0f, 0.0f );
+ const float EXPECTED_SPACING = 20.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE(121.0f, 57.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE(122.0f, 118.0f, 0.0f);
controller->SetText(textMulti);
controller->Relayout(size);
- controller->SetMultiLineEnabled( true );
- controller->SetDefaultLineSpacing( 20 );
+ controller->SetMultiLineEnabled(true);
+ controller->SetDefaultLineSpacing(20);
Vector3 naturalSize = controller->GetNaturalSize();
Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
- float lineSpacing0 = controller->GetDefaultLineSpacing();
+ 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 );
+ 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( 121.0f, 117.0f );
- const Vector3 EXPECTED_NATURAL_SIZE( 122.0f, 148.0f, 0.0f );
+ const float EXPECTED_SPACING = 30.0f;
+ const Vector2 EXPECTED_LAYOUT_SIZE(121.0f, 117.0f);
+ const Vector3 EXPECTED_NATURAL_SIZE(122.0f, 148.0f, 0.0f);
controller->SetText(textMulti);
controller->Relayout(size);
- controller->SetMultiLineEnabled( true );
- controller->SetDefaultLineSpacing( 30 );
+ controller->SetMultiLineEnabled(true);
+ controller->SetDefaultLineSpacing(30);
Vector3 naturalSize = controller->GetNaturalSize();
Vector2 layoutSize = controller->GetTextModel()->GetLayoutSize();
- float lineSpacing0 = controller->GetDefaultLineSpacing();
+ 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 );
+ 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)
controller->SetText(text);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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.mNumberOfCharactersToAdd = mImpl.mModel->mLogicalModel->mText.Count() * 10u;
mImpl.mTextUpdateInfo.mNumberOfCharactersToRemove = 0u;
mImpl.mTextUpdateInfo.mPreviousNumberOfCharacters = 0u;
- mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
+ mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
// Perform a relayout
- const Size size( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
// Set the text
controller->SetText(emptyText);
// Tweak some parameters to make the indices to access the text buffer invalid
- mImpl.mTextUpdateInfo.mNumberOfCharactersToAdd = 10u;
+ mImpl.mTextUpdateInfo.mNumberOfCharactersToAdd = 10u;
mImpl.mTextUpdateInfo.mNumberOfCharactersToRemove = 0u;
mImpl.mTextUpdateInfo.mPreviousNumberOfCharacters = 0u;
- mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
+ mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
// Perform a relayout
controller->Relayout(size);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ 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 );
+ 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() );
+ 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 ) );
+ 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 );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
tet_result(TET_PASS);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the text and font family
const std::string text("Hello World!");
controller->SetInputFontFamily("SamsungOneUI_200");
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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 ) );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
tet_result(TET_PASS);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the text
const std::string text("Hello World!");
controller->SetText(text);
- controller->SetInputFontWeight( TextAbstraction::FontWeight::NORMAL );
+ controller->SetInputFontWeight(TextAbstraction::FontWeight::NORMAL);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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 ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN));
// change the input font weight
- controller->SetInputFontWeight( TextAbstraction::FontWeight::BOLD );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
tet_result(TET_PASS);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the text
const std::string text("Hello World!");
controller->SetText(text);
- controller->SetInputFontWidth( TextAbstraction::FontWidth::NORMAL );
+ controller->SetInputFontWidth(TextAbstraction::FontWidth::NORMAL);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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 ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN));
// change the input font width
- controller->SetInputFontWidth( TextAbstraction::FontWidth::EXPANDED );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
tet_result(TET_PASS);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the text
const std::string text("Hello World!");
controller->SetText(text);
- controller->SetInputFontSlant( TextAbstraction::FontSlant::NORMAL );
+ controller->SetInputFontSlant(TextAbstraction::FontSlant::NORMAL);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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 ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN));
// change the input font slant
- controller->SetInputFontSlant( TextAbstraction::FontSlant::ROMAN );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
tet_result(TET_PASS);
// Enable the text input.
// Creates a decorator.
- Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
- *controller );
+ Text::DecoratorPtr decorator = Text::Decorator::New(*controller,
+ *controller);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Enables the text input.
- controller->EnableTextInput( decorator, inputMethodContext );
+ controller->EnableTextInput(decorator, inputMethodContext);
// Set the text
const std::string text("Hello World!");
controller->SetText(text);
- controller->SetInputFontPointSize( 1.0f );
+ controller->SetInputFontPointSize(1.0f);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ 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 ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN));
// change the input font point size
- controller->SetInputFontPointSize( 1.2f );
+ 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 );
+ 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( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
// For coverage
- controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN));
tet_result(TET_PASS);
ControllerPtr controller = Controller::New();
// Configures the text controller similarly to the text-field.
- ConfigureTextField( controller );
+ ConfigureTextField(controller);
// Set the text
const std::string text("Hello World!");
- controller->SetText( text );
+ controller->SetText(text);
// Select the whole text.
- controller->SelectEvent( 0.f, 0.f, SelectionType::INTERACTIVE );
+ controller->SelectEvent(0.f, 0.f, SelectionType::INTERACTIVE);
// Perform a relayout
- const Size size( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation(*controller.Get());
// Check if the whole text is selected or not.
std::string retrieved_text;
- mImpl.RetrieveSelection( retrieved_text, false );
- DALI_TEST_EQUALS( "Hello", retrieved_text, TEST_LOCATION );
+ mImpl.RetrieveSelection(retrieved_text, false);
+ DALI_TEST_EQUALS("Hello", retrieved_text, TEST_LOCATION);
// Select the whole text.
- controller->SelectEvent( 0.f, 0.f, SelectionType::ALL );
+ controller->SelectEvent(0.f, 0.f, SelectionType::ALL);
// Perform a relayout
- controller->Relayout( size );
+ controller->Relayout(size);
- mImpl.RetrieveSelection( retrieved_text, false );
- DALI_TEST_EQUALS( text, retrieved_text, TEST_LOCATION );
+ mImpl.RetrieveSelection(retrieved_text, false);
+ DALI_TEST_EQUALS(text, retrieved_text, TEST_LOCATION);
END_TEST;
}
-
int UtcDaliTextControllerRemoveTextChangeEventData(void)
{
tet_infoline(" UtcDaliTextControllerRemoveTextChangeEventData");
// Creates a text controller.
ControllerPtr controller = Controller::New();
- ConfigureTextField( controller );
+ ConfigureTextField(controller);
// Set the text
- const std::string text( "Hello World!" );
- controller->SetText( text );
- controller->SetInputFontPointSize( 1.0f );
+ 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() );
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation(*controller.Get());
- DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS(EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION);
// Send DELETE_SURROUNDING event
- InputMethodContext::EventData imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -1, 1 );
- InputMethodContext inputMethodContext = InputMethodContext::New();
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ InputMethodContext::EventData imfEvent = InputMethodContext::EventData(InputMethodContext::DELETE_SURROUNDING, "", -1, 1);
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Force to update the model.
controller->GetNaturalSize();
// Simulate a key event to delete text
- controller->KeyEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::DOWN));
- DALI_TEST_EQUALS( EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS(EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION);
// Perform a relayout
- const Size size( application.GetScene().GetSize() );
- controller->Relayout( size );
+ const Size size(application.GetScene().GetSize());
+ controller->Relayout(size);
tet_result(TET_PASS);
// Set the text
const std::string text("Hello World!");
- controller->SetText( text );
- controller->SetInputFontPointSize( 1.0f );
+ controller->SetText(text);
+ controller->SetInputFontPointSize(1.0f);
controller->KeyboardFocusGainEvent();
application.SendNotification();
application.Render();
// Perform a relayout
- const Size size( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
controller->Relayout(size);
// simulate a key event.
- controller->KeyEvent( GenerateKey( "a", "a", 38, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent(GenerateKey("a", "a", 38, 0, 0, Dali::KeyEvent::DOWN));
// change the input font point size
- controller->SetInputFontPointSize( 20.f );
+ controller->SetInputFontPointSize(20.f);
application.SendNotification();
application.Render();
// Creates a text controller.
ControllerPtr controller = Controller::New();
- ConfigureTextField( controller );
+ ConfigureTextField(controller);
// Get the implementation of the text controller
- Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation(*controller.Get());
- DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS(EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION);
InputMethodContext inputMethodContext = InputMethodContext::New();
// Add some pre-edit text, such as Korean
- InputMethodContext::EventData imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅂㅂㅂ", 0, 3 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ InputMethodContext::EventData imfEvent = InputMethodContext::EventData(InputMethodContext::PRE_EDIT, "ㅂㅂㅂ", 0, 3);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
// Perform a relayout
- const Size size( application.GetScene().GetSize() );
+ const Size size(application.GetScene().GetSize());
application.SendNotification();
application.Render();
- controller->Relayout( size );
+ controller->Relayout(size);
// Simulate a key event to delete one text
- controller->KeyEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent(GenerateKey("", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::DOWN));
// Send DELETE_SURROUNDING event (Delete All text)
- imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -2, 2 );
- controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+ imfEvent = InputMethodContext::EventData(InputMethodContext::DELETE_SURROUNDING, "", -2, 2);
+ controller->OnInputMethodContextEvent(inputMethodContext, imfEvent);
application.SendNotification();
application.Render();
- controller->Relayout( size );
+ controller->Relayout(size);
// simulate a key event to add text
- controller->KeyEvent( GenerateKey( "ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN ) );
- controller->KeyEvent( GenerateKey( "ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent(GenerateKey("ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN));
+ controller->KeyEvent(GenerateKey("ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN));
- DALI_TEST_EQUALS( EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS(EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION);
// Force to update the model.
controller->GetNaturalSize();
application.SendNotification();
application.Render();
- controller->Relayout( size );
+ controller->Relayout(size);
tet_result(TET_PASS);
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
*
*/
-#include <iostream>
#include <stdlib.h>
#include <unistd.h>
+#include <iostream>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
namespace
{
+const std::string DEFAULT_FONT_DIR("/resources/fonts");
-const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
-
-const Size CONTROL_SIZE( 200.f, 400.f );
-const Size CONTROL_SMALL_SIZE( 50.f, 100.f );
-const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+const Size CONTROL_SIZE(200.f, 400.f);
+const Size CONTROL_SMALL_SIZE(50.f, 100.f);
+const char* LOREM_IPSUM =
+ "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
"Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
"Ne nec nulla regione albucius, mea doctus delenit ad!\n"
"Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
"Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
"Asšúm sapěret usu ůť.\n"
"Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n";
-const Vector2 LOREM_SCROLL_POSITION( 0.f, -265.f );
-const Length LOREM_NUMBER_OF_LINES = 35u;
-const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
-const Length LOREM_NUMBER_OF_GLYPHS = 632;
-const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 393u;
+const Vector2 LOREM_SCROLL_POSITION(0.f, -265.f);
+const Length LOREM_NUMBER_OF_LINES = 35u;
+const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
+const Length LOREM_NUMBER_OF_GLYPHS = 632u;
+const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 393u;
+const Length LOREM_NUMBER_OF_CHARACTERS = 633u;
+const Length LOREM_NUMBER_OF_CHARACTERS_ELIDED = 633u;
// The expected layout size for UtcDaliTextViewModelGetLayoutSize
-const Size LAYOUT_SIZE( 181.f, 48.f );
+const Size LAYOUT_SIZE(181.f, 48.f);
// The expected color indices for UtcDaliTextViewModelGetColors
-const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u };
-const Length NUMBER_OF_COLORS = 3u;
-const Vector4 COLORS[] = { Color::RED, Color::BLUE, Color::GREEN };
+const ColorIndex COLOR_INDICES[] = {0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u};
+const Length NUMBER_OF_COLORS = 3u;
+const Vector4 COLORS[] = {Color::RED, Color::BLUE, Color::GREEN};
struct ElideData
{
float* positions;
};
-bool ElideTest( const ElideData& data )
+bool ElideTest(const ElideData& data)
{
std::cout << " testing : " << data.description << std::endl;
// Load some fonts.
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
- fontClient.SetDpi( 93u, 93u );
+ fontClient.SetDpi(93u, 93u);
- char* pathNamePtr = get_current_dir_name();
- const std::string pathName( pathNamePtr );
- free( pathNamePtr );
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName(pathNamePtr);
+ free(pathNamePtr);
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf");
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf");
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf");
// Creates a text controller.
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Sets a text and relais-out.
- controller->SetMarkupProcessorEnabled( true );
+ controller->SetMarkupProcessorEnabled(true);
- controller->SetText( data.text );
- controller->Relayout( data.size );
+ controller->SetText(data.text);
+ controller->Relayout(data.size);
// Elide the glyphs.
model->ElideGlyphs();
- if( data.numberOfLines != model->GetNumberOfLines() )
+ if(data.numberOfLines != model->GetNumberOfLines())
{
std::cout << " different number of lines : " << model->GetNumberOfLines() << ", expected : " << data.numberOfLines << std::endl;
return false;
}
- if( data.numberOfGlyphs != model->GetNumberOfGlyphs() )
+ if(data.numberOfGlyphs != model->GetNumberOfGlyphs())
{
std::cout << " different number of glyphs : " << model->GetNumberOfGlyphs() << ", expected : " << data.numberOfGlyphs << std::endl;
return false;
}
- const Vector2* const layoutBuffer = model->GetLayout();
- const Length numberOfLines = model->GetNumberOfLines();
+ const Vector2* const layoutBuffer = model->GetLayout();
+ const Length numberOfLines = model->GetNumberOfLines();
- if( numberOfLines != 0u )
+ if(numberOfLines != 0u)
{
- const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u );
- const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex;
+ const LineRun& lastLine = *(model->GetLines() + numberOfLines - 1u);
+ const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex;
std::cout << " last line alignment offset : " << floor(lastLine.alignmentOffset) << std::endl;
- for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index )
+ for(unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index)
{
- if( *( data.positions + index ) != floor(lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
+ if(*(data.positions + index) != floor(lastLine.alignmentOffset + (*(layoutBuffer + lastLine.glyphRun.glyphIndex + index)).x))
{
std::cout << " different layout :";
- for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+ for(unsigned int i = 0; i < numberOfLastLineGlyphs; ++i)
{
- std::cout << " " << floor( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
+ std::cout << " " << floor(lastLine.alignmentOffset + (*(layoutBuffer + lastLine.glyphRun.glyphIndex + i)).x);
}
std::cout << std::endl;
std::cout << " expected :";
- for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+ for(unsigned int i = 0; i < numberOfLastLineGlyphs; ++i)
{
- std::cout << " " << *( data.positions + i );
+ std::cout << " " << *(data.positions + i);
}
std::cout << std::endl;
return false;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// The text has not been laid-out. The stored control's size should be zero.
- DALI_TEST_EQUALS( Size::ZERO, model->GetControlSize(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Size::ZERO, model->GetControlSize(), TEST_LOCATION);
// Sets a text and relais-out.
- controller->SetText( "Hello world" );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText("Hello world");
+ controller->Relayout(CONTROL_SIZE);
// The control's size should be stored now.
- DALI_TEST_EQUALS( CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION );
+ DALI_TEST_EQUALS(CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
// Load some fonts.
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
- fontClient.SetDpi( 93u, 93u );
+ fontClient.SetDpi(93u, 93u);
- char* pathNamePtr = get_current_dir_name();
- const std::string pathName( pathNamePtr );
- free( pathNamePtr );
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName(pathNamePtr);
+ free(pathNamePtr);
- fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf");
// Creates a text controller.
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// The text has not been laid-out. The stored control's size should be zero.
- DALI_TEST_EQUALS( Size::ZERO, model->GetLayoutSize(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Size::ZERO, model->GetLayoutSize(), TEST_LOCATION);
// Sets a text and relais-out.
- controller->SetMarkupProcessorEnabled( true );
- controller->SetText( "<font family='TizenSansRegular' size='10'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>" );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetText("<font family='TizenSansRegular' size='10'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>");
+ controller->Relayout(CONTROL_SIZE);
// The control's size should be stored now.
- DALI_TEST_EQUALS( LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION );
+ DALI_TEST_EQUALS(LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// No text has been set. The scroll position should be zero.
- DALI_TEST_EQUALS( Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION);
// Gains the keyboard focus, sets a big text and relais-out.
controller->KeyboardFocusGainEvent();
- controller->SetText( LOREM_IPSUM );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
// The text should be scrolled to the end.
- DALI_TEST_EQUALS( LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION );
+ DALI_TEST_EQUALS(LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
- DALI_TEST_EQUALS( Text::HorizontalAlignment::BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION );
- DALI_TEST_EQUALS( Text::VerticalAlignment::TOP, model->GetVerticalAlignment(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Text::HorizontalAlignment::BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION);
+ DALI_TEST_EQUALS(Text::VerticalAlignment::TOP, model->GetVerticalAlignment(), TEST_LOCATION);
- controller->SetHorizontalAlignment( Text::HorizontalAlignment::CENTER );
- controller->SetVerticalAlignment( Text::VerticalAlignment::CENTER );
+ controller->SetHorizontalAlignment(Text::HorizontalAlignment::CENTER);
+ controller->SetVerticalAlignment(Text::VerticalAlignment::CENTER);
- DALI_TEST_EQUALS( Text::HorizontalAlignment::CENTER, model->GetHorizontalAlignment(), TEST_LOCATION );
- DALI_TEST_EQUALS( Text::VerticalAlignment::CENTER, model->GetVerticalAlignment(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Text::HorizontalAlignment::CENTER, model->GetHorizontalAlignment(), TEST_LOCATION);
+ DALI_TEST_EQUALS(Text::VerticalAlignment::CENTER, model->GetVerticalAlignment(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// Elide text should be disabled.
- DALI_TEST_CHECK( !model->IsTextElideEnabled() );
+ DALI_TEST_CHECK(!model->IsTextElideEnabled());
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Elide text should be enabled.
- DALI_TEST_CHECK( model->IsTextElideEnabled() );
+ DALI_TEST_CHECK(model->IsTextElideEnabled());
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextViewModelGetCharacters(void)
+{
+ tet_infoline(" UtcDaliTextViewModelGetLines");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(NULL != model);
+
+ // Configures the text controller similarly to the text-editor.
+ ConfigureTextEditor(controller);
+
+ // The number of characters should be zero.
+ DALI_TEST_EQUALS(0u, model->GetNumberOfCharacters(), TEST_LOCATION);
+
+ // Sets a text and relais-out.
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
+
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_CHARACTERS, model->GetNumberOfCharacters(), TEST_LOCATION);
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Relais-out for the text-label configuration.
+ controller->Relayout(Size(100.f, 100.f)); // Change the size to force a relayout.
+ controller->Relayout(CONTROL_SIZE);
+
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_CHARACTERS_ELIDED, model->GetNumberOfCharacters(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// The number of lines should be zero.
- DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL == model->GetLines() );
+ DALI_TEST_EQUALS(0u, model->GetNumberOfLines(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL == model->GetLines());
// Sets a text and relais-out.
- controller->SetText( LOREM_IPSUM );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL != model->GetLines() );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != model->GetLines());
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Relais-out for the text-label configuration.
- controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(Size(100.f, 100.f)); // Change the size to force a relayout.
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL != model->GetLines() );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != model->GetLines());
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// The number of glyphs should be zero.
- DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL == model->GetGlyphs() );
- DALI_TEST_CHECK( NULL == model->GetLayout() );
+ DALI_TEST_EQUALS(0u, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL == model->GetGlyphs());
+ DALI_TEST_CHECK(NULL == model->GetLayout());
// Sets a text and relais-out.
- controller->SetText( LOREM_IPSUM );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL != model->GetGlyphs() );
- DALI_TEST_CHECK( NULL != model->GetLayout() );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != model->GetGlyphs());
+ DALI_TEST_CHECK(NULL != model->GetLayout());
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Relais-out for the text-label configuration.
- controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
- controller->Relayout( CONTROL_SIZE );
+ controller->Relayout(Size(100.f, 100.f)); // Change the size to force a relayout.
+ controller->Relayout(CONTROL_SIZE);
// Elide the glyphs.
model->ElideGlyphs();
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL != model->GetGlyphs() );
- DALI_TEST_CHECK( NULL != model->GetLayout() );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL != model->GetGlyphs());
+ DALI_TEST_CHECK(NULL != model->GetLayout());
tet_result(TET_PASS);
END_TEST;
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Sets a text and relais-out.
- controller->SetMarkupProcessorEnabled( true );
- controller->SetText( "Lorem <color value='red'>ips<color value='blue'>um do</color>lor s<color value='green'>i</color>t a</color>met." );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetText("Lorem <color value='red'>ips<color value='blue'>um do</color>lor s<color value='green'>i</color>t a</color>met.");
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( Color::BLACK, model->GetDefaultColor(), TEST_LOCATION );
+ DALI_TEST_EQUALS(Color::BLACK, model->GetDefaultColor(), TEST_LOCATION);
const ColorIndex* const colorIndicesBuffer = model->GetColorIndices();
const Length numberOfGlyphs = model->GetNumberOfGlyphs();
- for( ColorIndex index = 0u; index < numberOfGlyphs; ++index )
+ for(ColorIndex index = 0u; index < numberOfGlyphs; ++index)
{
- DALI_TEST_EQUALS( COLOR_INDICES[index], *( colorIndicesBuffer + index ), TEST_LOCATION );
+ DALI_TEST_EQUALS(COLOR_INDICES[index], *(colorIndicesBuffer + index), TEST_LOCATION);
}
const Vector4* const colors = model->GetColors();
- for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index )
+ for(unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index)
{
- DALI_TEST_EQUALS( COLORS[index], *( colors + index ), TEST_LOCATION );
+ DALI_TEST_EQUALS(COLORS[index], *(colors + index), TEST_LOCATION);
}
tet_result(TET_PASS);
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
- DALI_TEST_CHECK( typesetter );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
ViewModel* model = typesetter->GetViewModel();
- DALI_TEST_CHECK( NULL != model );
+ DALI_TEST_CHECK(NULL != model);
// Configures the text controller similarly to the text-editor.
- ConfigureTextEditor( controller );
+ ConfigureTextEditor(controller);
// The number of glyphs should be zero.
- DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
- DALI_TEST_CHECK( NULL == model->GetGlyphs() );
- DALI_TEST_CHECK( NULL == model->GetLayout() );
+ DALI_TEST_EQUALS(0u, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(0u, model->GetNumberOfLines(), TEST_LOCATION);
+ DALI_TEST_CHECK(NULL == model->GetGlyphs());
+ DALI_TEST_CHECK(NULL == model->GetLayout());
// Sets a text and relais-out.
- controller->SetText( LOREM_IPSUM );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
// Keep the pointers to the glyphs and layout.
// As the text is not elided with this configuration, the pointers shoud be the same after calling the ElideGlyphs() method.
- const GlyphInfo* const glyphsModel = model->GetGlyphs();
- const Vector2* layoutsModel = model->GetLayout();
+ const GlyphInfo* const glyphsModel = model->GetGlyphs();
+ const Vector2* layoutsModel = model->GetLayout();
// Elide the glyphs. Text shouldn't be elided with this configuration.
model->ElideGlyphs();
- DALI_TEST_CHECK( glyphsModel == model->GetGlyphs() );
- DALI_TEST_CHECK( layoutsModel == model->GetLayout() );
+ DALI_TEST_CHECK(glyphsModel == model->GetGlyphs());
+ DALI_TEST_CHECK(layoutsModel == model->GetLayout());
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION);
// Configures the text controller similarly to the text-label.
- ConfigureTextLabel( controller );
+ ConfigureTextLabel(controller);
// Clear the text and relais-out.
- controller->SetText( "" );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText("");
+ controller->Relayout(CONTROL_SIZE);
- DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_EQUALS(0u, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(0u, model->GetNumberOfLines(), TEST_LOCATION);
// Elide the glyphs. Should not add the ellipsis glyph.
model->ElideGlyphs();
- DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+ DALI_TEST_EQUALS(0u, model->GetNumberOfGlyphs(), TEST_LOCATION);
// Sets a text that doesn't need to be elided.
- controller->SetText( "Hello\n" );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText("Hello\n");
+ controller->Relayout(CONTROL_SIZE);
// Elide the glyphs.
model->ElideGlyphs();
- DALI_TEST_EQUALS( 6u, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( 2u, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_EQUALS(6u, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(2u, model->GetNumberOfLines(), TEST_LOCATION);
// Sets a text and relais-out.
- controller->SetText( LOREM_IPSUM );
- controller->Relayout( CONTROL_SIZE );
+ controller->SetText(LOREM_IPSUM);
+ controller->Relayout(CONTROL_SIZE);
// Elide the glyphs.
model->ElideGlyphs();
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
- const GlyphInfo* const glyphs = model->GetGlyphs();
- const Vector2* layouts = model->GetLayout();
- DALI_TEST_CHECK( NULL != glyphs );
- DALI_TEST_CHECK( NULL != layouts );
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION);
+ const GlyphInfo* const glyphs = model->GetGlyphs();
+ const Vector2* layouts = model->GetLayout();
+ DALI_TEST_CHECK(NULL != glyphs);
+ DALI_TEST_CHECK(NULL != layouts);
// When the ellipsis is enabled, at least a glyph has to be rendered.
// Even if the given width is too narrow for rendering an ellipsis glyph.
- controller->SetText( "…" );
+ controller->SetText("…");
Vector3 sizeEllipsis = controller->GetNaturalSize();
- controller->SetText( "A" );
- Vector3 sizeA = controller->GetNaturalSize();
- float testWidth = sizeA.width < sizeEllipsis.width ? sizeA.width : sizeEllipsis.width - 1.0;
+ controller->SetText("A");
+ Vector3 sizeA = controller->GetNaturalSize();
+ float testWidth = sizeA.width < sizeEllipsis.width ? sizeA.width : sizeEllipsis.width - 1.0;
- controller->SetText( "AB" );
+ controller->SetText("AB");
Vector3 sizeAB = controller->GetNaturalSize();
- controller->Relayout( Size(testWidth, sizeAB.height) );
+ controller->Relayout(Size(testWidth, sizeAB.height));
// Elide the glyphs.
model->ElideGlyphs();
- DALI_TEST_EQUALS( 1u, model->GetNumberOfGlyphs(), TEST_LOCATION );
- DALI_TEST_EQUALS( 1u, model->GetNumberOfLines(), TEST_LOCATION );
+ DALI_TEST_EQUALS(1u, model->GetNumberOfGlyphs(), TEST_LOCATION);
+ DALI_TEST_EQUALS(1u, model->GetNumberOfLines(), TEST_LOCATION);
tet_result(TET_PASS);
END_TEST;
{
tet_infoline(" UtcDaliTextViewModelElideText02");
- Size textSize00( 100.f, 100.f );
+ Size textSize00(100.f, 100.f);
- Size textSize01( 80.f, 100.f );
- float positions01[] = { 0.f, 7.f, 16.f, 26.f, 33.f, 41.f, 45.f, 55.f, 64.0f };
+ Size textSize01(80.f, 100.f);
+ float positions01[] = {0.f, 7.f, 16.f, 26.f, 33.f, 41.f, 45.f, 55.f, 64.0f};
- Size textSize02( 80.f, 100.f );
- float positions02[] = { 68.f, 62.f, 58.f, 50.f, 46.f, 42.f, 32.f, 24.f, 5.f };
+ Size textSize02(80.f, 100.f);
+ float positions02[] = {68.f, 62.f, 58.f, 50.f, 46.f, 42.f, 32.f, 24.f, 5.f};
- Size textSize03( 80.f, 100.f );
- float positions03[] = { 78.f, 72.f, 66.f, 62.f, 57.f, 50.f, 45.f, 41.f, 39.f, 33.f, 30.f, 24.f, 5.0f };
+ Size textSize03(80.f, 100.f);
+ float positions03[] = {78.f, 72.f, 66.f, 62.f, 57.f, 50.f, 45.f, 41.f, 39.f, 33.f, 30.f, 24.f, 5.0f};
- Size textSize04( 80.f, 10.f );
- float positions04[] = { 1.f };
+ Size textSize04(80.f, 10.f);
+ float positions04[] = {1.f};
struct ElideData data[] =
- {
- {
- "void text",
- "",
- textSize00,
- 0u,
- 0u,
- NULL
- },
- {
- "Latin script",
- "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
- textSize01,
- 5u,
- 36u,
- positions01
- },
{
- "Hebrew script",
- "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
- textSize02,
- 5u,
- 44u,
- positions02
- },
- {
- "Arabic script",
- "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
- textSize03,
- 5u,
- 66u,
- positions03
- },
- {
- "Small control size, no line fits.",
- "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
- textSize04,
- 1u,
- 1u,
- positions04
- }
- };
+ {"void text",
+ "",
+ textSize00,
+ 0u,
+ 0u,
+ NULL},
+ {"Latin script",
+ "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+ textSize01,
+ 5u,
+ 36u,
+ positions01},
+ {"Hebrew script",
+ "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
+ textSize02,
+ 5u,
+ 44u,
+ positions02},
+ {"Arabic script",
+ "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
+ textSize03,
+ 5u,
+ 66u,
+ positions03},
+ {"Small control size, no line fits.",
+ "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+ textSize04,
+ 1u,
+ 1u,
+ positions04}};
const unsigned int numberOfTests = 5u;
- for( unsigned int index = 0u; index < numberOfTests; ++index )
+ for(unsigned int index = 0u; index < numberOfTests; ++index)
{
ToolkitTestApplication application;
- if( !ElideTest( data[index] ) )
+ if(!ElideTest(data[index]))
{
tet_result(TET_FAIL);
}