There is an issue with LineCount of TextLabel and TextEditor.
The issue is that if you set Text in TextLabel and do GetLineCount, an incorrect LineCount is returned.
This issue related to GetHeightForWidth which called in Controller::GetLineCount(float width).
Change-Id: Ia0cc5737432080fbd925bc6e655062f023a1c133
END_TEST;
}
+int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
+ //Set text longer than width of textEditor
+ textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
+ //Set line wrap mode Character
+ textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+
+ lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
+ lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ // When the text changed, the Line-count should be updated according to new text.
+ // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
+ DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
+ DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+
int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+
+int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextLabel textLabel = TextLabel::New();
+ //Set very large font-size using point-size
+ textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
+ //Set text longer than width of textLabel
+ textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
+ //Set line wrap mode Character
+ textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
+ textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
+
+ application.GetScene().Add( textLabel );
+
+ application.SendNotification();
+ application.Render();
+
+
+ lineCountBefore = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
+
+ textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
+ lineCountAfter = textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
+
+ // When the text changed, the Line-count should be updated according to new text.
+ // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
+ DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
+ DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
+
+
+ END_TEST;
+}
\ No newline at end of file
// The implementation of Get LineCount property depends on calling GetHeightForWidth then read mLines.Count() from visualModel direct.
// If the LineCount property is requested before rendering and layouting then the value will be zero, which is incorrect.
// So we will not restore the previously backed-up mLines and mGlyphPositions from visualModel in such case.
- bool restoreLinesAndGlyphPositions = visualModel->mControlSize.width>0 && visualModel->mControlSize.height>0;
+ // Another case to skip restore is when the requested width equals the Control's width which means the caller need to update the old values.
+ // For example, when the text is changed.
+ bool restoreLinesAndGlyphPositions = (visualModel->mControlSize.width>0 && visualModel->mControlSize.height>0)
+ && (visualModel->mControlSize.width != width);
layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask, restoreLinesAndGlyphPositions);