-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
#include <iostream>
//////////////////////////////////////////////////////////////////
-struct CalculateSubLineLayoutTest
+struct CalculateLineLayoutTest
{
std::string description;
- std::string inputLine;
+ std::string inputParagraph;
float parentWidth;
- std::size_t groupIndex;
std::size_t wordIndex;
std::size_t characterIndex;
+ std::size_t characterParagraphIndex;
TextViewRelayout::HorizontalWrapType splitPolicy;
float shrinkFactor;
float resultMaxAscender;
};
-bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
+bool TestCalculateLineLayout( const CalculateLineLayoutTest& test, const char* location )
{
tet_printf( "%s", test.description.c_str() );
// Create styled text.
MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( test.inputLine, inputStyledText, true );
+ MarkupProcessor::GetStyledTextArray( test.inputParagraph, inputStyledText, true );
// Create styled text layout info.
Toolkit::Internal::TextView::RelayoutData relayoutData;
// Prepare input parameters and the result structure and call the function to be tested.
// Creaqte indices.
- TextViewProcessor::TextInfoIndices indices( 0, test.groupIndex, test.wordIndex, test.characterIndex );
+ TextViewProcessor::TextInfoIndices indices( 0u, test.wordIndex, test.characterIndex );
+ indices.mCharacterParagraphIndex = test.characterParagraphIndex;
- // Get the input line.
- TextViewProcessor::LineLayoutInfo inputLineLayout;
+ // Get the input paragraph.
+ TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
+ if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
+ inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
}
// Result struct.
- TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
+ TextViewRelayout::LineLayoutInfo resultLayoutInfo;
- CalculateSubLineLayout( test.parentWidth,
- indices,
- inputLineLayout,
- test.splitPolicy,
- test.shrinkFactor,
- resultLayoutInfo );
+ CalculateLineLayout( test.parentWidth,
+ indices,
+ inputParagraphLayout,
+ test.splitPolicy,
+ test.shrinkFactor,
+ resultLayoutInfo );
// Check results.
if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
TextViewRelayout::RelayoutParameters relayoutParameters;
DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mLineSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mLineIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mGroupIndex, 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewLineCharacter );
+ DALI_TEST_CHECK( !relayoutParameters.mIsNewParagraphCharacter );
DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
- // Test SubLineLayoutInfo defaults
- TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
+ // Test LineLayoutInfo defaults
+ TextViewRelayout::LineLayoutInfo lineLayoutInfo;
- DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
END_TEST;
}
-int UtcDaliTextViewCalculateSubLineLayout(void)
+int UtcDaliTextViewCalculateLineLayout(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
+ tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
- struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
+ struct CalculateLineLayoutTest calculateLineLayoutTest[] =
{
//WrapByCharacter
{
- "The line is wraped by character. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by character. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
+ 0, // indices
0,
- 0, // indices
0,
TextViewRelayout::WrapByCharacter, // split policy
1.f,
10.242188f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes.",
- "Hello <font size='14'>world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes.",
+ "Hello <font size='14'>world</font>", // input paragraph
100.f, // parent width
- 0,
0, // indices
0,
+ 0,
TextViewRelayout::WrapByCharacter, // split policy
1.f,
// results
11.949220f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
+ "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
100.f, // parent width
- 0,
2, // indices. The third character of the third word starts in a new line.
2,
+ 8,
TextViewRelayout::WrapByCharacter, // split policy
1.f,
// results
10.242188f // max ascender
},
{
- "The line is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
+ "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
+ "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
100.f, // parent width
- 0,
4, // indices. The fifth character of the fifth word starts in a new line.
4,
+ 16,
TextViewRelayout::WrapByCharacter, // split policy
1.f,
// results
//WrapByWord
{
- "The line is wraped by word. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by word. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
- 0,
0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
9999999,
+ 9999999,
TextViewRelayout::WrapByWord, // split policy
1.f,
// results
10.242188f // max ascender
},
{
- "The line is wraped by word. There are characters with different sizes.",
- "Hell<font size='14'>o</font> world", // input line
+ "The paragraph is wraped by word. There are characters with different sizes.",
+ "Hell<font size='14'>o</font> world", // input paragraph
100.f, // parent width
- 0,
0, // indices.
0,
+ 0,
TextViewRelayout::WrapByWord, // split policy
1.f,
// results
11.949220f // max ascender
},
{
- "The line is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input line
+ "The paragraph is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
+ "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input paragraph
100.f, // parent width
- 0,
2, // indices. The third word starts in a new line.
0,
+ 6,
TextViewRelayout::WrapByWord, // split policy
1.f,
// results
11.949220f // max ascender
},
{
- "The line is wraped by word. The word doen't fit.",
- "Hello world", // input line
+ "The paragraph is wraped by word. The word doen't fit.",
+ "Hello world", // input paragraph
40.f, // parent width
- 0,
0, // indices. The third word starts in a new line.
0,
+ 0,
TextViewRelayout::WrapByWord, // split policy
1.f,
// results
//WrapByWordAndSplit
{
- "The line is wraped by word and by character. All characters have the same size. There is not a long word.",
- "Hello world hello world", // input line
+ "The paragraph is wraped by word and by character. All characters have the same size. There is not a long word.",
+ "Hello world hello world", // input paragraph
100.f, // parent width
- 0,
0, // indices.
0,
+ 0,
TextViewRelayout::WrapByWordAndSplit, // split policy
1.f,
// results
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. All characters have the same size. There is a long word.",
- "Helloooooooo world", // input line
+ "The paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
+ "Helloooooooo world", // input paragraph
100.f, // parent width
- 0,
0, // indices.
0,
+ 0,
TextViewRelayout::WrapByWordAndSplit, // split policy
1.f,
// results
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
- "Helloooooooo <font size='14'>world</font>", // input line
+ "The paragraph is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
+ "Helloooooooo <font size='14'>world</font>", // input paragraph
100.f, // parent width
- 0,
0, // indices.
8,
+ 8,
TextViewRelayout::WrapByWordAndSplit, // split policy
1.f,
// results
10.242188f // max ascender
},
{
- "The line is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
- "Helloooooooo<font size='14'> world</font>", // input line
+ "The paragraph is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
+ "Helloooooooo<font size='14'> world</font>", // input paragraph
100.f, // parent width
- 0,
0, // indices.
8,
+ 8,
TextViewRelayout::WrapByWordAndSplit, // split policy
0.7f,
// results
7.169531f // max ascender
},
- //WrapByLineAndSplit
+ //WrapByParagraphCharacterAndSplit
{
- "The line is wraped by end of line and by character. All characters have the same size.",
- "Hello world", // input line
+ "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
+ "Hello world", // input paragraph
100.f, // parent width
- 0,
0, // indices
0,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ 0,
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
91.041672f, // line length. (only fits 8 characters 8x11.38)
10.242188f // max ascender
},
{
- "The line fits in the width.",
- "Hello", // input line
+ "The paragraph fits in the width.",
+ "Hello", // input paragraph
100.f, // parent width
- 0,
0, // indices
0,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ 0,
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
56.901047f, // line length. (only fits 5 characters 5x11.38)
10.242188f // max ascender
},
{
- "The line is wraped by end of line and by character. All characters have the same size. It calculates the layout for the second line.",
- "Hello world, hello world", // input line
+ "The paragraph is wraped by end of paragraph and by character. All characters have the same size. It calculates the layout for the second line.",
+ "Hello world, hello world", // input paragraph
100.f, // parent width
- 0,
2, // indices
2,
- TextViewRelayout::WrapByLineAndSplit, // split policy
+ 8,
+ TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
1.f,
// results
91.041672f, // line length. (only fits 8 characters 8x11.38)
for( std::size_t index = 0; index < numberOfTests; ++index )
{
- const CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
+ const CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
- if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
+ if( !TestCalculateLineLayout( test, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
assert1 = true;
}
catch( ... )
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
assert2 = true;
}
catch( ... )