END_TEST;
}
+
+
+int UtcDaliTextControllerMaxLengthSetText(void)
+{
+ tet_infoline(" UtcDaliTextControllerMaxLengthSetText");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ const Length MAX_TEXT_LENGTH = 1024u * 32u;
+
+ // make over length world
+ int maxLength = (1024u * 32u) + 10u;
+ char world[maxLength];
+ for( int i = 0; i < maxLength; i++ )
+ {
+ world[i] = 'a';
+ }
+
+ // Set the text
+ std::string text(world);
+ controller->SetText( text );
+
+ // Perform a relayout
+ const Size size( Dali::Stage::GetCurrent().GetSize() );
+ controller->Relayout(size);
+
+ // check text length
+ controller->GetText( text );
+ Length textSize = text.size();
+
+ DALI_TEST_EQUALS( MAX_TEXT_LENGTH, textSize, TEST_LOCATION );
+
+ END_TEST;
+}
const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
+const unsigned int MAX_TEXT_LENGTH = 1024u * 32u;
float ConvertToEven( float value )
{
void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
{
- mImpl->mMaximumNumberOfCharacters = maxCharacters;
+ mImpl->mMaximumNumberOfCharacters = std::min( maxCharacters, MAX_TEXT_LENGTH );
}
int Controller::GetMaximumNumberOfCharacters()
utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
}
+ // Limit the text size. If the text size is too large, crash or deadlock will occur.
+ if( textSize > MAX_TEXT_LENGTH )
+ {
+ DALI_LOG_WARNING( "The text size is too large(%d), limit the length to 32,768u\n", textSize );
+ textSize = MAX_TEXT_LENGTH;
+ }
+
// Convert text into UTF-32
Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
utf32Characters.Resize( textSize );