2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
27 // Internal headers are allowed here
28 #include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
29 #include <dali-toolkit/internal/controls/text-view/text-view-line-processor.h>
30 #include <dali-toolkit/internal/controls/text-view/text-view-word-group-processor.h>
31 #include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
32 #include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
35 using namespace Dali::Toolkit;
36 using namespace Dali::Toolkit::Internal;
41 const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
42 const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
44 // Data structures used to create an 'experiment' in TET cases
48 std::string description;
51 std::string firstResult;
52 std::string lastResult;
55 struct SplitWordGroupTest
57 std::string description;
59 std::size_t wordPosition;
61 std::string firstResult;
62 std::string lastResult;
67 std::string description;
69 std::size_t groupPosition;
70 std::size_t wordPosition;
72 float lineHeightOffset;
73 std::string firstResult;
74 std::string lastResult;
79 std::string description;
80 std::string inputFirst;
81 std::string inputLast;
85 struct MergeWordGroupsTest
87 std::string description;
88 std::string inputFirst;
89 std::string inputLast;
95 std::string description;
96 std::string inputFirst;
97 std::string inputLast;
98 float lineHeightOffset;
102 struct RemoveCharactersFromWordTest
104 std::string description;
106 std::size_t position;
107 std::size_t numberOfCharacters;
111 struct RemoveWordsFromGroupTest
113 std::string description;
115 std::size_t wordIndex;
116 std::size_t numberOfWords;
120 struct RemoveGroupsFromLineTest
122 std::string description;
124 std::size_t groupIndex;
125 std::size_t numberOfGroups;
126 float lineHeightOffset;
130 enum UpdateTextInfoOperation
137 struct UpdateTextInfoTest
139 std::string description;
140 UpdateTextInfoOperation operation;
142 std::size_t position;
143 std::size_t numberOfCharacters;
144 std::string inputText;
145 float lineHeightOffset;
149 // Useful Print functions when something goes wrong.
151 void Print( const TextViewProcessor::CharacterLayoutInfo& character )
153 std::cout << " height : " << character.mHeight << std::endl;
154 std::cout << " advance : " << character.mAdvance << std::endl;
155 std::cout << " bearing : " << character.mBearing << std::endl;
156 std::cout << " mPosition : " << character.mPosition << std::endl;
157 std::cout << " mSize : " << character.mSize << std::endl;
158 std::cout << " mAscender : " << character.mAscender << std::endl;
160 TextActor textActor = TextActor::DownCast( character.mGlyphActor );
163 std::cout << "[" << textActor.GetText() << "]";
167 std::cout << "{" << character.mStyledText.mText.GetText() << "}";
171 void Print( const TextViewProcessor::WordLayoutInfo& word )
174 std::cout << " mSize : " << word.mSize << std::endl;
175 std::cout << " mAscender : " << word.mAscender << std::endl;
176 std::cout << " mType : " << word.mType << std::endl;
177 std::cout << "mNumberOfCharacters : " << word.mCharactersLayoutInfo.size() << std::endl;
179 for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it )
183 std::cout << "]"; std::cout << std::endl;
184 std::cout << "]"; std::cout << std::endl;
187 void Print( const TextViewProcessor::WordGroupLayoutInfo& wordGroup )
190 std::cout << " mSize : " << wordGroup.mSize << std::endl;
191 std::cout << " mAscender : " << wordGroup.mAscender << std::endl;
192 std::cout << " mDirection : " << wordGroup.mDirection << std::endl;
193 std::cout << "mNumberOfCharacters : " << wordGroup.mNumberOfCharacters << std::endl;
194 for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = wordGroup.mWordsLayoutInfo.begin(), endIt = wordGroup.mWordsLayoutInfo.end(); it != endIt; ++it )
198 std::cout << ")"; std::cout << std::endl;
201 void Print( const TextViewProcessor::LineLayoutInfo& line )
204 std::cout << " mSize : " << line.mSize << std::endl;
205 std::cout << " mAscender : " << line.mAscender << std::endl;
206 std::cout << "mNumberOfCharacters : " << line.mNumberOfCharacters << std::endl;
207 for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it = line.mWordGroupsLayoutInfo.begin(), endIt = line.mWordGroupsLayoutInfo.end(); it != endIt; ++it )
211 std::cout << ">" << std::endl;
214 void Print( const TextViewProcessor::TextLayoutInfo& text )
217 for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it = text.mLinesLayoutInfo.begin(), endIt = text.mLinesLayoutInfo.end(); it != endIt; ++it )
221 std::cout << "||" << std::endl;
224 void Print( const TextStyle& style )
226 std::cout << " font name : " << style.GetFontName() << std::endl;
227 std::cout << " : " << style.GetFontStyle() << std::endl;
228 std::cout << " : " << style.GetFontPointSize() << std::endl;
229 std::cout << " : " << style.GetWeight() << std::endl;
230 std::cout << " : " << style.GetTextColor() << std::endl;
231 std::cout << " : " << style.GetItalics() << std::endl;
232 std::cout << " : " << style.GetUnderline() << std::endl;
233 std::cout << " : " << style.GetShadow() << std::endl;
234 std::cout << " : " << style.GetShadowColor() << std::endl;
235 std::cout << " : " << style.GetShadowOffset() << std::endl;
236 std::cout << " : " << style.GetGlow() << std::endl;
237 std::cout << " : " << style.GetGlowColor() << std::endl;
238 std::cout << " : " << style.GetGlowIntensity() << std::endl;
239 std::cout << " : " << style.GetSmoothEdge() << std::endl;
240 std::cout << " : " << style.GetOutline() << std::endl;
241 std::cout << " : " << style.GetOutlineThickness() << std::endl;
244 // Test functions used to check if two data structures are equal.
246 bool TestEqual( float x, float y )
248 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
251 bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
252 const TextViewProcessor::CharacterLayoutInfo& character2 )
254 if( !TestEqual( character1.mHeight, character2.mHeight ) )
258 if( !TestEqual( character1.mAdvance, character2.mAdvance ) )
262 if( !TestEqual( character1.mBearing, character2.mBearing ) )
267 if( !TestEqual( character1.mPosition.x, character2.mPosition.x ) )
271 if( !TestEqual( character1.mPosition.y, character2.mPosition.y ) )
276 if( !TestEqual( character1.mSize.x, character2.mSize.x ) )
280 if( !TestEqual( character1.mSize.y, character2.mSize.y ) )
285 if( !TestEqual( character1.mAscender, character2.mAscender ) )
290 if( character1.mGlyphActor && !character2.mGlyphActor )
295 if( !character1.mGlyphActor && character2.mGlyphActor )
305 TextActor textActor1 = TextActor::DownCast( character1.mGlyphActor );
306 TextActor textActor2 = TextActor::DownCast( character2.mGlyphActor );
309 text1 = textActor1.GetText();
310 style1 = textActor1.GetTextStyle();
312 text2 = textActor2.GetText();
313 style2 = textActor2.GetTextStyle();
321 if( style1 != style2 )
326 text1 = character1.mStyledText.mText.GetText();
327 style1 = character1.mStyledText.mStyle;
329 text2 = character2.mStyledText.mText.GetText();
330 style2 = character2.mStyledText.mStyle;
337 if( style1 != style2 )
345 bool TestEqual( const TextViewProcessor::WordLayoutInfo& word1,
346 const TextViewProcessor::WordLayoutInfo& word2 )
348 if( !TestEqual( word1.mSize.x, word2.mSize.x ) )
352 if( !TestEqual( word1.mSize.y, word2.mSize.y ) )
357 if( !TestEqual( word1.mAscender, word2.mAscender ) )
362 if( word1.mType != word2.mType )
367 if( word1.mCharactersLayoutInfo.size() != word2.mCharactersLayoutInfo.size() )
372 for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it1 = word1.mCharactersLayoutInfo.begin(), endIt1 = word1.mCharactersLayoutInfo.end(),
373 it2 = word2.mCharactersLayoutInfo.begin(), endIt2 = word2.mCharactersLayoutInfo.end();
374 ( it1 != endIt1 ) && ( it2 != endIt2 );
377 if( !TestEqual( *it1, *it2 ) )
386 bool TestEqual( const TextViewProcessor::WordGroupLayoutInfo& group1,
387 const TextViewProcessor::WordGroupLayoutInfo& group2 )
390 if( group1.mNumberOfCharacters != group2.mNumberOfCharacters )
395 if( group1.mWordsLayoutInfo.size() != group2.mWordsLayoutInfo.size() )
400 if( !TestEqual( group1.mSize.x, group2.mSize.x ) )
404 if( !TestEqual( group1.mSize.y, group2.mSize.y ) )
409 if( !TestEqual( group1.mAscender, group2.mAscender ) )
414 if( group1.mDirection != group2.mDirection )
419 for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = group1.mWordsLayoutInfo.begin(), endIt1 = group1.mWordsLayoutInfo.end(),
420 it2 = group2.mWordsLayoutInfo.begin(), endIt2 = group2.mWordsLayoutInfo.end();
421 ( it1 != endIt1 ) && ( it2 != endIt2 );
424 if( !TestEqual( *it1, *it2 ) )
433 bool TestEqual( const TextViewProcessor::LineLayoutInfo& line1,
434 const TextViewProcessor::LineLayoutInfo& line2 )
436 if( !TestEqual( line1.mSize.x, line2.mSize.x ) )
440 if( !TestEqual( line1.mSize.y, line2.mSize.y ) )
445 if( !TestEqual( line1.mAscender, line2.mAscender ) )
450 if( line1.mNumberOfCharacters != line2.mNumberOfCharacters )
455 if( line1.mWordGroupsLayoutInfo.size() != line2.mWordGroupsLayoutInfo.size() )
460 for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it1 = line1.mWordGroupsLayoutInfo.begin(), endIt1 = line1.mWordGroupsLayoutInfo.end(),
461 it2 = line2.mWordGroupsLayoutInfo.begin(), endIt2 = line2.mWordGroupsLayoutInfo.end();
462 ( it1 != endIt1 ) && ( it2 != endIt2 );
465 if( !TestEqual( *it1, *it2 ) )
474 bool TestEqual( const TextViewProcessor::TextLayoutInfo& text1,
475 const TextViewProcessor::TextLayoutInfo& text2 )
477 if( !TestEqual( text1.mWholeTextSize.x, text2.mWholeTextSize.x ) )
481 if( !TestEqual( text1.mWholeTextSize.y, text2.mWholeTextSize.y ) )
486 if( !TestEqual( text1.mMaxWordWidth, text2.mMaxWordWidth ) )
491 if( text1.mNumberOfCharacters != text2.mNumberOfCharacters )
496 if( text1.mLinesLayoutInfo.size() != text2.mLinesLayoutInfo.size() )
501 for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it1 = text1.mLinesLayoutInfo.begin(), endIt1 = text1.mLinesLayoutInfo.end(),
502 it2 = text2.mLinesLayoutInfo.begin(), endIt2 = text2.mLinesLayoutInfo.end();
503 ( it1 != endIt1 ) && ( it2 != endIt2 );
506 if( !TestEqual( *it1, *it2 ) )
516 * Splits the \e input word in two by the given \e position and checks the results with \e firstResult and \e lastResult.
518 * If the test fails it prints a short description and the line where this function was called.
520 * @param description Short description of the experiment. i.e. "Split the word from the beginning. (position 0)".
521 * @param input The input word.
522 * @param position Where to split the word.
523 * @param firstResult First part of the split word.
524 * @param lastResult Last part of the split word.
525 * @param location Where this function has been called.
527 * @return \e true if the experiment is successful. Otherwise returns \e false.
529 bool TestSplitWord( const std::string& description, const std::string& input, const size_t position, const std::string& firstResult, const std::string& lastResult, const char* location )
531 tet_printf( "%s", description.c_str() );
533 // Create layout info for the input word.
534 Toolkit::Internal::TextView::RelayoutData relayoutData;
535 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
537 MarkupProcessor::StyledTextArray inputStyledText;
538 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
540 TextViewProcessor::CreateTextInfo( inputStyledText,
541 DEFAULT_LAYOUT_PARAMETERS,
544 // Get the input word
545 TextViewProcessor::WordLayoutInfo inputWordLayout;
547 if( !inputLayout.mLinesLayoutInfo.empty() )
549 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
550 if( !line.mWordGroupsLayoutInfo.empty() )
552 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
553 if( !group.mWordsLayoutInfo.empty() )
555 inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
560 // Create layout info for the first part of the result (after split the word)
562 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
563 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
565 MarkupProcessor::StyledTextArray firstResultStyledText;
566 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
568 TextViewProcessor::CreateTextInfo( firstResultStyledText,
569 DEFAULT_LAYOUT_PARAMETERS,
572 // Get the first result word
573 TextViewProcessor::WordLayoutInfo firstResultWordLayout;
575 if( !firstResultLayout.mLinesLayoutInfo.empty() )
577 const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
578 if( !line.mWordGroupsLayoutInfo.empty() )
580 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
581 if( !group.mWordsLayoutInfo.empty() )
583 firstResultWordLayout = *( *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
588 // Create layout info for the last part of the result (after split the word)
590 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
591 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
593 MarkupProcessor::StyledTextArray lastResultStyledText;
594 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
596 TextViewProcessor::CreateTextInfo( lastResultStyledText,
597 DEFAULT_LAYOUT_PARAMETERS,
600 // Get the last result word
601 TextViewProcessor::WordLayoutInfo lastResultWordLayout;
603 if( !lastResultLayout.mLinesLayoutInfo.empty() )
605 const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
606 if( !line.mWordGroupsLayoutInfo.empty() )
608 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
609 if( !group.mWordsLayoutInfo.empty() )
611 lastResultWordLayout = *( *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
618 TextViewProcessor::WordLayoutInfo lastWordLayoutInfo;
622 lastWordLayoutInfo );
625 if( !TestEqual( inputWordLayout, firstResultWordLayout ) )
627 tet_printf( "Fail. different layout info. %s", location );
631 if( !TestEqual( lastWordLayoutInfo, lastResultWordLayout ) )
633 tet_printf( "Fail. different layout info. %s", location );
641 * Splits the \e input group of words in two by the given \e wordPosition and \e position and checks the results with \e firstResult and \e lastResult.
643 * If the test fails it prints a short description and the line where this function was called.
645 * @param description Short description of the experiment. i.e. "Split the group of words from the beginning. (wordPosition 0 and position 0)".
646 * @param input The input word.
647 * @param wordPosition Index to the word within the group where to split the group.
648 * @param position Where to split the word.
649 * @param firstResult First part of the split group of words.
650 * @param lastResult Last part of the split group of words.
651 * @param location Where this function has been called.
653 * @return \e true if the experiment is successful. Otherwise returns \e false.
655 bool TestSplitWordGroup( const std::string& description,
656 const std::string& input,
657 const size_t wordPosition,
658 const size_t position,
659 const std::string& firstResult,
660 const std::string& lastResult,
661 const char* location )
663 tet_printf( "%s", description.c_str() );
665 // Create layout info for the input group of words.
666 Toolkit::Internal::TextView::RelayoutData relayoutData;
667 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
669 MarkupProcessor::StyledTextArray inputStyledText;
670 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
672 TextViewProcessor::CreateTextInfo( inputStyledText,
673 DEFAULT_LAYOUT_PARAMETERS,
676 // Get the input group of words
677 TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
679 if( !inputLayout.mLinesLayoutInfo.empty() )
681 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
682 if( !line.mWordGroupsLayoutInfo.empty() )
684 inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
688 // Create layout info for the first part of the result (after split the group of words)
690 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
691 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
693 MarkupProcessor::StyledTextArray firstResultStyledText;
694 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
696 TextViewProcessor::CreateTextInfo( firstResultStyledText,
697 DEFAULT_LAYOUT_PARAMETERS,
700 // Get the first result group of words
701 TextViewProcessor::WordGroupLayoutInfo firstResultWordGroupLayout;
703 if( !firstResultLayout.mLinesLayoutInfo.empty() )
705 const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
706 if( !line.mWordGroupsLayoutInfo.empty() )
708 firstResultWordGroupLayout = *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
712 // Create layout info for the last part of the result (after split the group of words)
714 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
715 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
717 MarkupProcessor::StyledTextArray lastResultStyledText;
718 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
720 TextViewProcessor::CreateTextInfo( lastResultStyledText,
721 DEFAULT_LAYOUT_PARAMETERS,
724 // Get the last result group of words
725 TextViewProcessor::WordGroupLayoutInfo lastResultWordGroupLayout;
727 if( !lastResultLayout.mLinesLayoutInfo.empty() )
729 const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
730 if( !line.mWordGroupsLayoutInfo.empty() )
732 lastResultWordGroupLayout = *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
736 // Split the group of words.
738 TextViewProcessor::WordGroupLayoutInfo lastWordGroupLayoutInfo;
740 TextViewProcessor::TextInfoIndices indices( 0, 0, wordPosition, position );
741 SplitWordGroup( indices,
742 inputWordGroupLayout,
743 lastWordGroupLayoutInfo );
746 if( !TestEqual( inputWordGroupLayout, firstResultWordGroupLayout ) )
748 tet_printf( "Fail. different layout info. %s", location );
752 if( !TestEqual( lastWordGroupLayoutInfo, lastResultWordGroupLayout ) )
754 tet_printf( "Fail. different layout info. %s", location );
762 * Splits the \e input line in two by the given \e groupPosition, \e wordPosition and \e position and checks the results with \e firstResult and \e lastResult.
764 * If the test fails it prints a short description and the line where this function was called.
766 * @param description Short description of the experiment. i.e. "Split the line from the beginning. (groupPosition 0, wordPosition 0 and position 0)".
767 * @param input The input word.
768 * @param groupPosition Index to the group of words within the line where to split the line.
769 * @param wordPosition Index to the word within the group where to split the group.
770 * @param position Where to split the word.
771 * @param lineHeightOffset Offset between lines.
772 * @param firstResult First part of the split line.
773 * @param lastResult Last part of the split line.
774 * @param location Where this function has been called.
776 * @return \e true if the experiment is successful. Otherwise returns \e false.
778 bool TestSplitLine( const std::string& description,
779 const std::string& input,
780 const size_t groupPosition,
781 const size_t wordPosition,
782 const size_t position,
783 const float lineHeightOffset,
784 const std::string& firstResult,
785 const std::string& lastResult,
786 const char* location )
788 tet_printf( "%s", description.c_str() );
790 // Create layout info for the input line.
791 Toolkit::Internal::TextView::RelayoutData relayoutData;
792 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
794 MarkupProcessor::StyledTextArray inputStyledText;
795 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
797 TextViewProcessor::CreateTextInfo( inputStyledText,
798 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
799 Toolkit::TextView::Original,
800 Toolkit::TextView::Original,
801 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
802 Toolkit::TextView::Center,
803 PointSize( lineHeightOffset ),
804 std::string( "..." ),
808 // Get the input line
809 TextViewProcessor::LineLayoutInfo inputLineLayout;
811 if( !inputLayout.mLinesLayoutInfo.empty() )
813 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
816 // Create layout info for the first part of the result (after split the line)
818 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
819 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
821 MarkupProcessor::StyledTextArray firstResultStyledText;
822 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
824 TextViewProcessor::CreateTextInfo( firstResultStyledText,
825 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
826 Toolkit::TextView::Original,
827 Toolkit::TextView::Original,
828 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
829 Toolkit::TextView::Center,
830 PointSize( lineHeightOffset ),
831 std::string( "..." ),
835 // Get the first result line
836 TextViewProcessor::LineLayoutInfo firstResultLineLayout;
838 if( !firstResultLayout.mLinesLayoutInfo.empty() )
840 firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin();
843 // Create layout info for the last part of the result (after split the line)
845 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
846 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
848 MarkupProcessor::StyledTextArray lastResultStyledText;
849 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
851 TextViewProcessor::CreateTextInfo( lastResultStyledText,
852 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
853 Toolkit::TextView::Original,
854 Toolkit::TextView::Original,
855 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
856 Toolkit::TextView::Center,
857 PointSize( lineHeightOffset ),
862 // Get the last result line
863 TextViewProcessor::LineLayoutInfo lastResultLineLayout;
865 if( !lastResultLayout.mLinesLayoutInfo.empty() )
867 lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin();
872 TextViewProcessor::LineLayoutInfo lastLineLayoutInfo;
874 TextViewProcessor::TextInfoIndices indices( 0, groupPosition, wordPosition, position );
876 PointSize( lineHeightOffset ),
878 lastLineLayoutInfo );
881 if( !TestEqual( inputLineLayout, firstResultLineLayout ) )
883 tet_printf( "Fail. different layout info. %s", location );
887 if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) )
889 tet_printf( "Fail. different layout info. %s", location );
897 * Merges the \e inputFirst word and the \e inputLast word, and checks the results with \e result.
899 * If the test fails it prints a short description and the line where this function was called.
901 * @param description Short description of the experiment. i.e. "Merge two words with same style".
902 * @param inputFirst The first part of the word.
903 * @param inputLast The last part of the word.
904 * @param result The merged word.
905 * @param location Where this function has been called.
907 * @return \e true if the experiment is successful. Otherwise returns \e false.
909 bool TestMergeWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
911 tet_printf( "%s", description.c_str() );
913 // Create layout info for the inputFirst word.
914 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
915 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
917 MarkupProcessor::StyledTextArray inputFirstStyledText;
918 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
920 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
921 DEFAULT_LAYOUT_PARAMETERS,
924 // Get the input word
925 TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
927 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
929 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
930 if( !line.mWordGroupsLayoutInfo.empty() )
932 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
933 if( !group.mWordsLayoutInfo.empty() )
935 inputFirstWordLayout = *( *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
940 // Create layout info for the inputLast word.
941 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
942 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
944 MarkupProcessor::StyledTextArray inputLastStyledText;
945 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
947 TextViewProcessor::CreateTextInfo( inputLastStyledText,
948 DEFAULT_LAYOUT_PARAMETERS,
951 // Get the input word
952 TextViewProcessor::WordLayoutInfo inputLastWordLayout;
954 if( !inputLastLayout.mLinesLayoutInfo.empty() )
956 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
957 if( !line.mWordGroupsLayoutInfo.empty() )
959 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
960 if( !group.mWordsLayoutInfo.empty() )
962 inputLastWordLayout = *( *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
967 // Create layout info for the result word.
968 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
969 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
971 MarkupProcessor::StyledTextArray resultStyledText;
972 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
974 TextViewProcessor::CreateTextInfo( resultStyledText,
975 DEFAULT_LAYOUT_PARAMETERS,
976 resultRelayoutData );
978 // Get the result word
979 TextViewProcessor::WordLayoutInfo resultWordLayout;
981 if( !resultLayout.mLinesLayoutInfo.empty() )
983 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
984 if( !line.mWordGroupsLayoutInfo.empty() )
986 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
987 if( !group.mWordsLayoutInfo.empty() )
989 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
994 MergeWord( inputFirstWordLayout,
995 inputLastWordLayout );
997 if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
999 tet_printf( "Fail. different layout info. %s", location );
1007 * Merges the \e inputFirst group of words and the \e inputLast group of words, and checks the results with \e result.
1009 * If the test fails it prints a short description and the line where this function was called.
1011 * @param description Short description of the experiment.
1012 * @param inputFirst The first part of the group of words.
1013 * @param inputLast The last part of the group of words.
1014 * @param result The merged group of word.
1015 * @param location Where this function has been called.
1017 * @return \e true if the experiment is successful. Otherwise returns \e false.
1019 bool TestMergeGroupsOfWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
1021 tet_printf( "%s", description.c_str() );
1023 // Create layout info for the inputFirst group of word.
1024 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1025 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1027 MarkupProcessor::StyledTextArray inputFirstStyledText;
1028 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
1030 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1031 DEFAULT_LAYOUT_PARAMETERS,
1032 firstRelayoutData );
1034 // Get the input group of words.
1035 TextViewProcessor::WordGroupLayoutInfo inputFirstWordGroupLayout;
1037 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1039 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
1040 if( !line.mWordGroupsLayoutInfo.empty() )
1042 inputFirstWordGroupLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1046 // Create layout info for the inputLast group of words.
1047 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1048 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1050 MarkupProcessor::StyledTextArray inputLastStyledText;
1051 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
1053 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1054 DEFAULT_LAYOUT_PARAMETERS,
1057 // Get the input group of words
1058 TextViewProcessor::WordGroupLayoutInfo inputLastWordGroupLayout;
1060 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1062 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
1063 if( !line.mWordGroupsLayoutInfo.empty() )
1065 inputLastWordGroupLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1069 // Create layout info for the result group of words.
1070 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1071 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1073 MarkupProcessor::StyledTextArray resultStyledText;
1074 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1076 TextViewProcessor::CreateTextInfo( resultStyledText,
1077 DEFAULT_LAYOUT_PARAMETERS,
1078 resultRelayoutData );
1080 // Get the result word
1081 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1083 if( !resultLayout.mLinesLayoutInfo.empty() )
1085 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1086 if( !line.mWordGroupsLayoutInfo.empty() )
1088 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1092 MergeWordGroup( inputFirstWordGroupLayout,
1093 inputLastWordGroupLayout );
1095 if( !TestEqual( inputFirstWordGroupLayout, resultWordGroupLayout ) )
1097 tet_printf( "Fail. different layout info. %s", location );
1105 * Merges the \e inputFirst line and the \e inputLast line, and checks the results with \e result.
1107 * If the test fails it prints a short description and the line where this function was called.
1109 * @param description Short description of the experiment.
1110 * @param inputFirst The first part of the line.
1111 * @param inputLast The last part of the line.
1112 * @param lineHeightOffset Offset between lines.
1113 * @param result The merged line.
1114 * @param location Where this function has been called.
1116 * @return \e true if the experiment is successful. Otherwise returns \e false.
1118 bool TestMergeLines( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
1120 tet_printf( "%s", description.c_str() );
1122 // Create layout info for the inputFirst line.
1123 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1124 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1126 MarkupProcessor::StyledTextArray inputFirstStyledText;
1127 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
1129 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1130 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1131 Toolkit::TextView::Original,
1132 Toolkit::TextView::Original,
1133 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1134 Toolkit::TextView::Center,
1135 PointSize( lineHeightOffset ),
1136 std::string( "..." ),
1138 firstRelayoutData );
1140 // Get the input word
1141 TextViewProcessor::LineLayoutInfo inputFirstLineLayout;
1143 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1145 inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin();
1148 // Create layout info for the inputLast line.
1149 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1150 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1152 MarkupProcessor::StyledTextArray inputLastStyledText;
1153 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
1155 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1156 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1157 Toolkit::TextView::Original,
1158 Toolkit::TextView::Original,
1159 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1160 Toolkit::TextView::Center,
1161 PointSize( lineHeightOffset ),
1162 std::string( "..." ),
1166 // Get the input word
1167 TextViewProcessor::LineLayoutInfo inputLastLineLayout;
1169 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1171 inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.begin();
1174 // Create layout info for the result word.
1175 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1176 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1178 MarkupProcessor::StyledTextArray resultStyledText;
1179 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1181 TextViewProcessor::CreateTextInfo( resultStyledText,
1182 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1183 Toolkit::TextView::Original,
1184 Toolkit::TextView::Original,
1185 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1186 Toolkit::TextView::Center,
1187 PointSize( lineHeightOffset ),
1188 std::string( "..." ),
1190 resultRelayoutData );
1192 // Get the result word
1193 TextViewProcessor::LineLayoutInfo resultLineLayout;
1195 if( !resultLayout.mLinesLayoutInfo.empty() )
1197 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1200 MergeLine( inputFirstLineLayout,
1201 inputLastLineLayout );
1203 if( !TestEqual( inputFirstLineLayout, resultLineLayout ) )
1205 tet_printf( "Fail. different layout info. %s", location );
1213 * Removes from the \e input word the \e numberOfCharacters characters starting from the given \e position and checks the results with \e result.
1215 * If the test fails it prints a short description and the line where this function was called.
1217 * @param description Short description of the experiment. i.e. "Remove a whole group of characters. Merge".
1218 * @param input The input word.
1219 * @param position Where to start to remove characters
1220 * @param numberOfCharacters The number of characters to remove.
1221 * @param result The word without the removed characters.
1222 * @param location Where this function has been called.
1224 * @return \e true if the experiment is successful. Otherwise returns \e false.
1226 bool TestRemoveCharactersFromWord( const std::string& description, const std::string& input, const std::size_t position, const std::size_t numberOfCharacters, const std::string& result, const char* location )
1228 tet_printf( "%s", description.c_str() );
1230 // Create layout info for the input word.
1231 Toolkit::Internal::TextView::RelayoutData relayoutData;
1232 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1234 MarkupProcessor::StyledTextArray inputStyledText;
1235 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
1237 TextViewProcessor::CreateTextInfo( inputStyledText,
1238 DEFAULT_LAYOUT_PARAMETERS,
1241 // Get the input word
1242 TextViewProcessor::WordLayoutInfo inputWordLayout;
1244 if( !inputLayout.mLinesLayoutInfo.empty() )
1246 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1247 if( !line.mWordGroupsLayoutInfo.empty() )
1249 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1250 if( !group.mWordsLayoutInfo.empty() )
1252 inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1257 // Create layout info for the result word.
1258 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1259 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1261 MarkupProcessor::StyledTextArray resultStyledText;
1262 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1264 TextViewProcessor::CreateTextInfo( resultStyledText,
1265 DEFAULT_LAYOUT_PARAMETERS,
1266 resultRelayoutData );
1268 // Get the result word
1269 TextViewProcessor::WordLayoutInfo resultWordLayout;
1271 if( !resultLayout.mLinesLayoutInfo.empty() )
1273 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1274 if( !line.mWordGroupsLayoutInfo.empty() )
1276 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1277 if( !group.mWordsLayoutInfo.empty() )
1279 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1284 RemoveCharactersFromWord( position,
1288 if( !TestEqual( inputWordLayout, resultWordLayout ) )
1290 tet_printf( "Fail. different layout info. %s", location );
1298 * Removes from the \e input group of words the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result.
1300 * If the test fails it prints a short description and the line where this function was called.
1302 * @param description Short description of the experiment.
1303 * @param input The input group of words.
1304 * @param wordIndex Where to start to remove words.
1305 * @param numberOfWords The number of words to remove.
1306 * @param result The group of words without the removed words.
1307 * @param location Where this function has been called.
1309 * @return \e true if the experiment is successful. Otherwise returns \e false.
1311 bool TestRemoveWordsFromGroup( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const std::string& result, const char* location )
1313 tet_printf( "%s", description.c_str() );
1315 // Create layout info for the input group of words.
1316 Toolkit::Internal::TextView::RelayoutData relayoutData;
1317 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1319 MarkupProcessor::StyledTextArray inputStyledText;
1320 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
1322 TextViewProcessor::CreateTextInfo( inputStyledText,
1323 DEFAULT_LAYOUT_PARAMETERS,
1326 // Get the input group of words
1327 TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
1329 if( !inputLayout.mLinesLayoutInfo.empty() )
1331 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1332 if( !line.mWordGroupsLayoutInfo.empty() )
1334 inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1338 // Create layout info for the result group of words.
1339 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1340 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1342 MarkupProcessor::StyledTextArray resultStyledText;
1343 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1345 TextViewProcessor::CreateTextInfo( resultStyledText,
1346 DEFAULT_LAYOUT_PARAMETERS,
1347 resultRelayoutData );
1349 // Get the result group of words.
1350 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1352 if( !resultLayout.mLinesLayoutInfo.empty() )
1354 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1355 if( !line.mWordGroupsLayoutInfo.empty() )
1357 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1361 RemoveWordsFromWordGroup( wordIndex,
1363 inputWordGroupLayout );
1365 if( !TestEqual( inputWordGroupLayout, resultWordGroupLayout ) )
1367 tet_printf( "Fail. different layout info. %s", location );
1376 * Removes from the \e input line the \e numberOfGroups groups of words starting from the given \e groupIndex and checks the results with \e result.
1378 * If the test fails it prints a short description and the line where this function was called.
1380 * @param description Short description of the experiment.
1381 * @param input The input line.
1382 * @param groupIndex Where to start to remove groups of words
1383 * @param numberOfGroups The number of groups of words to remove.
1384 * @param lineHeightOffset Offset between lines.
1385 * @param result The line without the removed groups of words.
1386 * @param location Where this function has been called.
1388 * @return \e true if the experiment is successful. Otherwise returns \e false.
1390 bool TestRemoveGroupsFromLine( const std::string& description, const std::string& input, const std::size_t groupIndex, const std::size_t numberOfGroups, const float lineHeightOffset, const std::string& result, const char* location )
1392 tet_printf( "%s", description.c_str() );
1394 // Create layout info for the input line.
1395 Toolkit::Internal::TextView::RelayoutData relayoutData;
1396 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1398 MarkupProcessor::StyledTextArray inputStyledText;
1399 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
1401 TextViewProcessor::CreateTextInfo( inputStyledText,
1402 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1403 Toolkit::TextView::Original,
1404 Toolkit::TextView::Original,
1405 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1406 Toolkit::TextView::Center,
1407 PointSize( lineHeightOffset ),
1408 std::string( "..." ),
1412 // Get the input line
1413 TextViewProcessor::LineLayoutInfo inputLineLayout;
1415 if( !inputLayout.mLinesLayoutInfo.empty() )
1417 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
1420 // Create layout info for the result line.
1421 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1422 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1424 MarkupProcessor::StyledTextArray resultStyledText;
1425 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1427 TextViewProcessor::CreateTextInfo( resultStyledText,
1428 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1429 Toolkit::TextView::Original,
1430 Toolkit::TextView::Original,
1431 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1432 Toolkit::TextView::Center,
1433 PointSize( lineHeightOffset ),
1434 std::string( "..." ),
1436 resultRelayoutData );
1438 // Get the result line
1439 TextViewProcessor::LineLayoutInfo resultLineLayout;
1441 if( !resultLayout.mLinesLayoutInfo.empty() )
1443 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1446 RemoveWordGroupsFromLine( groupIndex,
1448 PointSize( lineHeightOffset ),
1451 if( !TestEqual( inputLineLayout, resultLineLayout ) )
1453 tet_printf( "Fail. different layout info. %s", location );
1461 * Tests inserts, removes and updates operation in the given \e input text and checks with the given \e result.
1463 * If the test fails it prints a short description and the line where this function was called.
1465 * @param description Short description of the experiment.
1466 * @param operation Type of update operation (insert, remove, replace)
1467 * @param input The input text.
1468 * @param position Where to insert, remove or replace text.
1469 * @param numberOfCharacters Number of characters to remove or replace.
1470 * @param inputText Inserted or updated text.
1471 * @param lineHeightOffset Offset between lines.
1472 * @param result Expected result.
1473 * @param location Where this function has been called.
1475 * @return \e true if the experiment is successful. Otherwise returns \e false.
1477 bool TestUpdateTextInfo( const std::string& description,
1478 const UpdateTextInfoOperation operation,
1479 const std::string& input,
1480 const std::size_t position,
1481 const std::size_t numberOfCharacters,
1482 const std::string& inputText,
1483 const float lineHeightOffset,
1484 const std::string& result,
1485 const char* location )
1487 tet_printf( "%s", description.c_str() );
1489 // Create layout info for the input.
1490 Toolkit::Internal::TextView::RelayoutData relayoutData;
1491 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1493 MarkupProcessor::StyledTextArray inputStyledText;
1494 MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
1496 TextViewProcessor::CreateTextInfo( inputStyledText,
1497 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1498 Toolkit::TextView::Original,
1499 Toolkit::TextView::Original,
1500 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1501 Toolkit::TextView::Center,
1502 PointSize( lineHeightOffset ),
1503 std::string( "..." ),
1507 // Create layout info for the result.
1508 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1509 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1511 MarkupProcessor::StyledTextArray resultStyledText;
1512 MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
1514 TextViewProcessor::CreateTextInfo( resultStyledText,
1515 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1516 Toolkit::TextView::Original,
1517 Toolkit::TextView::Original,
1518 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1519 Toolkit::TextView::Center,
1520 PointSize( lineHeightOffset ),
1521 std::string( "..." ),
1523 resultRelayoutData );
1525 // Choose operation and call appropiate UpdateTextInfo() method.
1526 const Toolkit::Internal::TextView::LayoutParameters layoutParameters( Toolkit::TextView::SplitByNewLineChar,
1527 Toolkit::TextView::Original,
1528 Toolkit::TextView::Original,
1529 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1530 Toolkit::TextView::Center,
1531 PointSize( lineHeightOffset ),
1532 std::string( "..." ),
1539 MarkupProcessor::StyledTextArray inputStyledText;
1540 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
1542 TextViewProcessor::UpdateTextInfo( position,
1550 TextViewProcessor::UpdateTextInfo( position,
1554 TextViewProcessor::CLEAR_TEXT );
1559 MarkupProcessor::StyledTextArray inputStyledText;
1560 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
1562 TextViewProcessor::UpdateTextInfo( position,
1571 tet_printf( "TestUpdateTextInfo: unknown update operation. %s", location );
1576 if( !TestEqual( inputLayout, resultLayout ) )
1578 tet_printf( "Fail. different layout info. %s", location );
1580 std::cout << " result : "; Print( inputLayout );
1581 std::cout << " expected result : "; Print( resultLayout );
1590 static void Startup();
1591 static void Cleanup();
1594 void (*tet_startup)() = Startup;
1595 void (*tet_cleanup)() = Cleanup;
1599 POSITIVE_TC_IDX = 0x01,
1603 #define MAX_NUMBER_OF_TESTS 10000
1605 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
1608 // Add test functionality for all APIs in the class (Positive and Negative)
1609 TEST_FUNCTION( UtcDaliTextViewCreateTextInfo, POSITIVE_TC_IDX ); // Tests data structures are built well.
1610 TEST_FUNCTION( UtcDaliTextViewUpdateTextInfo, POSITIVE_TC_IDX ); // Tests update operations within a whole text (insert, remove, replace).
1611 TEST_FUNCTION( UtcDaliTextViewSplitWord, POSITIVE_TC_IDX ); // Tests the split word operation.
1612 TEST_FUNCTION( UtcDaliTextViewSplitWordGroup, POSITIVE_TC_IDX ); // Tests the split group of words operation.
1613 TEST_FUNCTION( UtcDaliTextViewSplitLine, POSITIVE_TC_IDX ); // Tests the split line operation.
1614 TEST_FUNCTION( UtcDaliTextViewMergeWord01, POSITIVE_TC_IDX ); // Tests the merge word operation.
1615 TEST_FUNCTION( UtcDaliTextViewMergeWord02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge word operation.
1616 TEST_FUNCTION( UtcDaliTextViewMergeGroup01, POSITIVE_TC_IDX ); // Tests the merge group of words operation.
1617 TEST_FUNCTION( UtcDaliTextViewMergeGroup02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge group of words operation.
1618 TEST_FUNCTION( UtcDaliTextViewMergeLine01, POSITIVE_TC_IDX ); // Tests the merge line operation.
1619 TEST_FUNCTION( UtcDaliTextViewMergeLine02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge line operation.
1620 TEST_FUNCTION( UtcDaliTextViewRemoveCharactersFromWord, POSITIVE_TC_IDX ); // Tests the remove characters from a word operation.
1621 TEST_FUNCTION( UtcDaliTextViewRemoveWordsFromGroup, POSITIVE_TC_IDX ); // Tests the remove words from a group of words operation.
1622 TEST_FUNCTION( UtcDaliTextViewRemoveGroupsFromLine, POSITIVE_TC_IDX ); // Tests the remove groups of words from a line operation.
1624 // Called only once before first test is run.
1625 static void Startup()
1629 // Called only once after last test is run
1630 static void Cleanup()
1634 static void UtcDaliTextViewCreateTextInfo()
1636 ToolkitTestApplication application;
1638 tet_infoline("UtcDaliTextViewCreateTextInfo : ");
1640 // Metrics for characters
1643 // size : [9.48351, 9.48351]
1644 // advance : 9.48351
1645 // bearing : 8.53516
1646 // ascender : 8.53516
1649 // size : [11.3802, 11.3802]
1650 // advance : 11.3802
1651 // bearing : 10.2422
1652 // ascender : 10.2422
1655 // size : [13.2769, 13.2769]
1656 // advance : 13.2769
1657 // bearing : 11.9492
1658 // ascender : 11.9492
1660 const float WIDTH_10( 9.48351f );
1661 const float HEIGHT_10( 9.48351f );
1662 const float ADVANCE_10( 9.48351f );
1663 const float BEARING_10( 8.53516f );
1664 const float ASCENDER_10( 8.53516f );
1666 const float WIDTH_12( 11.3802f );
1667 const float HEIGHT_12( 11.3802f );
1668 const float ADVANCE_12( 11.3802f );
1669 const float BEARING_12( 10.2422f );
1670 const float ASCENDER_12( 10.2422f );
1674 Toolkit::Internal::TextView::RelayoutData relayoutData;
1675 TextViewProcessor::TextLayoutInfo& textLayoutInfo( relayoutData.mTextLayoutInfo );
1677 std::string text( "Hel<font size='10'>lo wo</font>rld!\n"
1680 MarkupProcessor::StyledTextArray styledText;
1681 MarkupProcessor::GetStyledTextArray( text, styledText, true );
1683 TextViewProcessor::CreateTextInfo( styledText,
1684 DEFAULT_LAYOUT_PARAMETERS,
1688 // Build the text info with metric values.
1692 TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
1693 layoutInfo10.mHeight = HEIGHT_10;
1694 layoutInfo10.mAdvance = ADVANCE_10;
1695 layoutInfo10.mBearing = BEARING_10;
1696 layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
1697 layoutInfo10.mAscender = ASCENDER_10;
1698 TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
1699 layoutInfo12.mHeight = HEIGHT_12;
1700 layoutInfo12.mAdvance = ADVANCE_12;
1701 layoutInfo12.mBearing = BEARING_12;
1702 layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
1703 layoutInfo12.mAscender = ASCENDER_12;
1706 style10.SetFontPointSize( PointSize( 10.f ) );
1708 style12.SetFontPointSize( PointSize( 0.f ) ); // point size is set to zero because is a default point size.
1710 layoutInfo12.mStyledText.mStyle = style12;
1711 layoutInfo10.mStyledText.mStyle = style10;
1715 TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
1718 wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
1719 wordLayout1.mAscender = ASCENDER_12;
1720 wordLayout1.mType = TextViewProcessor::NoSeparator;
1722 layoutInfo12.mStyledText.mText = Text( "H" );
1723 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
1724 layoutInfo12.mStyledText.mText = Text( "e" );
1725 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
1726 layoutInfo12.mStyledText.mText = Text( "l" );
1727 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1728 layoutInfo10.mStyledText.mText = Text( "l" );
1729 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
1730 layoutInfo10.mStyledText.mText = Text( "o" );
1731 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1734 wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
1735 wordLayout2.mAscender = ASCENDER_10;
1736 wordLayout2.mType = TextViewProcessor::WordSeparator;
1737 layoutInfo10.mStyledText.mText = Text( " " );
1738 wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
1741 wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
1742 wordLayout3.mAscender = ASCENDER_12;
1743 wordLayout3.mType = TextViewProcessor::NoSeparator;
1744 layoutInfo10.mStyledText.mText = Text( "w" );
1745 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
1746 layoutInfo10.mStyledText.mText = Text( "o" );
1747 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1748 layoutInfo12.mStyledText.mText = Text( "r" );
1749 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
1750 layoutInfo12.mStyledText.mText = Text( "l" );
1751 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1752 layoutInfo12.mStyledText.mText = Text( "d" );
1753 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
1754 layoutInfo12.mStyledText.mText = Text( "!" );
1755 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
1757 // (new line character)
1758 wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
1759 wordLayout4.mAscender = ASCENDER_12;
1760 wordLayout4.mType = TextViewProcessor::LineSeparator;
1761 layoutInfo12.mStyledText.mText = Text( "\n" );
1762 layoutInfo12.mSize.width = 0.f;
1763 wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char)
1767 TextViewProcessor::WordGroupLayoutInfo groupLayout1, groupLayout2;
1769 groupLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1770 groupLayout1.mAscender = ASCENDER_12;
1771 groupLayout1.mDirection = TextViewProcessor::LTR;
1772 groupLayout1.mNumberOfCharacters = 13;
1773 groupLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
1774 groupLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
1775 groupLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
1776 groupLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
1778 groupLayout2.mSize = Size( 0.f, HEIGHT_12 );
1779 groupLayout2.mAscender = ASCENDER_12;
1780 groupLayout2.mDirection = TextViewProcessor::LTR;
1781 groupLayout2.mNumberOfCharacters = 1;
1782 groupLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
1786 TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3;
1788 lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1789 lineLayout1.mAscender = ASCENDER_12;
1790 lineLayout1.mNumberOfCharacters = 13;
1791 lineLayout1.mWordGroupsLayoutInfo.push_back( groupLayout1 );
1793 lineLayout2.mSize = Size( 0.f, HEIGHT_12 );
1794 lineLayout2.mAscender = ASCENDER_12;
1795 lineLayout2.mNumberOfCharacters = 1;
1796 lineLayout2.mWordGroupsLayoutInfo.push_back( groupLayout2 );
1798 lineLayout3.mSize = Size( 0.f, HEIGHT_12 );
1801 TextViewProcessor::TextLayoutInfo textLayout;
1803 textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
1804 textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
1805 textLayout.mNumberOfCharacters = 14;
1806 textLayout.mLinesLayoutInfo.push_back( lineLayout1 );
1807 textLayout.mLinesLayoutInfo.push_back( lineLayout2 );
1808 textLayout.mLinesLayoutInfo.push_back( lineLayout3 );
1810 if(!TestEqual( textLayout, textLayoutInfo ))
1812 std::cout << "Layout fails" << std::endl;
1813 Print(textLayout); std::cout << std::endl;
1814 Print(textLayoutInfo); std::cout << std::endl;
1817 DALI_TEST_CHECK( TestEqual( textLayout, textLayoutInfo ) );
1820 static void UtcDaliTextViewSplitWord()
1822 ToolkitTestApplication application;
1824 tet_infoline("UtcDaliTextViewSplitWord : ");
1826 struct SplitWordTest splitWordTests[] =
1829 std::string( "Split word, position 0." ),
1830 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1833 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1836 std::string( "Split word, position 8." ),
1837 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1839 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1843 std::string( "Split word, position 2." ),
1844 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1846 std::string( "<font size='10'>He</font>" ),
1847 std::string( "<font size='12'>ll</font><font size='10'>oooo</font>" ),
1850 std::string( "Split word, position 3." ),
1851 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1853 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
1854 std::string( "<font size='12'>l</font><font size='10'>oooo</font>" ),
1857 std::string( "Split word, position 4." ),
1858 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1860 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
1861 std::string( "<font size='10'>oooo</font>" ),
1864 const std::size_t numberOfTests( 5 );
1866 for( std::size_t index = 0; index < numberOfTests; ++index )
1868 const SplitWordTest& test = splitWordTests[index];
1870 if( !TestSplitWord( test.description, test.input, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
1872 tet_result( TET_FAIL );
1876 tet_result( TET_PASS );
1879 static void UtcDaliTextViewUpdateTextInfo()
1881 ToolkitTestApplication application;
1883 tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
1885 struct UpdateTextInfoTest updateTextInfoTest[] =
1887 // Remove operations
1890 std::string( "Remove from new line character to first character next line." ),
1892 std::string("Hello world\nhello world."),
1897 std::string("Hello worldello world."),
1900 std::string( "Replace style from new line character to first character next line." ),
1902 std::string("Hello world\nhello world."),
1905 std::string("<b>\nh</b>"),
1907 std::string("Hello world<b>\nh</b>ello world."),
1910 std::string( "Remove from the beginning to the middle of last word." ),
1912 std::string("Hello world, hello world."),
1915 std::string(), // Not used.
1920 std::string( "Remove from the beginning to the middle of the text." ),
1922 std::string("Hello world hello world."),
1925 std::string(), // Not used.
1927 std::string("hello world."),
1929 // Remove within the same word:
1930 // * within the same group of characters.
1932 std::string( "Remove within the same word, within the same group of characters" ),
1934 std::string("Hello <font size='30'>world\nhello</font> world"),
1937 std::string(), // Not used.
1939 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1941 // * whole group of characters (merge adjacent group of characters)
1943 std::string( "Remove within the same word, whole group of characters (merge adjacent group of characters)" ),
1945 std::string("Hello <font size='30'>w<font size='20'>orl</font>d\nhello</font> world"),
1948 std::string(), // Not used.
1950 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1952 // * whole group of characters (don't merge adjacent gtoup of characters)
1954 std::string( "Remove within the same word, whole group of characters (don't merge adjacent gtoup of characters)" ),
1956 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1959 std::string(), // Not used.
1961 std::string( "Hello <font size='30'>w</font><font size='10'>d\nhello</font> world" )
1963 // * Remove whole word (merge words)
1965 std::string( "Remove within the same word, whole word (merge words)" ),
1967 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1970 std::string(), // Not used.
1972 std::string( "Hello<font size='30'>w</font>orl<font size='10'>d\nhello</font> world" )
1974 // * Remove whole word (don't merge words)
1976 std::string( "Remove within the same word, whole word (don't merge words)" ),
1978 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1981 std::string(), // Not used.
1983 std::string( "Hello <font size='10'>\nhello</font> world" )
1985 // * Remove whole word (merge lines)
1987 std::string( "Remove within the same word, whole word (merge lines)" ),
1989 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1992 std::string(), // Not used.
1994 std::string( "Hello <font size='30'>w</font>orl<font size='10'>dhello</font> world" )
1996 // * Remove whole group of words
1997 /* TODO check this when RTL text is working
1999 std::string( "Remove within the same line, whole group of words (merge groups)" ),
2001 std::string("Hello world, שלום עולם, hello world"),
2004 std::string(), // Not used.
2006 std::string( "Hello worlello world" )
2009 // * Remove whole line
2011 std::string( "Remove whole line" ),
2013 std::string("Hello world, hello world\n"
2014 "Hello world, hello world\n"
2015 "Hello world, hello world\n"
2016 "Hello world, hello world\n"),
2019 std::string(), // Not used.
2021 std::string("Hello world, hello world\n"
2022 "Hello world, hello world\n"
2023 "Hello world, hello world\n"),
2026 std::string( "Remove whole line" ),
2028 std::string("Hello world, hello world\n"
2032 std::string(), // Not used.
2034 std::string("Hello world, hello world\n"),
2038 // Insert operations
2040 std::string( "insert some text" ),
2042 std::string("inpuext"),
2045 std::string( "t t" ),
2047 std::string( "input text" )
2050 std::string( "Insert text at the end" ),
2052 std::string("touch "),
2055 std::string("me\nhello"),
2057 std::string("touch me\nhello")
2060 // Replace operations.
2062 std::string( "Replace style from the beginning to some point in the middle of the text." ),
2064 std::string( "Hello <font color='green'>world</font>" ),
2067 std::string( "<font color='red'>Hello w</font>" ),
2069 std::string( "<font color='red'>Hello w</font><font color='green'>orld</font>" )
2072 std::string( "Replace style from the middle of the text to the end." ),
2074 std::string( "Touch me\nhello" ),
2077 std::string( "<b>me\nhello</b>" ),
2079 std::string( "Touch <b>me\nhello</b>" )
2082 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 1." ),
2084 std::string( "Touch me\nhello\nworld" ),
2089 std::string( "Touch \nworld" )
2092 std::string( "Insert styled text in the middle of a text. Previous: Replace style from the middle of the text 1." ),
2094 std::string( "Touch \nworld" ),
2097 std::string( "<b>me\nhello</b>" ),
2099 std::string( "Touch <b>me\nhello</b>\nworld" )
2102 std::string( "Replace style from the middle of the text 1." ),
2104 std::string( "Touch me\nhello\nworld" ),
2107 std::string( "<b>me\nhello</b>" ),
2109 std::string( "Touch <b>me\nhello</b>\nworld" )
2112 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 2." ),
2114 std::string( "Touch me\nhello\nworld" ),
2119 std::string( "Touch world" )
2122 std::string( "Replace style from the middle of the text 2." ),
2124 std::string( "Touch me\nhello\nworld" ),
2127 std::string( "<b>me\nhello\n</b>" ),
2129 std::string( "Touch <b>me\nhello\n</b>world" )
2132 const std::size_t numberOfTests( 21 );
2134 for( std::size_t index = 0; index < numberOfTests; ++index )
2136 const UpdateTextInfoTest& test = updateTextInfoTest[index];
2138 if( !TestUpdateTextInfo( test.description, test.operation, test.input, test.position, test.numberOfCharacters, test.inputText, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2140 tet_result( TET_FAIL );
2144 tet_result( TET_PASS );
2147 static void UtcDaliTextViewSplitWordGroup()
2149 ToolkitTestApplication application;
2151 tet_infoline("UtcDaliTextViewSplitWordGroup : ");
2153 struct SplitWordGroupTest splitWordGroupTests[] =
2156 std::string( "Split word group, wordPosition 0, position 0." ),
2157 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2161 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2164 std::string( "Split word group, wordPosition 2, position 8." ),
2165 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2168 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2172 std::string( "Split word group, wordPosition 0, position 2." ),
2173 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2176 std::string( "<font size='10'>He</font>" ),
2177 std::string( "<font size='12'>ll</font><font size='10'>oooo wooorld</font>" ),
2180 std::string( "Split word group, wordPosition 0, position 3." ),
2181 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2184 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
2185 std::string( "<font size='12'>l</font><font size='10'>oooo wooorld</font>" ),
2188 std::string( "Split word group, wordPosition 0, position 4." ),
2189 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2192 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
2193 std::string( "<font size='10'>oooo wooorld</font>" ),
2196 std::string( "Split word group, wordPosition 1, position 0." ),
2197 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2200 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
2201 std::string( "<font size='10'> wooorld</font>" ),
2204 const std::size_t numberOfTests( 6 );
2206 for( std::size_t index = 0; index < numberOfTests; ++index )
2208 const SplitWordGroupTest& test = splitWordGroupTests[index];
2210 if( !TestSplitWordGroup( test.description, test.input, test.wordPosition, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
2212 tet_result( TET_FAIL );
2216 tet_result( TET_PASS );
2219 static void UtcDaliTextViewSplitLine()
2221 ToolkitTestApplication application;
2223 tet_infoline("UtcDaliTextViewSplitLine : ");
2225 struct SplitLineTest splitLineTests[] =
2228 std::string( "Split line, groupPosition 0, wordPosition 0, position 0." ),
2229 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2235 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2238 std::string( "Split line, groupPosition 2, wordPosition 2, position 4." ),
2239 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2244 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2247 /* TODO check when RTL is working.
2249 std::string( "Split line, groupPosition 1, wordPosition 2, position 0." ),
2250 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2255 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום" ),
2256 std::string( " עולם text text" ),
2259 std::string( "Split line, groupPosition 1, wordPosition 0, position 0." ),
2260 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2265 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
2266 std::string( "שלום עולם text text" ),
2270 std::string( "Split line, groupPosition 2, wordPosition 0, position 0." ),
2271 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2276 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם " ),
2277 std::string( "text text" ),
2280 const std::size_t numberOfTests( 3 );
2282 for( std::size_t index = 0; index < numberOfTests; ++index )
2284 const SplitLineTest& test = splitLineTests[index];
2286 if( !TestSplitLine( test.description, test.input, test.groupPosition, test.wordPosition, test.position, test.lineHeightOffset, test.firstResult, test.lastResult, TEST_LOCATION ) )
2288 tet_result( TET_FAIL );
2292 tet_result( TET_PASS );
2295 static void UtcDaliTextViewMergeWord01()
2297 ToolkitTestApplication application;
2299 tet_infoline("UtcDaliTextViewMergeWord01 : ");
2301 struct MergeWordsTest mergeWordsTests[] =
2304 std::string( "Merge words with same style." ),
2305 std::string( "Hel" ),
2306 std::string( "lo" ),
2307 std::string( "Hello" ),
2310 std::string( "Merge words with different styles." ),
2311 std::string( "<font size='10>Hel</font>" ),
2312 std::string( "<font size='20'>lo</font>" ),
2313 std::string( "<font size='10'>Hel</font><font size='20'>lo</font>" )
2316 const std::size_t numberOfTests( 2 );
2318 for( std::size_t index = 0; index < numberOfTests; ++index )
2320 const MergeWordsTest& test = mergeWordsTests[index];
2322 if( !TestMergeWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2324 tet_result( TET_FAIL );
2328 tet_result( TET_PASS );
2331 static void UtcDaliTextViewMergeWord02()
2334 // It test white spaces and new line characters can't be merged to other words.
2336 ToolkitTestApplication application;
2338 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2340 // Generate three words
2342 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2343 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2344 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2345 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2346 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2347 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2349 std::string text01( " " );
2350 std::string text02( "\n" );
2351 std::string text03( "a" );
2352 MarkupProcessor::StyledTextArray styledText01;
2353 MarkupProcessor::StyledTextArray styledText02;
2354 MarkupProcessor::StyledTextArray styledText03;
2355 MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
2356 MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
2357 MarkupProcessor::GetStyledTextArray( text03, styledText03, true );
2359 TextViewProcessor::CreateTextInfo( styledText01,
2360 DEFAULT_LAYOUT_PARAMETERS,
2363 TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
2365 wordLayoutInfo01 = *( *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2367 TextViewProcessor::CreateTextInfo( styledText02,
2368 DEFAULT_LAYOUT_PARAMETERS,
2371 TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
2373 wordLayoutInfo02 = *( *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2375 TextViewProcessor::CreateTextInfo( styledText03,
2376 DEFAULT_LAYOUT_PARAMETERS,
2379 TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
2381 wordLayoutInfo03 = *( *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2383 // Test MergeWord() asserts if white spaces or new line chars are merged.
2384 bool assert1 = false;
2385 bool assert2 = false;
2386 bool assert3 = false;
2387 bool assert4 = false;
2388 bool assert5 = false;
2389 bool assert6 = false;
2393 MergeWord( wordLayoutInfo01,
2396 catch( Dali::DaliException& e )
2398 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2399 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2404 MergeWord( wordLayoutInfo01,
2407 catch( Dali::DaliException& e )
2409 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2410 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2415 MergeWord( wordLayoutInfo02,
2418 catch( Dali::DaliException& e )
2420 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2421 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2426 MergeWord( wordLayoutInfo02,
2429 catch( Dali::DaliException& e )
2431 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2432 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2437 MergeWord( wordLayoutInfo03,
2440 catch( Dali::DaliException& e )
2442 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2443 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2448 MergeWord( wordLayoutInfo03,
2451 catch( Dali::DaliException& e )
2453 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2454 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2458 if( assert1 && assert2 && assert3 && assert4 && assert5 && assert6 )
2460 tet_result( TET_PASS );
2464 tet_result( TET_FAIL );
2468 static void UtcDaliTextViewMergeGroup01()
2470 ToolkitTestApplication application;
2472 tet_infoline("UtcDaliTextViewMergeGroup01 : ");
2474 struct MergeWordGroupsTest mergeWordGroupssTests[] =
2477 std::string( "Merge a void first group." ),
2479 std::string( "Hello world" ),
2480 std::string( "Hello world" ),
2483 std::string( "Merge a void last group." ),
2484 std::string( "Hello world" ),
2486 std::string( "Hello world" ),
2489 std::string( "Merge groups and merge last and first words." ),
2490 std::string( "Hello wor" ),
2491 std::string( "ld, hello world" ),
2492 std::string( "Hello world, hello world" ),
2495 std::string( "Merge groups and don't merge last and first words." ),
2496 std::string( "Hello world, " ),
2497 std::string( "hello world" ),
2498 std::string( "Hello world, hello world" )
2501 const std::size_t numberOfTests( 4 );
2503 for( std::size_t index = 0; index < numberOfTests; ++index )
2505 const MergeWordGroupsTest& test = mergeWordGroupssTests[index];
2507 if( !TestMergeGroupsOfWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2509 tet_result( TET_FAIL );
2513 tet_result(TET_PASS);
2516 static void UtcDaliTextViewMergeGroup02()
2518 ToolkitTestApplication application;
2520 tet_infoline("UtcDaliTextViewMergeGroup02 : ");
2522 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2523 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2524 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2525 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2526 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2527 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2529 std::string text01( "Hello \n" );
2530 std::string text02( "world" );
2531 std::string text03( "السلام عليكم" );
2532 MarkupProcessor::StyledTextArray styledText01;
2533 MarkupProcessor::StyledTextArray styledText02;
2534 MarkupProcessor::StyledTextArray styledText03;
2535 MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
2536 MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
2537 MarkupProcessor::GetStyledTextArray( text03, styledText03, true );
2539 TextViewProcessor::CreateTextInfo( styledText01,
2540 DEFAULT_LAYOUT_PARAMETERS,
2543 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo01;
2545 wordGroupLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2547 TextViewProcessor::CreateTextInfo( styledText02,
2548 DEFAULT_LAYOUT_PARAMETERS,
2551 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo02;
2553 wordGroupLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2555 TextViewProcessor::CreateTextInfo( styledText03,
2556 DEFAULT_LAYOUT_PARAMETERS,
2559 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo03;
2561 wordGroupLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2563 bool assert1 = false;
2564 bool assert2 = false;
2568 MergeWordGroup( wordGroupLayoutInfo01,
2569 wordGroupLayoutInfo02 );
2571 catch( Dali::DaliException& e )
2573 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2574 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWordGroup(). ERROR: A group of words can't be merged to another group which finishes with a new line character.\"", TEST_LOCATION );
2580 MergeWordGroup( wordGroupLayoutInfo03,
2581 wordGroupLayoutInfo02 );
2583 catch( Dali::DaliException& e )
2585 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2586 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWordGroup(). ERROR: groups with different direction can't be merged.\"", TEST_LOCATION );
2590 if( assert1 && assert2 )
2592 tet_result( TET_PASS );
2596 tet_result( TET_FAIL );
2600 static void UtcDaliTextViewMergeLine01()
2602 ToolkitTestApplication application;
2604 tet_infoline("UtcDaliTextViewMergeLine01 : ");
2606 struct MergeLinesTest mergeLinesTests[] =
2609 std::string( "Merge a void first line." ),
2611 std::string( "Hello world, this is a whole line" ),
2613 std::string( "Hello world, this is a whole line" )
2616 std::string( "Merge a void last line." ),
2617 std::string( "Hello world, this is a whole line" ),
2620 std::string( "Hello world, this is a whole line" )
2622 /* TODO: check when RTL text is working.
2624 std::string( "Merge lines and merge last and first groups" ),
2625 std::string( "Hello world, שלום" ),
2626 std::string( " עולם, hello world." ),
2628 std::string( "Hello world, שלום עולם, hello world." )
2631 std::string( "Merge lines and don't merge last and first words." ),
2632 std::string( "Hello world, " ),
2633 std::string( "שלום עולם, hello world." ),
2635 std::string( "Hello world, שלום עולם, hello world." )
2639 std::string( "Merge lines. Don't merge words" ),
2640 std::string( "Hello world," ),
2641 std::string( " this is a whole line" ),
2643 std::string( "Hello world, this is a whole line" )
2646 std::string( "Merge lines. Merge words" ),
2647 std::string( "Hello world, th" ),
2648 std::string( "is is a whole line" ),
2650 std::string( "Hello world, this is a whole line" )
2653 const std::size_t numberOfTests( 4 );
2655 for( std::size_t index = 0; index < numberOfTests; ++index )
2657 const MergeLinesTest& test = mergeLinesTests[index];
2659 if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2661 tet_result( TET_FAIL );
2665 tet_result( TET_PASS );
2668 static void UtcDaliTextViewMergeLine02()
2670 ToolkitTestApplication application;
2672 tet_infoline("UtcDaliTextViewMergeLine02 : ");
2674 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2675 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2676 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2677 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2679 std::string text01( "Hello world\n" );
2680 std::string text02( "hello world" );
2681 MarkupProcessor::StyledTextArray styledText01;
2682 MarkupProcessor::StyledTextArray styledText02;
2683 MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
2684 MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
2686 TextViewProcessor::CreateTextInfo( styledText01,
2687 DEFAULT_LAYOUT_PARAMETERS,
2690 TextViewProcessor::LineLayoutInfo lineLayoutInfo01;
2692 lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin();
2694 TextViewProcessor::CreateTextInfo( styledText02,
2695 DEFAULT_LAYOUT_PARAMETERS,
2698 TextViewProcessor::LineLayoutInfo lineLayoutInfo02;
2700 lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin();
2702 bool assert1 = false;
2706 MergeLine( lineLayoutInfo01,
2709 catch( Dali::DaliException& e )
2711 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2712 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 );
2718 tet_result( TET_PASS );
2722 tet_result( TET_FAIL );
2726 void UtcDaliTextViewRemoveCharactersFromWord()
2728 ToolkitTestApplication application;
2730 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2732 struct RemoveCharactersFromWordTest removeCharactersFromWordTests[] =
2735 std::string( "Delete 0 characters." ),
2736 std::string( "Hello" ),
2739 std::string( "Hello" ),
2742 std::string( "Delete within the same group of characters. Starting from the beginning" ),
2743 std::string( "Hello" ),
2746 std::string( "lo" ),
2749 std::string( "Delete within the same group of characters. Somewhere in the middle" ),
2750 std::string( "Hello" ),
2753 std::string( "Heo" ),
2756 std::string( "Delete within the same group of characters. Starting somewhere in the middle to the end" ),
2757 std::string( "Hello" ),
2760 std::string( "Hel" ),
2763 std::string( "Delete within the same group of characters. Finish just before a new one." ),
2764 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2767 std::string( "<font size='10'>H</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2770 std::string( "Delete starting in one group of characters and finishing in a different one. No merge of groups." ),
2771 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2774 std::string( "<font size='10'>He</font><font size='20'>Wo</font><font size='30'>rld</font>" ),
2777 std::string( "Delete within the same group of characters. Starting just after a different one." ),
2778 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2781 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>d</font>" ),
2784 std::string( "Delete whole group of characters. No merge" ),
2785 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2788 std::string( "<font size='10'>Hel</font><font size='30'>rld</font>" ),
2791 std::string( "Delete whole group of characters and part of the adjacent ones. No merge" ),
2792 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2795 std::string( "<font size='10'>He</font><font size='30'>ld</font>" ),
2798 std::string( "Delete whole group of characters. Merge" ),
2799 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2802 std::string( "<font size='10'>Helrld</font>" ),
2805 std::string( "Delete whole group of characters and part of the adjacent ones. Merge" ),
2806 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2809 std::string( "<font size='10'>Held</font>" ),
2812 const std::size_t numberOfTests( 11 );
2814 for( std::size_t index = 0; index < numberOfTests; ++index )
2816 const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
2818 if( !TestRemoveCharactersFromWord( test.description, test.input, test.position, test.numberOfCharacters, test.result, TEST_LOCATION ) )
2820 tet_result( TET_FAIL );
2824 tet_result( TET_PASS );
2827 static void UtcDaliTextViewRemoveWordsFromGroup()
2829 // Note: Currently RemoveWordsFromWordGroup() function is only used to remove a number of words from the beginning, or
2830 // from a given index to the end. RemoveWordsFromWordGroup() doesn't merge words (if a white space is removed) so
2831 // tehere isn't any TET case to cover these cases. To be done if needed.
2833 ToolkitTestApplication application;
2835 tet_infoline("UtcDaliTextViewRemoveWordsFromGroup : ");
2836 struct RemoveWordsFromGroupTest removeWordsFromGroupTests[] =
2839 std::string( "Delete 0 words." ),
2840 std::string( "Hello world, hello world" ),
2843 std::string( "Hello world, hello world" ),
2846 std::string( "Delete some words in the middle. Don't merge words" ),
2847 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2850 std::string( "<font size='10'>Hel</font><font size='20'>lo</font><font size='30'> world</font>" ),
2853 std::string( "Delete words up to the end" ),
2854 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2857 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello</font>" ),
2860 std::string( "Delete words from the beginning." ),
2861 std::string( "Hello world, hello world" ),
2864 std::string( " hello world" ),
2867 const std::size_t numberOfTests( 4 );
2869 for( std::size_t index = 0; index < numberOfTests; ++index )
2871 const RemoveWordsFromGroupTest& test = removeWordsFromGroupTests[index];
2873 if( !TestRemoveWordsFromGroup( test.description, test.input, test.wordIndex, test.numberOfWords, test.result, TEST_LOCATION ) )
2875 tet_result( TET_FAIL );
2879 tet_result( TET_PASS );
2882 static void UtcDaliTextViewRemoveGroupsFromLine()
2884 // Note: Currently RemoveWordGroupsFromLine() function is only used to remove a number of group of words from the beginning, or
2885 // from a given index to the end. RemoveWordGroupsFromLine() doesn't merge groups of words (if a whole group of words is removed) so
2886 // tehere isn't any TET case to cover these cases. To be done if needed.
2888 ToolkitTestApplication application;
2890 tet_infoline("UtcDaliTextViewRemoveGroupsFromLine : ");
2891 struct RemoveGroupsFromLineTest removeGroupsFromLineTests[] =
2894 std::string( "Delete 0 groups of words." ),
2895 std::string( "Hello hello, שלום עולם hello hello" ),
2899 std::string( "Hello hello, שלום עולם hello hello" ),
2902 std::string( "Delete from the middle to the end." ),
2903 std::string( "Hello hello, שלום עולם hello hello" ),
2907 std::string( "Hello hello, " ),
2910 std::string( "Delete from the beginning to the middle." ),
2911 std::string( "Hello hello, שלום עולם hello hello" ),
2915 std::string( "hello hello" ),
2918 const std::size_t numberOfTests( 3 );
2920 for( std::size_t index = 0; index < numberOfTests; ++index )
2922 const RemoveGroupsFromLineTest& test = removeGroupsFromLineTests[index];
2924 if( !TestRemoveGroupsFromLine( test.description, test.input, test.groupIndex, test.numberOfGroups, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2926 tet_result( TET_FAIL );
2930 tet_result( TET_PASS );