X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextView.cpp;h=91dcc57e2b312d7a2bafbe56ba89e2973efb89ed;hp=4044c820ed67258f8b01e094b6d4097c0a1a25f2;hb=966b18f7fa3989309dbf22d38cbc7750785f8333;hpb=64485a966f60d59a33610e3439703dc7e7c19c32 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp index 4044c82..91dcc57 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp @@ -24,7 +24,7 @@ // Internal headers are allowed here #include #include -#include +#include #include #include @@ -60,12 +60,13 @@ struct SplitWordTest std::string lastResult; }; -struct SplitLineTest +struct SplitParagraphTest { std::string description; std::string input; std::size_t wordIndex; std::size_t characterIndex; + std::size_t characterParagraphIndex; float lineHeightOffset; std::string firstResult; std::string lastResult; @@ -79,7 +80,7 @@ struct MergeWordsTest std::string result; }; -struct MergeLinesTest +struct MergeParagraphsTest { std::string description; std::string inputFirst; @@ -97,7 +98,7 @@ struct RemoveCharactersFromWordTest std::string result; }; -struct RemoveWordsFromLineTest +struct RemoveWordsFromParagraphTest { std::string description; std::string input; @@ -130,22 +131,17 @@ struct UpdateTextInfoTest void Print( const TextViewProcessor::CharacterLayoutInfo& character ) { - std::cout << " height : " << character.mHeight << std::endl; - std::cout << " advance : " << character.mAdvance << std::endl; + std::cout << " height : " << character.mSize.height << std::endl; + std::cout << " advance : " << character.mSize.width << std::endl; std::cout << " bearing : " << character.mBearing << std::endl; - std::cout << " mPosition : " << character.mPosition << std::endl; - std::cout << " mSize : " << character.mSize << std::endl; - std::cout << " mAscender : " << character.mAscender << std::endl; + std::cout << " ascender : " << character.mAscender << std::endl; + std::cout << " position : " << character.mPosition << std::endl; TextActor textActor = TextActor::DownCast( character.mGlyphActor ); if( textActor ) { std::cout << "[" << textActor.GetText() << "]"; } - else - { - std::cout << "{" << character.mStyledText.mText.GetText() << "}"; - } } void Print( const TextViewProcessor::WordLayoutInfo& word ) @@ -164,13 +160,13 @@ void Print( const TextViewProcessor::WordLayoutInfo& word ) std::cout << "]"; std::cout << std::endl; } -void Print( const TextViewProcessor::LineLayoutInfo& line ) +void Print( const TextViewProcessor::ParagraphLayoutInfo& paragraph ) { std::cout << "<"; - std::cout << " mSize : " << line.mSize << std::endl; - std::cout << " mAscender : " << line.mAscender << std::endl; - std::cout << "mNumberOfCharacters : " << line.mNumberOfCharacters << std::endl; - for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = line.mWordsLayoutInfo.begin(), endIt = line.mWordsLayoutInfo.end(); it != endIt; ++it ) + std::cout << " mSize : " << paragraph.mSize << std::endl; + std::cout << " mAscender : " << paragraph.mAscender << std::endl; + std::cout << "mNumberOfCharacters : " << paragraph.mNumberOfCharacters << std::endl; + for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it ) { Print( *it ); } @@ -180,37 +176,29 @@ void Print( const TextViewProcessor::LineLayoutInfo& line ) void Print( const TextViewProcessor::TextLayoutInfo& text ) { std::cout << "||"; - for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it = text.mLinesLayoutInfo.begin(), endIt = text.mLinesLayoutInfo.end(); it != endIt; ++it ) + for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it = text.mParagraphsLayoutInfo.begin(), endIt = text.mParagraphsLayoutInfo.end(); it != endIt; ++it ) { Print( *it ); } std::cout << "||" << std::endl; } -std::string GetText( const TextViewProcessor::CharacterLayoutInfo& character ) -{ - return character.mStyledText.mText.GetText(); -} - -std::string GetText( const TextViewProcessor::WordLayoutInfo& word ) +std::string GetText( const TextViewProcessor::WordLayoutInfo& word, const Text& paragraphText ) { - std::string text; + Text text; - for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it ) - { - text += GetText( *it ); - } + paragraphText.GetSubText( word.mFirstCharacter, word.mFirstCharacter + word.mCharactersLayoutInfo.size() - 1u, text ); - return text; + return text.GetText(); } -std::string GetText( const TextViewProcessor::LineLayoutInfo& line ) +std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph ) { std::string text; - for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = line.mWordsLayoutInfo.begin(), endIt = line.mWordsLayoutInfo.end(); it != endIt; ++it ) + for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it ) { - text += GetText( *it ); + text += GetText( *it, paragraph.mText ); } return text; @@ -226,11 +214,11 @@ bool TestEqual( float x, float y ) bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1, const TextViewProcessor::CharacterLayoutInfo& character2 ) { - if( !TestEqual( character1.mHeight, character2.mHeight ) ) + if( !TestEqual( character1.mSize.height, character2.mSize.height ) ) { return false; } - if( !TestEqual( character1.mAdvance, character2.mAdvance ) ) + if( !TestEqual( character1.mSize.width, character2.mSize.width ) ) { return false; } @@ -248,15 +236,6 @@ bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1, return false; } - if( !TestEqual( character1.mSize.x, character2.mSize.x ) ) - { - return false; - } - if( !TestEqual( character1.mSize.y, character2.mSize.y ) ) - { - return false; - } - if( !TestEqual( character1.mAscender, character2.mAscender ) ) { return false; @@ -298,27 +277,6 @@ bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1, return false; } - text1 = character1.mStyledText.mText.GetText(); - style1 = character1.mStyledText.mStyle; - - text2 = character2.mStyledText.mText.GetText(); - style2 = character2.mStyledText.mStyle; - - if( text1 != text2 ) - { - return false; - } - - if( style1 != style2 ) - { - std::cout << " style1 : " << std::endl; - TextViewProcessor::dbgPrint( style1 ); - - std::cout << " style2 : " << std::endl; - TextViewProcessor::dbgPrint( style2 ); - return false; - } - return true; } @@ -363,35 +321,35 @@ bool TestEqual( const TextViewProcessor::WordLayoutInfo& word1, return true; } -bool TestEqual( const TextViewProcessor::LineLayoutInfo& line1, - const TextViewProcessor::LineLayoutInfo& line2 ) +bool TestEqual( const TextViewProcessor::ParagraphLayoutInfo& paragraph1, + const TextViewProcessor::ParagraphLayoutInfo& paragraph2 ) { - if( !TestEqual( line1.mSize.x, line2.mSize.x ) ) + if( !TestEqual( paragraph1.mSize.x, paragraph2.mSize.x ) ) { return false; } - if( !TestEqual( line1.mSize.y, line2.mSize.y ) ) + if( !TestEqual( paragraph1.mSize.y, paragraph2.mSize.y ) ) { return false; } - if( !TestEqual( line1.mAscender, line2.mAscender ) ) + if( !TestEqual( paragraph1.mAscender, paragraph2.mAscender ) ) { return false; } - if( line1.mNumberOfCharacters != line2.mNumberOfCharacters ) + if( paragraph1.mNumberOfCharacters != paragraph2.mNumberOfCharacters ) { return false; } - if( line1.mWordsLayoutInfo.size() != line2.mWordsLayoutInfo.size() ) + if( paragraph1.mWordsLayoutInfo.size() != paragraph2.mWordsLayoutInfo.size() ) { return false; } - for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = line1.mWordsLayoutInfo.begin(), endIt1 = line1.mWordsLayoutInfo.end(), - it2 = line2.mWordsLayoutInfo.begin(), endIt2 = line2.mWordsLayoutInfo.end(); + for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = paragraph1.mWordsLayoutInfo.begin(), endIt1 = paragraph1.mWordsLayoutInfo.end(), + it2 = paragraph2.mWordsLayoutInfo.begin(), endIt2 = paragraph2.mWordsLayoutInfo.end(); ( it1 != endIt1 ) && ( it2 != endIt2 ); ++it1, ++it2 ) { @@ -426,13 +384,13 @@ bool TestEqual( const TextViewProcessor::TextLayoutInfo& text1, return false; } - if( text1.mLinesLayoutInfo.size() != text2.mLinesLayoutInfo.size() ) + if( text1.mParagraphsLayoutInfo.size() != text2.mParagraphsLayoutInfo.size() ) { return false; } - for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it1 = text1.mLinesLayoutInfo.begin(), endIt1 = text1.mLinesLayoutInfo.end(), - it2 = text2.mLinesLayoutInfo.begin(), endIt2 = text2.mLinesLayoutInfo.end(); + for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it1 = text1.mParagraphsLayoutInfo.begin(), endIt1 = text1.mParagraphsLayoutInfo.end(), + it2 = text2.mParagraphsLayoutInfo.begin(), endIt2 = text2.mParagraphsLayoutInfo.end(); ( it1 != endIt1 ) && ( it2 != endIt2 ); ++it1, ++it2 ) { @@ -477,12 +435,12 @@ bool TestSplitWord( const std::string& description, const std::string& input, co // Get the input word TextViewProcessor::WordLayoutInfo inputWordLayout; - if( !inputLayout.mLinesLayoutInfo.empty() ) + if( !inputLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - inputWordLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -501,12 +459,12 @@ bool TestSplitWord( const std::string& description, const std::string& input, co // Get the first result word TextViewProcessor::WordLayoutInfo firstResultWordLayout; - if( !firstResultLayout.mLinesLayoutInfo.empty() ) + if( !firstResultLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *firstResultLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - firstResultWordLayout = *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + firstResultWordLayout = *( *firstResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -525,12 +483,12 @@ bool TestSplitWord( const std::string& description, const std::string& input, co // Get the last result word TextViewProcessor::WordLayoutInfo lastResultWordLayout; - if( !lastResultLayout.mLinesLayoutInfo.empty() ) + if( !lastResultLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *lastResultLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - lastResultWordLayout = *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + lastResultWordLayout = *( *lastResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -559,33 +517,35 @@ bool TestSplitWord( const std::string& description, const std::string& input, co } /** - * Splits the \e input line in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult. + * Splits the \e input paragraph in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult. * * If the test fails it prints a short description and the line where this function was called. * - * @param description Short description of the experiment. i.e. "Split the line from the beginning. (wordIndex 0 and characterIndex 0)". + * @param description Short description of the experiment. i.e. "Split the paragraph from the beginning. (wordIndex 0 and characterIndex 0)". * @param input The input word. - * @param wordIndex Index to the word within the line where to split it. + * @param wordIndex Index to the word within the paragraph where to split it. * @param characterIndex Where to split the word. + * @param characterIndex Character index within the paragraph. * @param lineHeightOffset Offset between lines. - * @param firstResult First part of the split line. - * @param lastResult Last part of the split line. + * @param firstResult First part of the split paragraph. + * @param lastResult Last part of the split paragraph. * @param location Where this function has been called. * * @return \e true if the experiment is successful. Otherwise returns \e false. */ -bool TestSplitLine( const std::string& description, - const std::string& input, - const size_t wordIndex, - const size_t characterIndex, - const float lineHeightOffset, - const std::string& firstResult, - const std::string& lastResult, - const char* location ) +bool TestSplitParagraph( const std::string& description, + const std::string& input, + size_t wordIndex, + size_t characterIndex, + size_t characterParagraphIndex, + float lineHeightOffset, + const std::string& firstResult, + const std::string& lastResult, + const char* location ) { tet_printf( "%s\n", description.c_str() ); - // Create layout info for the input line. + // Create layout info for the input paragraph. Toolkit::Internal::TextView::RelayoutData relayoutData; TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo ); @@ -599,19 +559,18 @@ bool TestSplitLine( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); - // Get the input line - TextViewProcessor::LineLayoutInfo inputLineLayout; + // Get the input paragraph + TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout; - if( !inputLayout.mLinesLayoutInfo.empty() ) + if( !inputLayout.mParagraphsLayoutInfo.empty() ) { - inputLineLayout = *inputLayout.mLinesLayoutInfo.begin(); + inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin(); } - // Create layout info for the first part of the result (after split the line) + // Create layout info for the first part of the result (after split the paragraph) Toolkit::Internal::TextView::RelayoutData firstRelayoutData; TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo ); @@ -626,19 +585,18 @@ bool TestSplitLine( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), firstRelayoutData ); - // Get the first result line - TextViewProcessor::LineLayoutInfo firstResultLineLayout; + // Get the first result paragraph + TextViewProcessor::ParagraphLayoutInfo firstResultParagraphLayout; - if( !firstResultLayout.mLinesLayoutInfo.empty() ) + if( !firstResultLayout.mParagraphsLayoutInfo.empty() ) { - firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin(); + firstResultParagraphLayout = *firstResultLayout.mParagraphsLayoutInfo.begin(); } - // Create layout info for the last part of the result (after split the line) + // Create layout info for the last part of the result (after split the paragraph) Toolkit::Internal::TextView::RelayoutData lastRelayoutData; TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo ); @@ -653,37 +611,37 @@ bool TestSplitLine( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..."), true ), lastRelayoutData ); - // Get the last result line - TextViewProcessor::LineLayoutInfo lastResultLineLayout; + // Get the last result paragraph + TextViewProcessor::ParagraphLayoutInfo lastResultParagraphLayout; - if( !lastResultLayout.mLinesLayoutInfo.empty() ) + if( !lastResultLayout.mParagraphsLayoutInfo.empty() ) { - lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin(); + lastResultParagraphLayout = *lastResultLayout.mParagraphsLayoutInfo.begin(); } - // Split the line. + // Split the paragraph. - TextViewProcessor::LineLayoutInfo lastLineLayoutInfo; + TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo; TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex ); + indices.mCharacterParagraphIndex = characterParagraphIndex; - SplitLine( indices, - PointSize( lineHeightOffset ), - inputLineLayout, - lastLineLayoutInfo ); + SplitParagraph( indices, + PointSize( lineHeightOffset ), + inputParagraphLayout, + lastParagraphLayoutInfo ); // Test results - if( !TestEqual( inputLineLayout, firstResultLineLayout ) ) + if( !TestEqual( inputParagraphLayout, firstResultParagraphLayout ) ) { tet_printf( "Fail. different first layout info. %s\n", location ); return false; } - if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) ) + if( !TestEqual( lastParagraphLayoutInfo, lastResultParagraphLayout ) ) { tet_printf( "Fail. different last layout info. %s\n", location ); return false; @@ -723,12 +681,12 @@ bool TestMergeWords( const std::string& description, const std::string& inputFir // Get the input word TextViewProcessor::WordLayoutInfo inputFirstWordLayout; - if( !inputFirstLayout.mLinesLayoutInfo.empty() ) + if( !inputFirstLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputFirstLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - inputFirstWordLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + inputFirstWordLayout = *( *inputFirstLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -746,12 +704,12 @@ bool TestMergeWords( const std::string& description, const std::string& inputFir // Get the input word TextViewProcessor::WordLayoutInfo inputLastWordLayout; - if( !inputLastLayout.mLinesLayoutInfo.empty() ) + if( !inputLastLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLastLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - inputLastWordLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + inputLastWordLayout = *( *inputLastLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -769,12 +727,12 @@ bool TestMergeWords( const std::string& description, const std::string& inputFir // Get the result word TextViewProcessor::WordLayoutInfo resultWordLayout; - if( !resultLayout.mLinesLayoutInfo.empty() ) + if( !resultLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - resultWordLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -791,24 +749,24 @@ bool TestMergeWords( const std::string& description, const std::string& inputFir } /** - * Merges the \e inputFirst line and the \e inputLast line, and checks the results with \e result. + * Merges the \e inputFirst paragraph and the \e inputLast paragraph, and checks the results with \e result. * * If the test fails it prints a short description and the line where this function was called. * * @param description Short description of the experiment. - * @param inputFirst The first part of the line. - * @param inputLast The last part of the line. + * @param inputFirst The first part of the paragraph. + * @param inputLast The last part of the paragraph. * @param lineHeightOffset Offset between lines. - * @param result The merged line. + * @param result The merged paragraph. * @param location Where this function has been called. * * @return \e true if the experiment is successful. Otherwise returns \e false. */ -bool TestMergeLines( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location ) +bool TestMergeParagraphs( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location ) { tet_printf( "%s\n", description.c_str() ); - // Create layout info for the inputFirst line. + // Create layout info for the inputFirst paragraph. Toolkit::Internal::TextView::RelayoutData firstRelayoutData; TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo ); @@ -822,19 +780,18 @@ bool TestMergeLines( const std::string& description, const std::string& inputFir static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), firstRelayoutData ); // Get the input word - TextViewProcessor::LineLayoutInfo inputFirstLineLayout; + TextViewProcessor::ParagraphLayoutInfo inputFirstParagraphLayout; - if( !inputFirstLayout.mLinesLayoutInfo.empty() ) + if( !inputFirstLayout.mParagraphsLayoutInfo.empty() ) { - inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin(); + inputFirstParagraphLayout = *inputFirstLayout.mParagraphsLayoutInfo.begin(); } - // Create layout info for the inputLast line. + // Create layout info for the inputLast paragraph. Toolkit::Internal::TextView::RelayoutData lastRelayoutData; TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo ); @@ -848,16 +805,15 @@ bool TestMergeLines( const std::string& description, const std::string& inputFir static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), lastRelayoutData ); // Get the input word - TextViewProcessor::LineLayoutInfo inputLastLineLayout; + TextViewProcessor::ParagraphLayoutInfo inputLastParagraphLayout; - if( !inputLastLayout.mLinesLayoutInfo.empty() ) + if( !inputLastLayout.mParagraphsLayoutInfo.empty() ) { - inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.begin(); + inputLastParagraphLayout = *inputLastLayout.mParagraphsLayoutInfo.begin(); } // Create layout info for the result word. @@ -874,22 +830,21 @@ bool TestMergeLines( const std::string& description, const std::string& inputFir static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); // Get the result word - TextViewProcessor::LineLayoutInfo resultLineLayout; + TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout; - if( !resultLayout.mLinesLayoutInfo.empty() ) + if( !resultLayout.mParagraphsLayoutInfo.empty() ) { - resultLineLayout = *resultLayout.mLinesLayoutInfo.begin(); + resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin(); } - MergeLine( inputFirstLineLayout, - inputLastLineLayout ); + MergeParagraph( inputFirstParagraphLayout, + inputLastParagraphLayout ); - if( !TestEqual( inputFirstLineLayout, resultLineLayout ) ) + if( !TestEqual( inputFirstParagraphLayout, resultParagraphLayout ) ) { tet_printf( "Fail. different layout info. %s\n", location ); return false; @@ -930,12 +885,12 @@ bool TestRemoveCharactersFromWord( const std::string& description, const std::st // Get the input word TextViewProcessor::WordLayoutInfo inputWordLayout; - if( !inputLayout.mLinesLayoutInfo.empty() ) + if( !inputLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - inputWordLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -953,12 +908,12 @@ bool TestRemoveCharactersFromWord( const std::string& description, const std::st // Get the result word TextViewProcessor::WordLayoutInfo resultWordLayout; - if( !resultLayout.mLinesLayoutInfo.empty() ) + if( !resultLayout.mParagraphsLayoutInfo.empty() ) { - const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() ); - if( !line.mWordsLayoutInfo.empty() ) + const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() ); + if( !paragraph.mWordsLayoutInfo.empty() ) { - resultWordLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); } } @@ -976,25 +931,25 @@ bool TestRemoveCharactersFromWord( const std::string& description, const std::st } /** - * Removes from the \e input line the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result. + * Removes from the \e input paragraph the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result. * * If the test fails it prints a short description and the line where this function was called. * * @param description Short description of the experiment. - * @param input The input line. - * @param wordIndex Index within the line where to start to remove words. + * @param input The input paragraph. + * @param wordIndex Index within the paragraph where to start to remove words. * @param numberOfWords The number of words to remove. * @param lineHeightOffset Offset between lines. - * @param result The line without the removed words. + * @param result The paragraph without the removed words. * @param location Where this function has been called. * * @return \e true if the experiment is successful. Otherwise returns \e false. */ -bool TestRemoveWordsFromLine( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location ) +bool TestRemoveWordsFromParagraph( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location ) { tet_printf( "%s\n", description.c_str() ); - // Create layout info for the input line. + // Create layout info for the input paragraph. Toolkit::Internal::TextView::RelayoutData relayoutData; TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo ); @@ -1008,19 +963,18 @@ bool TestRemoveWordsFromLine( const std::string& description, const std::string& static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); - // Get the input line - TextViewProcessor::LineLayoutInfo inputLineLayout; + // Get the input paragraph + TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout; - if( !inputLayout.mLinesLayoutInfo.empty() ) + if( !inputLayout.mParagraphsLayoutInfo.empty() ) { - inputLineLayout = *inputLayout.mLinesLayoutInfo.begin(); + inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin(); } - // Create layout info for the result line. + // Create layout info for the result paragraph. Toolkit::Internal::TextView::RelayoutData resultRelayoutData; TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo ); @@ -1034,32 +988,31 @@ bool TestRemoveWordsFromLine( const std::string& description, const std::string& static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); - // Get the result line - TextViewProcessor::LineLayoutInfo resultLineLayout; + // Get the result paragraph + TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout; - if( !resultLayout.mLinesLayoutInfo.empty() ) + if( !resultLayout.mParagraphsLayoutInfo.empty() ) { - resultLineLayout = *resultLayout.mLinesLayoutInfo.begin(); + resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin(); } - RemoveWordsFromLine( wordIndex, - numberOfWords, - lineHeightOffset, - inputLineLayout ); + RemoveWordsFromParagraph( wordIndex, + numberOfWords, + lineHeightOffset, + inputParagraphLayout ); - if( !TestEqual( inputLineLayout, resultLineLayout ) ) + if( !TestEqual( inputParagraphLayout, resultParagraphLayout ) ) { tet_printf( "Fail. different layout info. %s\n", location ); tet_printf( " input : [%s]\n", input.c_str() ); - tet_printf( " result : [%s]\n", GetText( resultLineLayout ).c_str() ); + tet_printf( " result : [%s]\n", GetText( resultParagraphLayout ).c_str() ); tet_printf( " expected result : [%s]\n\n", result.c_str() ); - Print(inputLineLayout); std::cout << std::endl << std::endl; - Print(resultLineLayout); std::cout << std::endl; + Print(inputParagraphLayout); std::cout << std::endl << std::endl; + Print(resultParagraphLayout); std::cout << std::endl; return false; } @@ -1084,12 +1037,12 @@ bool TestRemoveWordsFromLine( const std::string& description, const std::string& * @return \e true if the experiment is successful. Otherwise returns \e false. */ bool TestUpdateTextInfo( const std::string& description, - const UpdateTextInfoOperation operation, + UpdateTextInfoOperation operation, const std::string& input, - const std::size_t position, - const std::size_t numberOfCharacters, + std::size_t position, + std::size_t numberOfCharacters, const std::string& inputText, - const float lineHeightOffset, + float lineHeightOffset, const std::string& result, const char* location ) { @@ -1109,7 +1062,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); @@ -1127,7 +1079,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); @@ -1138,7 +1089,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ); switch( operation ) @@ -1223,13 +1173,11 @@ int UtcDaliTextViewCreateTextInfo(void) // bearing : 11.9492 // ascender : 11.9492 - const float WIDTH_10( 9.48351f ); const float HEIGHT_10( 9.48351f ); const float ADVANCE_10( 9.48351f ); const float BEARING_10( 8.53516f ); const float ASCENDER_10( 8.53516f ); - const float WIDTH_12( 11.3802f ); const float HEIGHT_12( 11.3802f ); const float ADVANCE_12( 11.3802f ); const float BEARING_12( 10.2422f ); @@ -1256,107 +1204,83 @@ int UtcDaliTextViewCreateTextInfo(void) // Characters TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo]) - layoutInfo10.mHeight = HEIGHT_10; - layoutInfo10.mAdvance = ADVANCE_10; + layoutInfo10.mSize.height = HEIGHT_10; + layoutInfo10.mSize.width = ADVANCE_10; layoutInfo10.mBearing = BEARING_10; - layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 ); layoutInfo10.mAscender = ASCENDER_10; TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR]) - layoutInfo12.mHeight = HEIGHT_12; - layoutInfo12.mAdvance = ADVANCE_12; + layoutInfo12.mSize.height = HEIGHT_12; + layoutInfo12.mSize.width = ADVANCE_12; layoutInfo12.mBearing = BEARING_12; - layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 ); layoutInfo12.mAscender = ASCENDER_12; - TextStyle style10; - style10.SetFontName( "" ); - style10.SetFontPointSize( PointSize( 10.f ) ); - TextStyle style12; - style12.SetFontName( "" ); - - layoutInfo12.mStyledText.mStyle = style12; - layoutInfo10.mStyledText.mStyle = style10; - // Words TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4; // Hello - wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 ); + wordLayout1.mSize = Size( 3.f * ADVANCE_12 + 2.f * ADVANCE_10, HEIGHT_12 ); wordLayout1.mAscender = ASCENDER_12; wordLayout1.mType = TextViewProcessor::NoSeparator; - layoutInfo12.mStyledText.mText = Text( "H" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H - layoutInfo12.mStyledText.mText = Text( "e" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e - layoutInfo12.mStyledText.mText = Text( "l" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l - layoutInfo10.mStyledText.mText = Text( "l" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l - layoutInfo10.mStyledText.mText = Text( "o" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o // (white space) - wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 ); + wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 ); wordLayout2.mAscender = ASCENDER_10; wordLayout2.mType = TextViewProcessor::WordSeparator; - layoutInfo10.mStyledText.mText = Text( " " ); wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space) // world! - wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 ); + wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 ); wordLayout3.mAscender = ASCENDER_12; wordLayout3.mType = TextViewProcessor::NoSeparator; - layoutInfo10.mStyledText.mText = Text( "w" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w - layoutInfo10.mStyledText.mText = Text( "o" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o - layoutInfo12.mStyledText.mText = Text( "r" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r - layoutInfo12.mStyledText.mText = Text( "l" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l - layoutInfo12.mStyledText.mText = Text( "d" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d - layoutInfo12.mStyledText.mText = Text( "!" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // ! - // (new line character) + // (new paragraph character) wordLayout4.mSize = Size( 0.f, HEIGHT_12 ); wordLayout4.mAscender = ASCENDER_12; - wordLayout4.mType = TextViewProcessor::LineSeparator; - layoutInfo12.mStyledText.mText = Text( "\n" ); + wordLayout4.mType = TextViewProcessor::ParagraphSeparator; layoutInfo12.mSize.width = 0.f; - wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char) + wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char) - // Lines + // Paragraphs - TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3; + TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3; - lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 ); - lineLayout1.mAscender = ASCENDER_12; - lineLayout1.mNumberOfCharacters = 13; - lineLayout1.mWordsLayoutInfo.push_back( wordLayout1 ); - lineLayout1.mWordsLayoutInfo.push_back( wordLayout2 ); - lineLayout1.mWordsLayoutInfo.push_back( wordLayout3 ); - lineLayout1.mWordsLayoutInfo.push_back( wordLayout4 ); + paragraphLayout1.mSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, HEIGHT_12 ); + paragraphLayout1.mAscender = ASCENDER_12; + paragraphLayout1.mNumberOfCharacters = 13; + paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 ); + paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout2 ); + paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout3 ); + paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout4 ); - lineLayout2.mSize = Size( 0.f, HEIGHT_12 ); - lineLayout2.mAscender = ASCENDER_12; - lineLayout2.mNumberOfCharacters = 1; - lineLayout2.mWordsLayoutInfo.push_back( wordLayout4 ); + paragraphLayout2.mSize = Size( 0.f, HEIGHT_12 ); + paragraphLayout2.mAscender = ASCENDER_12; + paragraphLayout2.mNumberOfCharacters = 1; + paragraphLayout2.mWordsLayoutInfo.push_back( wordLayout4 ); - lineLayout3.mSize = Size( 0.f, HEIGHT_12 ); + paragraphLayout3.mSize = Size( 0.f, HEIGHT_12 ); // Text (layout) TextViewProcessor::TextLayoutInfo textLayout; - textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 ); - textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12; + textLayout.mWholeTextSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, 3.f * HEIGHT_12 ); + textLayout.mMaxWordWidth = 2.f * ADVANCE_10 + 4.f * ADVANCE_12; textLayout.mNumberOfCharacters = 14; - textLayout.mLinesLayoutInfo.push_back( lineLayout1 ); - textLayout.mLinesLayoutInfo.push_back( lineLayout2 ); - textLayout.mLinesLayoutInfo.push_back( lineLayout3 ); + textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 ); + textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 ); + textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout3 ); if(!TestEqual( textLayout, textLayoutInfo )) { @@ -1413,9 +1337,9 @@ int UtcDaliTextViewSplitWord(void) std::string( "oooo" ), }, }; - const std::size_t numberOfTests( 5 ); + const std::size_t numberOfTests( 5u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { const SplitWordTest& test = splitWordTests[index]; @@ -1440,7 +1364,7 @@ int UtcDaliTextViewUpdateTextInfo(void) // Remove operations { - std::string( "Remove from new line character to first character next line." ), + std::string( "Remove from new paragraph character to first character next paragraph." ), Remove, std::string("Hello world\nhello world."), 11, @@ -1450,7 +1374,7 @@ int UtcDaliTextViewUpdateTextInfo(void) std::string("Hello worldello world."), }, { - std::string( "Replace style from new line character to first character next line." ), + std::string( "Replace style from new paragraph character to first character next paragraph." ), Replace, std::string("Hello world\nhello world."), 11, @@ -1535,9 +1459,9 @@ int UtcDaliTextViewUpdateTextInfo(void) 0.f, std::string( "Hello \nhello world" ) }, - // * Remove whole word (merge lines) + // * Remove whole word (merge paragraphs) { - std::string( "Remove within the same word, whole word (merge lines)" ), + std::string( "Remove within the same word, whole word (merge paragraphs)" ), Remove, std::string("Hello world\nhello world"), 11, @@ -1547,9 +1471,8 @@ int UtcDaliTextViewUpdateTextInfo(void) std::string( "Hello worldhello world" ) }, // * Remove RTL text within LTR - /* TODO check this when RTL text is working { - std::string( "Remove within the same line, RTL text within LTR." ), + std::string( "Remove within the same paragraph, RTL text within LTR." ), Remove, std::string("Hello world, שלום עולם, hello world"), 10, @@ -1558,10 +1481,9 @@ int UtcDaliTextViewUpdateTextInfo(void) 0.f, std::string( "Hello worlello world" ) }, - */ - // * Remove whole line + // * Remove whole paragraph { - std::string( "Remove whole line" ), + std::string( "Remove whole paragraph" ), Remove, std::string("Hello world, hello world\n" "Hello world, hello world\n" @@ -1576,7 +1498,7 @@ int UtcDaliTextViewUpdateTextInfo(void) "Hello world, hello world\n"), }, { - std::string( "Remove whole line" ), + std::string( "Remove whole paragraph" ), Remove, std::string("Hello world, hello world\n" "H"), @@ -1682,9 +1604,9 @@ int UtcDaliTextViewUpdateTextInfo(void) std::string( "Touch me\nhello\nworld" ) }, }; - const std::size_t numberOfTests( 21 ); + const std::size_t numberOfTests( 22u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { const UpdateTextInfoTest& test = updateTextInfoTest[index]; @@ -1698,85 +1620,90 @@ int UtcDaliTextViewUpdateTextInfo(void) END_TEST; } -int UtcDaliTextViewSplitLine(void) +int UtcDaliTextViewSplitParagraph(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliTextViewSplitLine : "); + tet_infoline("UtcDaliTextViewSplitParagraph : "); - struct SplitLineTest splitLineTests[] = + struct SplitParagraphTest splitParagraphTests[] = { { - std::string( "Split line, wordPosition 0, position 0." ), + std::string( "Split paragraph, wordPosition 0, position 0." ), std::string( "Helloooo wooorld שלום עולם text text" ), 0, 0, + 0, 3.f, std::string( "" ), std::string( "Helloooo wooorld שלום עולם text text" ), }, { - std::string( "Split line, wordPosition 10, position 4." ), + std::string( "Split paragraph, wordPosition 10, position 4." ), std::string( "Helloooo wooorld שלום עולם text text" ), 10, 4, + 36, 0.f, std::string( "Helloooo wooorld שלום עולם text text" ), std::string( "" ), }, { - std::string( "Split line, wordPosition 2, position 4." ), + std::string( "Split paragraph, wordPosition 2, position 4." ), std::string("Hello world, hello world"), 2, 4, + 10, 0.f, std::string("Hello worl"), std::string("d, hello world") - } - /* TODO RTL + }, { - std::string( "Split line, wordPosition 6, position 0." ), + std::string( "Split paragraph, wordPosition 6, position 0." ), std::string( "Helloooo wooorld שלום עולם text text" ), 6, 0, + 21, 0.f, - std::string( "Helloooo wooorld שלום" ), - std::string( " עולם text text" ), + std::string( "Helloooo wooorld שלום " ), + std::string( "עולם text text" ), }, { - std::string( "Split line, wordPosition 4, position 0." ), + std::string( "Split paragraph, wordPosition 4, position 0." ), std::string( "Helloooo wooorld שלום עולם text text" ), 4, 0, + 17, 0.f, std::string( "Helloooo wooorld " ), std::string( "שלום עולם text text" ), }, { - std::string( "Split line2, wordPosition 8, position 0." ), + std::string( "Split paragraph2, wordPosition 8, position 0." ), std::string( "Helloooo wooorld שלום עולם text text" ), 8, 0, + 27, 6.f, std::string( "Helloooo wooorld שלום עולם " ), std::string( "text text" ), }, - */ }; - const std::size_t numberOfTests( 3 ); + const std::size_t numberOfTests( 6u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { - const SplitLineTest& test = splitLineTests[index]; + const SplitParagraphTest& test = splitParagraphTests[index]; - if( !TestSplitLine( test.description, - test.input, - test.wordIndex, - test.characterIndex, - test.lineHeightOffset, - test.firstResult, - test.lastResult, - TEST_LOCATION ) ) + if( !TestSplitParagraph( test.description, + test.input, + test.wordIndex, + test.characterIndex, + test.characterParagraphIndex, + test.lineHeightOffset, + test.firstResult, + test.lastResult, + TEST_LOCATION ) ) { tet_result( TET_FAIL ); } @@ -1807,9 +1734,9 @@ int UtcDaliTextViewMergeWord01(void) std::string( "Hello" ) }, }; - const std::size_t numberOfTests( 2 ); + const std::size_t numberOfTests( 2u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { const MergeWordsTest& test = mergeWordsTests[index]; @@ -1826,7 +1753,7 @@ int UtcDaliTextViewMergeWord01(void) int UtcDaliTextViewMergeWord02(void) { // Negative test. - // It test white spaces and new line characters can't be merged to other words. + // It test white spaces and new paragraph characters can't be merged to other words. ToolkitTestApplication application; @@ -1857,7 +1784,7 @@ int UtcDaliTextViewMergeWord02(void) TextViewProcessor::WordLayoutInfo wordLayoutInfo01; - wordLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + wordLayoutInfo01 = *( *textLayoutInfo01.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); TextViewProcessor::CreateTextInfo( styledText02, DEFAULT_LAYOUT_PARAMETERS, @@ -1865,7 +1792,7 @@ int UtcDaliTextViewMergeWord02(void) TextViewProcessor::WordLayoutInfo wordLayoutInfo02; - wordLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + wordLayoutInfo02 = *( *textLayoutInfo02.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); TextViewProcessor::CreateTextInfo( styledText03, DEFAULT_LAYOUT_PARAMETERS, @@ -1873,9 +1800,9 @@ int UtcDaliTextViewMergeWord02(void) TextViewProcessor::WordLayoutInfo wordLayoutInfo03; - wordLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordsLayoutInfo.begin(); + wordLayoutInfo03 = *( *textLayoutInfo03.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin(); - // Test MergeWord() asserts if white spaces or new line chars are merged. + // Test MergeWord() asserts if white spaces or new paragraph chars are merged. bool assert1 = false; bool assert2 = false; bool assert3 = false; @@ -1890,8 +1817,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert1 = true; } try @@ -1901,8 +1828,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert2 = true; } try @@ -1912,8 +1839,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert3 = true; } try @@ -1923,8 +1850,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert4 = true; } try @@ -1934,8 +1861,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert5 = true; } try @@ -1945,8 +1872,8 @@ int UtcDaliTextViewMergeWord02(void) } 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, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert6 = true; } @@ -1961,66 +1888,64 @@ int UtcDaliTextViewMergeWord02(void) END_TEST; } -int UtcDaliTextViewMergeLine01(void) +int UtcDaliTextViewMergeParagraph01(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliTextViewMergeLine01 : "); + tet_infoline("UtcDaliTextViewMergeParagraph01 : "); - struct MergeLinesTest mergeLinesTests[] = + struct MergeParagraphsTest mergeParagraphsTests[] = { { - std::string( "Merge a void first line." ), + std::string( "Merge a void first paragraph." ), std::string( "" ), - std::string( "Hello world, this is a whole line" ), + std::string( "Hello world, this is a whole paragraph" ), 2.f, - std::string( "Hello world, this is a whole line" ) + std::string( "Hello world, this is a whole paragraph" ) }, { - std::string( "Merge a void last line." ), - std::string( "Hello world, this is a whole line" ), + std::string( "Merge a void last paragraph." ), + std::string( "Hello world, this is a whole paragraph" ), std::string( "" ), 0.f, - std::string( "Hello world, this is a whole line" ) + std::string( "Hello world, this is a whole paragraph" ) }, - /* TODO RTL { - std::string( "Merge lines: last starting with RTL text and first ending with RTL" ), + std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ), std::string( "Hello world, שלום" ), std::string( " עולם, hello world." ), 6.f, std::string( "Hello world, שלום עולם, hello world." ) }, { - std::string( "Merge lines and don't merge last and first words." ), + std::string( "Merge paragraphs and don't merge last and first words." ), std::string( "Hello world, " ), std::string( "שלום עולם, hello world." ), 3.f, std::string( "Hello world, שלום עולם, hello world." ) }, - */ { - std::string( "Merge lines. Don't merge words" ), + std::string( "Merge paragraphs. Don't merge words" ), std::string( "Hello world," ), - std::string( " this is a whole line" ), + std::string( " this is a whole paragraph" ), 0.f, - std::string( "Hello world, this is a whole line" ) + std::string( "Hello world, this is a whole paragraph" ) }, { - std::string( "Merge lines. Merge words" ), + std::string( "Merge paragraphs. Merge words" ), std::string( "Hello world, th" ), - std::string( "is is a whole line" ), + std::string( "is is a whole paragraph" ), 0.f, - std::string( "Hello world, this is a whole line" ) + std::string( "Hello world, this is a whole paragraph" ) }, }; - const std::size_t numberOfTests( 4 ); + const std::size_t numberOfTests( 6u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { - const MergeLinesTest& test = mergeLinesTests[index]; + const MergeParagraphsTest& test = mergeParagraphsTests[index]; - if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) ) + if( !TestMergeParagraphs( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) ) { tet_result( TET_FAIL ); } @@ -2030,11 +1955,11 @@ int UtcDaliTextViewMergeLine01(void) END_TEST; } -int UtcDaliTextViewMergeLine02(void) +int UtcDaliTextViewMergeParagraph02(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliTextViewMergeLine02 : "); + tet_infoline("UtcDaliTextViewMergeParagraph02 : "); Toolkit::Internal::TextView::RelayoutData relayoutData01; Toolkit::Internal::TextView::RelayoutData relayoutData02; @@ -2052,29 +1977,29 @@ int UtcDaliTextViewMergeLine02(void) DEFAULT_LAYOUT_PARAMETERS, relayoutData01 ); - TextViewProcessor::LineLayoutInfo lineLayoutInfo01; + TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo01; - lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin(); + paragraphLayoutInfo01 = *textLayoutInfo01.mParagraphsLayoutInfo.begin(); TextViewProcessor::CreateTextInfo( styledText02, DEFAULT_LAYOUT_PARAMETERS, relayoutData02 ); - TextViewProcessor::LineLayoutInfo lineLayoutInfo02; + TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo02; - lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin(); + paragraphLayoutInfo02 = *textLayoutInfo02.mParagraphsLayoutInfo.begin(); bool assert1 = false; try { - MergeLine( lineLayoutInfo01, - lineLayoutInfo02 ); + MergeParagraph( paragraphLayoutInfo01, + paragraphLayoutInfo02 ); } 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, "!\"TextViewProcessor::MergeLine(). ERROR: A line can't be merged to another line which finishes with a new line character.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION ); assert1 = true; } @@ -2175,9 +2100,9 @@ int UtcDaliTextViewRemoveCharactersFromWord(void) std::string( "Held" ), }, }; - const std::size_t numberOfTests( 11 ); + const std::size_t numberOfTests( 11u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index]; @@ -2191,15 +2116,15 @@ int UtcDaliTextViewRemoveCharactersFromWord(void) END_TEST; } -int UtcDaliTextViewRemoveWordsFromLine(void) +int UtcDaliTextViewRemoveWordsFromParagraph(void) { - // Note: Currently RemoveWordsFromLine() function is only used to remove a number of words from the beginning, or + // Note: Currently RemoveWordsFromParagraph() function is only used to remove a number of words from the beginning, or // from a given index to the end. ToolkitTestApplication application; - tet_infoline("UtcDaliTextViewRemoveWordsFromLine : "); - struct RemoveWordsFromLineTest removeWordsFromLineTest[] = + tet_infoline("UtcDaliTextViewRemoveWordsFromParagraph : "); + struct RemoveWordsFromParagraphTest removeWordsFromParagraphTest[] = { { std::string( "Delete 0 words." ), @@ -2226,13 +2151,13 @@ int UtcDaliTextViewRemoveWordsFromLine(void) std::string( "hello hello" ), }, }; - const std::size_t numberOfTests( 3 ); + const std::size_t numberOfTests( 3u ); - for( std::size_t index = 0; index < numberOfTests; ++index ) + for( std::size_t index = 0u; index < numberOfTests; ++index ) { - const RemoveWordsFromLineTest& test = removeWordsFromLineTest[index]; + const RemoveWordsFromParagraphTest& test = removeWordsFromParagraphTest[index]; - if( !TestRemoveWordsFromLine( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) ) + if( !TestRemoveWordsFromParagraph( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) ) { tet_result( TET_FAIL ); }