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 );
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 );
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 );
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 );
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 );
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 );
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 );
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( "..." ) ),
807 // Get the input line
808 TextViewProcessor::LineLayoutInfo inputLineLayout;
810 if( !inputLayout.mLinesLayoutInfo.empty() )
812 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
815 // Create layout info for the first part of the result (after split the line)
817 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
818 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
820 MarkupProcessor::StyledTextArray firstResultStyledText;
821 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText );
823 TextViewProcessor::CreateTextInfo( firstResultStyledText,
824 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
825 Toolkit::TextView::Original,
826 Toolkit::TextView::Original,
827 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
828 Toolkit::TextView::Center,
829 PointSize( lineHeightOffset ),
830 std::string( "..." ) ),
833 // Get the first result line
834 TextViewProcessor::LineLayoutInfo firstResultLineLayout;
836 if( !firstResultLayout.mLinesLayoutInfo.empty() )
838 firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin();
841 // Create layout info for the last part of the result (after split the line)
843 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
844 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
846 MarkupProcessor::StyledTextArray lastResultStyledText;
847 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText );
849 TextViewProcessor::CreateTextInfo( lastResultStyledText,
850 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
851 Toolkit::TextView::Original,
852 Toolkit::TextView::Original,
853 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
854 Toolkit::TextView::Center,
855 PointSize( lineHeightOffset ),
856 std::string( "..." ) ),
859 // Get the last result line
860 TextViewProcessor::LineLayoutInfo lastResultLineLayout;
862 if( !lastResultLayout.mLinesLayoutInfo.empty() )
864 lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin();
869 TextViewProcessor::LineLayoutInfo lastLineLayoutInfo;
871 TextViewProcessor::TextInfoIndices indices( 0, groupPosition, wordPosition, position );
873 PointSize( lineHeightOffset ),
875 lastLineLayoutInfo );
878 if( !TestEqual( inputLineLayout, firstResultLineLayout ) )
880 tet_printf( "Fail. different layout info. %s", location );
884 if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) )
886 tet_printf( "Fail. different layout info. %s", location );
894 * Merges the \e inputFirst word and the \e inputLast word, and checks the results with \e result.
896 * If the test fails it prints a short description and the line where this function was called.
898 * @param description Short description of the experiment. i.e. "Merge two words with same style".
899 * @param inputFirst The first part of the word.
900 * @param inputLast The last part of the word.
901 * @param result The merged word.
902 * @param location Where this function has been called.
904 * @return \e true if the experiment is successful. Otherwise returns \e false.
906 bool TestMergeWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
908 tet_printf( "%s", description.c_str() );
910 // Create layout info for the inputFirst word.
911 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
912 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
914 MarkupProcessor::StyledTextArray inputFirstStyledText;
915 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
917 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
918 DEFAULT_LAYOUT_PARAMETERS,
921 // Get the input word
922 TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
924 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
926 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
927 if( !line.mWordGroupsLayoutInfo.empty() )
929 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
930 if( !group.mWordsLayoutInfo.empty() )
932 inputFirstWordLayout = *( *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
937 // Create layout info for the inputLast word.
938 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
939 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
941 MarkupProcessor::StyledTextArray inputLastStyledText;
942 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
944 TextViewProcessor::CreateTextInfo( inputLastStyledText,
945 DEFAULT_LAYOUT_PARAMETERS,
948 // Get the input word
949 TextViewProcessor::WordLayoutInfo inputLastWordLayout;
951 if( !inputLastLayout.mLinesLayoutInfo.empty() )
953 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
954 if( !line.mWordGroupsLayoutInfo.empty() )
956 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
957 if( !group.mWordsLayoutInfo.empty() )
959 inputLastWordLayout = *( *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
964 // Create layout info for the result word.
965 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
966 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
968 MarkupProcessor::StyledTextArray resultStyledText;
969 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
971 TextViewProcessor::CreateTextInfo( resultStyledText,
972 DEFAULT_LAYOUT_PARAMETERS,
973 resultRelayoutData );
975 // Get the result word
976 TextViewProcessor::WordLayoutInfo resultWordLayout;
978 if( !resultLayout.mLinesLayoutInfo.empty() )
980 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
981 if( !line.mWordGroupsLayoutInfo.empty() )
983 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
984 if( !group.mWordsLayoutInfo.empty() )
986 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
991 MergeWord( inputFirstWordLayout,
992 inputLastWordLayout );
994 if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
996 tet_printf( "Fail. different layout info. %s", location );
1004 * Merges the \e inputFirst group of words and the \e inputLast group of words, and checks the results with \e result.
1006 * If the test fails it prints a short description and the line where this function was called.
1008 * @param description Short description of the experiment.
1009 * @param inputFirst The first part of the group of words.
1010 * @param inputLast The last part of the group of words.
1011 * @param result The merged group of word.
1012 * @param location Where this function has been called.
1014 * @return \e true if the experiment is successful. Otherwise returns \e false.
1016 bool TestMergeGroupsOfWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
1018 tet_printf( "%s", description.c_str() );
1020 // Create layout info for the inputFirst group of word.
1021 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1022 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1024 MarkupProcessor::StyledTextArray inputFirstStyledText;
1025 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
1027 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1028 DEFAULT_LAYOUT_PARAMETERS,
1029 firstRelayoutData );
1031 // Get the input group of words.
1032 TextViewProcessor::WordGroupLayoutInfo inputFirstWordGroupLayout;
1034 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1036 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
1037 if( !line.mWordGroupsLayoutInfo.empty() )
1039 inputFirstWordGroupLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1043 // Create layout info for the inputLast group of words.
1044 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1045 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1047 MarkupProcessor::StyledTextArray inputLastStyledText;
1048 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
1050 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1051 DEFAULT_LAYOUT_PARAMETERS,
1054 // Get the input group of words
1055 TextViewProcessor::WordGroupLayoutInfo inputLastWordGroupLayout;
1057 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1059 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
1060 if( !line.mWordGroupsLayoutInfo.empty() )
1062 inputLastWordGroupLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1066 // Create layout info for the result group of words.
1067 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1068 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1070 MarkupProcessor::StyledTextArray resultStyledText;
1071 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1073 TextViewProcessor::CreateTextInfo( resultStyledText,
1074 DEFAULT_LAYOUT_PARAMETERS,
1075 resultRelayoutData );
1077 // Get the result word
1078 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1080 if( !resultLayout.mLinesLayoutInfo.empty() )
1082 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1083 if( !line.mWordGroupsLayoutInfo.empty() )
1085 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1089 MergeWordGroup( inputFirstWordGroupLayout,
1090 inputLastWordGroupLayout );
1092 if( !TestEqual( inputFirstWordGroupLayout, resultWordGroupLayout ) )
1094 tet_printf( "Fail. different layout info. %s", location );
1102 * Merges the \e inputFirst line and the \e inputLast line, and checks the results with \e result.
1104 * If the test fails it prints a short description and the line where this function was called.
1106 * @param description Short description of the experiment.
1107 * @param inputFirst The first part of the line.
1108 * @param inputLast The last part of the line.
1109 * @param lineHeightOffset Offset between lines.
1110 * @param result The merged line.
1111 * @param location Where this function has been called.
1113 * @return \e true if the experiment is successful. Otherwise returns \e false.
1115 bool TestMergeLines( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
1117 tet_printf( "%s", description.c_str() );
1119 // Create layout info for the inputFirst line.
1120 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1121 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1123 MarkupProcessor::StyledTextArray inputFirstStyledText;
1124 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
1126 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1127 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1128 Toolkit::TextView::Original,
1129 Toolkit::TextView::Original,
1130 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1131 Toolkit::TextView::Center,
1132 PointSize( lineHeightOffset ),
1133 std::string( "..." ) ),
1134 firstRelayoutData );
1136 // Get the input word
1137 TextViewProcessor::LineLayoutInfo inputFirstLineLayout;
1139 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1141 inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin();
1144 // Create layout info for the inputLast line.
1145 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1146 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1148 MarkupProcessor::StyledTextArray inputLastStyledText;
1149 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
1151 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1152 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1153 Toolkit::TextView::Original,
1154 Toolkit::TextView::Original,
1155 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1156 Toolkit::TextView::Center,
1157 PointSize( lineHeightOffset ),
1158 std::string( "..." ) ),
1161 // Get the input word
1162 TextViewProcessor::LineLayoutInfo inputLastLineLayout;
1164 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1166 inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.begin();
1169 // Create layout info for the result word.
1170 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1171 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1173 MarkupProcessor::StyledTextArray resultStyledText;
1174 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1176 TextViewProcessor::CreateTextInfo( resultStyledText,
1177 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1178 Toolkit::TextView::Original,
1179 Toolkit::TextView::Original,
1180 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1181 Toolkit::TextView::Center,
1182 PointSize( lineHeightOffset ),
1183 std::string( "..." ) ),
1184 resultRelayoutData );
1186 // Get the result word
1187 TextViewProcessor::LineLayoutInfo resultLineLayout;
1189 if( !resultLayout.mLinesLayoutInfo.empty() )
1191 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1194 MergeLine( inputFirstLineLayout,
1195 inputLastLineLayout );
1197 if( !TestEqual( inputFirstLineLayout, resultLineLayout ) )
1199 tet_printf( "Fail. different layout info. %s", location );
1207 * Removes from the \e input word the \e numberOfCharacters characters starting from the given \e position and checks the results with \e result.
1209 * If the test fails it prints a short description and the line where this function was called.
1211 * @param description Short description of the experiment. i.e. "Remove a whole group of characters. Merge".
1212 * @param input The input word.
1213 * @param position Where to start to remove characters
1214 * @param numberOfCharacters The number of characters to remove.
1215 * @param result The word without the removed characters.
1216 * @param location Where this function has been called.
1218 * @return \e true if the experiment is successful. Otherwise returns \e false.
1220 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 )
1222 tet_printf( "%s", description.c_str() );
1224 // Create layout info for the input word.
1225 Toolkit::Internal::TextView::RelayoutData relayoutData;
1226 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1228 MarkupProcessor::StyledTextArray inputStyledText;
1229 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1231 TextViewProcessor::CreateTextInfo( inputStyledText,
1232 DEFAULT_LAYOUT_PARAMETERS,
1235 // Get the input word
1236 TextViewProcessor::WordLayoutInfo inputWordLayout;
1238 if( !inputLayout.mLinesLayoutInfo.empty() )
1240 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1241 if( !line.mWordGroupsLayoutInfo.empty() )
1243 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1244 if( !group.mWordsLayoutInfo.empty() )
1246 inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1251 // Create layout info for the result word.
1252 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1253 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1255 MarkupProcessor::StyledTextArray resultStyledText;
1256 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1258 TextViewProcessor::CreateTextInfo( resultStyledText,
1259 DEFAULT_LAYOUT_PARAMETERS,
1260 resultRelayoutData );
1262 // Get the result word
1263 TextViewProcessor::WordLayoutInfo resultWordLayout;
1265 if( !resultLayout.mLinesLayoutInfo.empty() )
1267 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1268 if( !line.mWordGroupsLayoutInfo.empty() )
1270 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1271 if( !group.mWordsLayoutInfo.empty() )
1273 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1278 RemoveCharactersFromWord( position,
1282 if( !TestEqual( inputWordLayout, resultWordLayout ) )
1284 tet_printf( "Fail. different layout info. %s", location );
1292 * 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.
1294 * If the test fails it prints a short description and the line where this function was called.
1296 * @param description Short description of the experiment.
1297 * @param input The input group of words.
1298 * @param wordIndex Where to start to remove words.
1299 * @param numberOfWords The number of words to remove.
1300 * @param result The group of words without the removed words.
1301 * @param location Where this function has been called.
1303 * @return \e true if the experiment is successful. Otherwise returns \e false.
1305 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 )
1307 tet_printf( "%s", description.c_str() );
1309 // Create layout info for the input group of words.
1310 Toolkit::Internal::TextView::RelayoutData relayoutData;
1311 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1313 MarkupProcessor::StyledTextArray inputStyledText;
1314 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1316 TextViewProcessor::CreateTextInfo( inputStyledText,
1317 DEFAULT_LAYOUT_PARAMETERS,
1320 // Get the input group of words
1321 TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
1323 if( !inputLayout.mLinesLayoutInfo.empty() )
1325 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1326 if( !line.mWordGroupsLayoutInfo.empty() )
1328 inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1332 // Create layout info for the result group of words.
1333 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1334 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1336 MarkupProcessor::StyledTextArray resultStyledText;
1337 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1339 TextViewProcessor::CreateTextInfo( resultStyledText,
1340 DEFAULT_LAYOUT_PARAMETERS,
1341 resultRelayoutData );
1343 // Get the result group of words.
1344 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1346 if( !resultLayout.mLinesLayoutInfo.empty() )
1348 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1349 if( !line.mWordGroupsLayoutInfo.empty() )
1351 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1355 RemoveWordsFromWordGroup( wordIndex,
1357 inputWordGroupLayout );
1359 if( !TestEqual( inputWordGroupLayout, resultWordGroupLayout ) )
1361 tet_printf( "Fail. different layout info. %s", location );
1370 * 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.
1372 * If the test fails it prints a short description and the line where this function was called.
1374 * @param description Short description of the experiment.
1375 * @param input The input line.
1376 * @param groupIndex Where to start to remove groups of words
1377 * @param numberOfGroups The number of groups of words to remove.
1378 * @param lineHeightOffset Offset between lines.
1379 * @param result The line without the removed groups of words.
1380 * @param location Where this function has been called.
1382 * @return \e true if the experiment is successful. Otherwise returns \e false.
1384 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 )
1386 tet_printf( "%s", description.c_str() );
1388 // Create layout info for the input line.
1389 Toolkit::Internal::TextView::RelayoutData relayoutData;
1390 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1392 MarkupProcessor::StyledTextArray inputStyledText;
1393 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1395 TextViewProcessor::CreateTextInfo( inputStyledText,
1396 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1397 Toolkit::TextView::Original,
1398 Toolkit::TextView::Original,
1399 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1400 Toolkit::TextView::Center,
1401 PointSize( lineHeightOffset ),
1402 std::string( "..." ) ),
1405 // Get the input line
1406 TextViewProcessor::LineLayoutInfo inputLineLayout;
1408 if( !inputLayout.mLinesLayoutInfo.empty() )
1410 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
1413 // Create layout info for the result line.
1414 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1415 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1417 MarkupProcessor::StyledTextArray resultStyledText;
1418 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1420 TextViewProcessor::CreateTextInfo( resultStyledText,
1421 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1422 Toolkit::TextView::Original,
1423 Toolkit::TextView::Original,
1424 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1425 Toolkit::TextView::Center,
1426 PointSize( lineHeightOffset ),
1427 std::string( "..." ) ),
1428 resultRelayoutData );
1430 // Get the result line
1431 TextViewProcessor::LineLayoutInfo resultLineLayout;
1433 if( !resultLayout.mLinesLayoutInfo.empty() )
1435 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1438 RemoveWordGroupsFromLine( groupIndex,
1440 PointSize( lineHeightOffset ),
1443 if( !TestEqual( inputLineLayout, resultLineLayout ) )
1445 tet_printf( "Fail. different layout info. %s", location );
1453 * Tests inserts, removes and updates operation in the given \e input text and checks with the given \e result.
1455 * If the test fails it prints a short description and the line where this function was called.
1457 * @param description Short description of the experiment.
1458 * @param operation Type of update operation (insert, remove, replace)
1459 * @param input The input text.
1460 * @param position Where to insert, remove or replace text.
1461 * @param numberOfCharacters Number of characters to remove or replace.
1462 * @param inputText Inserted or updated text.
1463 * @param lineHeightOffset Offset between lines.
1464 * @param result Expected result.
1465 * @param location Where this function has been called.
1467 * @return \e true if the experiment is successful. Otherwise returns \e false.
1469 bool TestUpdateTextInfo( const std::string& description,
1470 const UpdateTextInfoOperation operation,
1471 const std::string& input,
1472 const std::size_t position,
1473 const std::size_t numberOfCharacters,
1474 const std::string& inputText,
1475 const float lineHeightOffset,
1476 const std::string& result,
1477 const char* location )
1479 tet_printf( "%s", description.c_str() );
1481 // Create layout info for the input.
1482 Toolkit::Internal::TextView::RelayoutData relayoutData;
1483 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1485 MarkupProcessor::StyledTextArray inputStyledText;
1486 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1488 TextViewProcessor::CreateTextInfo( inputStyledText,
1489 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1490 Toolkit::TextView::Original,
1491 Toolkit::TextView::Original,
1492 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1493 Toolkit::TextView::Center,
1494 PointSize( lineHeightOffset ),
1495 std::string( "..." ) ),
1498 // Create layout info for the result.
1499 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1500 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1502 MarkupProcessor::StyledTextArray resultStyledText;
1503 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1505 TextViewProcessor::CreateTextInfo( resultStyledText,
1506 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1507 Toolkit::TextView::Original,
1508 Toolkit::TextView::Original,
1509 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1510 Toolkit::TextView::Center,
1511 PointSize( lineHeightOffset ),
1512 std::string( "..." ) ),
1513 resultRelayoutData );
1515 // Choose operation and call appropiate UpdateTextInfo() method.
1516 const Toolkit::Internal::TextView::LayoutParameters layoutParameters( Toolkit::TextView::SplitByNewLineChar,
1517 Toolkit::TextView::Original,
1518 Toolkit::TextView::Original,
1519 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1520 Toolkit::TextView::Center,
1521 PointSize( lineHeightOffset ),
1522 std::string( "..." ) );
1528 MarkupProcessor::StyledTextArray inputStyledText;
1529 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText );
1531 TextViewProcessor::UpdateTextInfo( position,
1539 TextViewProcessor::UpdateTextInfo( position,
1543 TextViewProcessor::CLEAR_TEXT );
1548 MarkupProcessor::StyledTextArray inputStyledText;
1549 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText );
1551 TextViewProcessor::UpdateTextInfo( position,
1560 tet_printf( "TestUpdateTextInfo: unknown update operation. %s", location );
1565 if( !TestEqual( inputLayout, resultLayout ) )
1567 tet_printf( "Fail. different layout info. %s", location );
1569 std::cout << " result : "; Print( inputLayout );
1570 std::cout << " expected result : "; Print( resultLayout );
1579 static void Startup();
1580 static void Cleanup();
1583 void (*tet_startup)() = Startup;
1584 void (*tet_cleanup)() = Cleanup;
1588 POSITIVE_TC_IDX = 0x01,
1592 #define MAX_NUMBER_OF_TESTS 10000
1594 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
1597 // Add test functionality for all APIs in the class (Positive and Negative)
1598 TEST_FUNCTION( UtcDaliTextViewCreateTextInfo, POSITIVE_TC_IDX ); // Tests data structures are built well.
1599 TEST_FUNCTION( UtcDaliTextViewUpdateTextInfo, POSITIVE_TC_IDX ); // Tests update operations within a whole text (insert, remove, replace).
1600 TEST_FUNCTION( UtcDaliTextViewSplitWord, POSITIVE_TC_IDX ); // Tests the split word operation.
1601 TEST_FUNCTION( UtcDaliTextViewSplitWordGroup, POSITIVE_TC_IDX ); // Tests the split group of words operation.
1602 TEST_FUNCTION( UtcDaliTextViewSplitLine, POSITIVE_TC_IDX ); // Tests the split line operation.
1603 TEST_FUNCTION( UtcDaliTextViewMergeWord01, POSITIVE_TC_IDX ); // Tests the merge word operation.
1604 TEST_FUNCTION( UtcDaliTextViewMergeWord02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge word operation.
1605 TEST_FUNCTION( UtcDaliTextViewMergeGroup01, POSITIVE_TC_IDX ); // Tests the merge group of words operation.
1606 TEST_FUNCTION( UtcDaliTextViewMergeGroup02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge group of words operation.
1607 TEST_FUNCTION( UtcDaliTextViewMergeLine01, POSITIVE_TC_IDX ); // Tests the merge line operation.
1608 TEST_FUNCTION( UtcDaliTextViewMergeLine02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge line operation.
1609 TEST_FUNCTION( UtcDaliTextViewRemoveCharactersFromWord, POSITIVE_TC_IDX ); // Tests the remove characters from a word operation.
1610 TEST_FUNCTION( UtcDaliTextViewRemoveWordsFromGroup, POSITIVE_TC_IDX ); // Tests the remove words from a group of words operation.
1611 TEST_FUNCTION( UtcDaliTextViewRemoveGroupsFromLine, POSITIVE_TC_IDX ); // Tests the remove groups of words from a line operation.
1613 // Called only once before first test is run.
1614 static void Startup()
1618 // Called only once after last test is run
1619 static void Cleanup()
1623 static void UtcDaliTextViewCreateTextInfo()
1625 ToolkitTestApplication application;
1627 tet_infoline("UtcDaliTextViewCreateTextInfo : ");
1629 // Metrics for characters
1632 // size : [9.48351, 9.48351]
1633 // advance : 9.48351
1634 // bearing : 8.53516
1635 // ascender : 8.53516
1638 // size : [11.3802, 11.3802]
1639 // advance : 11.3802
1640 // bearing : 10.2422
1641 // ascender : 10.2422
1644 // size : [13.2769, 13.2769]
1645 // advance : 13.2769
1646 // bearing : 11.9492
1647 // ascender : 11.9492
1649 const float WIDTH_10( 9.48351f );
1650 const float HEIGHT_10( 9.48351f );
1651 const float ADVANCE_10( 9.48351f );
1652 const float BEARING_10( 8.53516f );
1653 const float ASCENDER_10( 8.53516f );
1655 const float WIDTH_12( 11.3802f );
1656 const float HEIGHT_12( 11.3802f );
1657 const float ADVANCE_12( 11.3802f );
1658 const float BEARING_12( 10.2422f );
1659 const float ASCENDER_12( 10.2422f );
1663 Toolkit::Internal::TextView::RelayoutData relayoutData;
1664 TextViewProcessor::TextLayoutInfo& textLayoutInfo( relayoutData.mTextLayoutInfo );
1666 std::string text( "Hel<font size='10'>lo wo</font>rld!\n"
1669 MarkupProcessor::StyledTextArray styledText;
1670 MarkupProcessor::GetStyledTextArray( text, styledText );
1672 TextViewProcessor::CreateTextInfo( styledText,
1673 DEFAULT_LAYOUT_PARAMETERS,
1677 // Build the text info with metric values.
1681 TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
1682 layoutInfo10.mHeight = HEIGHT_10;
1683 layoutInfo10.mAdvance = ADVANCE_10;
1684 layoutInfo10.mBearing = BEARING_10;
1685 layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
1686 layoutInfo10.mAscender = ASCENDER_10;
1687 TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
1688 layoutInfo12.mHeight = HEIGHT_12;
1689 layoutInfo12.mAdvance = ADVANCE_12;
1690 layoutInfo12.mBearing = BEARING_12;
1691 layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
1692 layoutInfo12.mAscender = ASCENDER_12;
1695 style10.SetFontPointSize( PointSize( 10.f ) );
1697 style12.SetFontPointSize( PointSize( 0.f ) ); // point size is set to zero because is a default point size.
1699 layoutInfo12.mStyledText.mStyle = style12;
1700 layoutInfo10.mStyledText.mStyle = style10;
1704 TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
1707 wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
1708 wordLayout1.mAscender = ASCENDER_12;
1709 wordLayout1.mType = TextViewProcessor::NoSeparator;
1711 layoutInfo12.mStyledText.mText = Text( "H" );
1712 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
1713 layoutInfo12.mStyledText.mText = Text( "e" );
1714 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
1715 layoutInfo12.mStyledText.mText = Text( "l" );
1716 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1717 layoutInfo10.mStyledText.mText = Text( "l" );
1718 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
1719 layoutInfo10.mStyledText.mText = Text( "o" );
1720 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1723 wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
1724 wordLayout2.mAscender = ASCENDER_10;
1725 wordLayout2.mType = TextViewProcessor::WordSeparator;
1726 layoutInfo10.mStyledText.mText = Text( " " );
1727 wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
1730 wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
1731 wordLayout3.mAscender = ASCENDER_12;
1732 wordLayout3.mType = TextViewProcessor::NoSeparator;
1733 layoutInfo10.mStyledText.mText = Text( "w" );
1734 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
1735 layoutInfo10.mStyledText.mText = Text( "o" );
1736 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1737 layoutInfo12.mStyledText.mText = Text( "r" );
1738 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
1739 layoutInfo12.mStyledText.mText = Text( "l" );
1740 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1741 layoutInfo12.mStyledText.mText = Text( "d" );
1742 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
1743 layoutInfo12.mStyledText.mText = Text( "!" );
1744 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
1746 // (new line character)
1747 wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
1748 wordLayout4.mAscender = ASCENDER_12;
1749 wordLayout4.mType = TextViewProcessor::LineSeparator;
1750 layoutInfo12.mStyledText.mText = Text( "\n" );
1751 layoutInfo12.mSize.width = 0.f;
1752 wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char)
1756 TextViewProcessor::WordGroupLayoutInfo groupLayout1, groupLayout2;
1758 groupLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1759 groupLayout1.mAscender = ASCENDER_12;
1760 groupLayout1.mDirection = TextViewProcessor::LTR;
1761 groupLayout1.mNumberOfCharacters = 13;
1762 groupLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
1763 groupLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
1764 groupLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
1765 groupLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
1767 groupLayout2.mSize = Size( 0.f, HEIGHT_12 );
1768 groupLayout2.mAscender = ASCENDER_12;
1769 groupLayout2.mDirection = TextViewProcessor::LTR;
1770 groupLayout2.mNumberOfCharacters = 1;
1771 groupLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
1775 TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3;
1777 lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1778 lineLayout1.mAscender = ASCENDER_12;
1779 lineLayout1.mNumberOfCharacters = 13;
1780 lineLayout1.mWordGroupsLayoutInfo.push_back( groupLayout1 );
1782 lineLayout2.mSize = Size( 0.f, HEIGHT_12 );
1783 lineLayout2.mAscender = ASCENDER_12;
1784 lineLayout2.mNumberOfCharacters = 1;
1785 lineLayout2.mWordGroupsLayoutInfo.push_back( groupLayout2 );
1787 lineLayout3.mSize = Size( 0.f, HEIGHT_12 );
1790 TextViewProcessor::TextLayoutInfo textLayout;
1792 textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
1793 textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
1794 textLayout.mNumberOfCharacters = 14;
1795 textLayout.mLinesLayoutInfo.push_back( lineLayout1 );
1796 textLayout.mLinesLayoutInfo.push_back( lineLayout2 );
1797 textLayout.mLinesLayoutInfo.push_back( lineLayout3 );
1799 if(!TestEqual( textLayout, textLayoutInfo ))
1801 std::cout << "Layout fails" << std::endl;
1802 Print(textLayout); std::cout << std::endl;
1803 Print(textLayoutInfo); std::cout << std::endl;
1806 DALI_TEST_CHECK( TestEqual( textLayout, textLayoutInfo ) );
1809 static void UtcDaliTextViewSplitWord()
1811 ToolkitTestApplication application;
1813 tet_infoline("UtcDaliTextViewSplitWord : ");
1815 struct SplitWordTest splitWordTests[] =
1818 std::string( "Split word, position 0." ),
1819 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1822 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1825 std::string( "Split word, position 8." ),
1826 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1828 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1832 std::string( "Split word, position 2." ),
1833 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1835 std::string( "<font size='10'>He</font>" ),
1836 std::string( "<font size='12'>ll</font><font size='10'>oooo</font>" ),
1839 std::string( "Split word, position 3." ),
1840 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1842 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
1843 std::string( "<font size='12'>l</font><font size='10'>oooo</font>" ),
1846 std::string( "Split word, position 4." ),
1847 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1849 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
1850 std::string( "<font size='10'>oooo</font>" ),
1853 const std::size_t numberOfTests( 5 );
1855 for( std::size_t index = 0; index < numberOfTests; ++index )
1857 const SplitWordTest& test = splitWordTests[index];
1859 if( !TestSplitWord( test.description, test.input, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
1861 tet_result( TET_FAIL );
1865 tet_result( TET_PASS );
1868 static void UtcDaliTextViewUpdateTextInfo()
1870 ToolkitTestApplication application;
1872 tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
1874 struct UpdateTextInfoTest updateTextInfoTest[] =
1876 // Remove operations
1879 std::string( "Remove from new line character to first character next line." ),
1881 std::string("Hello world\nhello world."),
1886 std::string("Hello worldello world."),
1889 std::string( "Replace style from new line character to first character next line." ),
1891 std::string("Hello world\nhello world."),
1894 std::string("<b>\nh</b>"),
1896 std::string("Hello world<b>\nh</b>ello world."),
1899 std::string( "Remove from the beginning to the middle of last word." ),
1901 std::string("Hello world, hello world."),
1904 std::string(), // Not used.
1909 std::string( "Remove from the beginning to the middle of the text." ),
1911 std::string("Hello world hello world."),
1914 std::string(), // Not used.
1916 std::string("hello world."),
1918 // Remove within the same word:
1919 // * within the same group of characters.
1921 std::string( "Remove within the same word, within the same group of characters" ),
1923 std::string("Hello <font size='30'>world\nhello</font> world"),
1926 std::string(), // Not used.
1928 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1930 // * whole group of characters (merge adjacent group of characters)
1932 std::string( "Remove within the same word, whole group of characters (merge adjacent group of characters)" ),
1934 std::string("Hello <font size='30'>w<font size='20'>orl</font>d\nhello</font> world"),
1937 std::string(), // Not used.
1939 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1941 // * whole group of characters (don't merge adjacent gtoup of characters)
1943 std::string( "Remove within the same word, whole group of characters (don't merge adjacent gtoup of characters)" ),
1945 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1948 std::string(), // Not used.
1950 std::string( "Hello <font size='30'>w</font><font size='10'>d\nhello</font> world" )
1952 // * Remove whole word (merge words)
1954 std::string( "Remove within the same word, whole word (merge words)" ),
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>orl<font size='10'>d\nhello</font> world" )
1963 // * Remove whole word (don't merge words)
1965 std::string( "Remove within the same word, whole word (don't 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='10'>\nhello</font> world" )
1974 // * Remove whole word (merge lines)
1976 std::string( "Remove within the same word, whole word (merge lines)" ),
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='30'>w</font>orl<font size='10'>dhello</font> world" )
1985 // * Remove whole group of words
1986 /* TODO check this when RTL text is working
1988 std::string( "Remove within the same line, whole group of words (merge groups)" ),
1990 std::string("Hello world, שלום עולם, hello world"),
1993 std::string(), // Not used.
1995 std::string( "Hello worlello world" )
1998 // * Remove whole line
2000 std::string( "Remove whole line" ),
2002 std::string("Hello world, hello world\n"
2003 "Hello world, hello world\n"
2004 "Hello world, hello world\n"
2005 "Hello world, hello world\n"),
2008 std::string(), // Not used.
2010 std::string("Hello world, hello world\n"
2011 "Hello world, hello world\n"
2012 "Hello world, hello world\n"),
2015 std::string( "Remove whole line" ),
2017 std::string("Hello world, hello world\n"
2021 std::string(), // Not used.
2023 std::string("Hello world, hello world\n"),
2027 // Insert operations
2029 std::string( "insert some text" ),
2031 std::string("inpuext"),
2034 std::string( "t t" ),
2036 std::string( "input text" )
2039 std::string( "Insert text at the end" ),
2041 std::string("touch "),
2044 std::string("me\nhello"),
2046 std::string("touch me\nhello")
2049 // Replace operations.
2051 std::string( "Replace style from the beginning to some point in the middle of the text." ),
2053 std::string( "Hello <font color='green'>world</font>" ),
2056 std::string( "<font color='red'>Hello w</font>" ),
2058 std::string( "<font color='red'>Hello w</font><font color='green'>orld</font>" )
2061 std::string( "Replace style from the middle of the text to the end." ),
2063 std::string( "Touch me\nhello" ),
2066 std::string( "<b>me\nhello</b>" ),
2068 std::string( "Touch <b>me\nhello</b>" )
2071 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 1." ),
2073 std::string( "Touch me\nhello\nworld" ),
2078 std::string( "Touch \nworld" )
2081 std::string( "Insert styled text in the middle of a text. Previous: Replace style from the middle of the text 1." ),
2083 std::string( "Touch \nworld" ),
2086 std::string( "<b>me\nhello</b>" ),
2088 std::string( "Touch <b>me\nhello</b>\nworld" )
2091 std::string( "Replace style from the middle of the text 1." ),
2093 std::string( "Touch me\nhello\nworld" ),
2096 std::string( "<b>me\nhello</b>" ),
2098 std::string( "Touch <b>me\nhello</b>\nworld" )
2101 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 2." ),
2103 std::string( "Touch me\nhello\nworld" ),
2108 std::string( "Touch world" )
2111 std::string( "Replace style from the middle of the text 2." ),
2113 std::string( "Touch me\nhello\nworld" ),
2116 std::string( "<b>me\nhello\n</b>" ),
2118 std::string( "Touch <b>me\nhello\n</b>world" )
2121 const std::size_t numberOfTests( 21 );
2123 for( std::size_t index = 0; index < numberOfTests; ++index )
2125 const UpdateTextInfoTest& test = updateTextInfoTest[index];
2127 if( !TestUpdateTextInfo( test.description, test.operation, test.input, test.position, test.numberOfCharacters, test.inputText, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2129 tet_result( TET_FAIL );
2133 tet_result( TET_PASS );
2136 static void UtcDaliTextViewSplitWordGroup()
2138 ToolkitTestApplication application;
2140 tet_infoline("UtcDaliTextViewSplitWordGroup : ");
2142 struct SplitWordGroupTest splitWordGroupTests[] =
2145 std::string( "Split word group, wordPosition 0, position 0." ),
2146 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2150 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2153 std::string( "Split word group, wordPosition 2, position 8." ),
2154 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2157 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2161 std::string( "Split word group, wordPosition 0, position 2." ),
2162 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2165 std::string( "<font size='10'>He</font>" ),
2166 std::string( "<font size='12'>ll</font><font size='10'>oooo wooorld</font>" ),
2169 std::string( "Split word group, wordPosition 0, position 3." ),
2170 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2173 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
2174 std::string( "<font size='12'>l</font><font size='10'>oooo wooorld</font>" ),
2177 std::string( "Split word group, wordPosition 0, position 4." ),
2178 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2181 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
2182 std::string( "<font size='10'>oooo wooorld</font>" ),
2185 std::string( "Split word group, wordPosition 1, position 0." ),
2186 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2189 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
2190 std::string( "<font size='10'> wooorld</font>" ),
2193 const std::size_t numberOfTests( 6 );
2195 for( std::size_t index = 0; index < numberOfTests; ++index )
2197 const SplitWordGroupTest& test = splitWordGroupTests[index];
2199 if( !TestSplitWordGroup( test.description, test.input, test.wordPosition, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
2201 tet_result( TET_FAIL );
2205 tet_result( TET_PASS );
2208 static void UtcDaliTextViewSplitLine()
2210 ToolkitTestApplication application;
2212 tet_infoline("UtcDaliTextViewSplitLine : ");
2214 struct SplitLineTest splitLineTests[] =
2217 std::string( "Split line, groupPosition 0, wordPosition 0, position 0." ),
2218 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2224 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2227 std::string( "Split line, groupPosition 2, wordPosition 2, position 4." ),
2228 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2233 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2236 /* TODO check when RTL is working.
2238 std::string( "Split line, groupPosition 1, wordPosition 2, position 0." ),
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> שלום" ),
2245 std::string( " עולם text text" ),
2248 std::string( "Split line, groupPosition 1, wordPosition 0, position 0." ),
2249 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2254 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
2255 std::string( "שלום עולם text text" ),
2259 std::string( "Split line, groupPosition 2, 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" ),
2269 const std::size_t numberOfTests( 3 );
2271 for( std::size_t index = 0; index < numberOfTests; ++index )
2273 const SplitLineTest& test = splitLineTests[index];
2275 if( !TestSplitLine( test.description, test.input, test.groupPosition, test.wordPosition, test.position, test.lineHeightOffset, test.firstResult, test.lastResult, TEST_LOCATION ) )
2277 tet_result( TET_FAIL );
2281 tet_result( TET_PASS );
2284 static void UtcDaliTextViewMergeWord01()
2286 ToolkitTestApplication application;
2288 tet_infoline("UtcDaliTextViewMergeWord01 : ");
2290 struct MergeWordsTest mergeWordsTests[] =
2293 std::string( "Merge words with same style." ),
2294 std::string( "Hel" ),
2295 std::string( "lo" ),
2296 std::string( "Hello" ),
2299 std::string( "Merge words with different styles." ),
2300 std::string( "<font size='10>Hel</font>" ),
2301 std::string( "<font size='20'>lo</font>" ),
2302 std::string( "<font size='10'>Hel</font><font size='20'>lo</font>" )
2305 const std::size_t numberOfTests( 2 );
2307 for( std::size_t index = 0; index < numberOfTests; ++index )
2309 const MergeWordsTest& test = mergeWordsTests[index];
2311 if( !TestMergeWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2313 tet_result( TET_FAIL );
2317 tet_result( TET_PASS );
2320 static void UtcDaliTextViewMergeWord02()
2323 // It test white spaces and new line characters can't be merged to other words.
2325 ToolkitTestApplication application;
2327 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2329 // Generate three words
2331 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2332 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2333 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2334 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2335 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2336 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2338 std::string text01( " " );
2339 std::string text02( "\n" );
2340 std::string text03( "a" );
2341 MarkupProcessor::StyledTextArray styledText01;
2342 MarkupProcessor::StyledTextArray styledText02;
2343 MarkupProcessor::StyledTextArray styledText03;
2344 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2345 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2346 MarkupProcessor::GetStyledTextArray( text03, styledText03 );
2348 TextViewProcessor::CreateTextInfo( styledText01,
2349 DEFAULT_LAYOUT_PARAMETERS,
2352 TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
2354 wordLayoutInfo01 = *( *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2356 TextViewProcessor::CreateTextInfo( styledText02,
2357 DEFAULT_LAYOUT_PARAMETERS,
2360 TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
2362 wordLayoutInfo02 = *( *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2364 TextViewProcessor::CreateTextInfo( styledText03,
2365 DEFAULT_LAYOUT_PARAMETERS,
2368 TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
2370 wordLayoutInfo03 = *( *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2372 // Test MergeWord() asserts if white spaces or new line chars are merged.
2373 bool assert1 = false;
2374 bool assert2 = false;
2375 bool assert3 = false;
2376 bool assert4 = false;
2377 bool assert5 = false;
2378 bool assert6 = false;
2382 MergeWord( wordLayoutInfo01,
2385 catch( Dali::DaliException& e )
2387 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2388 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
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( wordLayoutInfo02,
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( wordLayoutInfo03,
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 );
2447 if( assert1 && assert2 && assert3 && assert4 && assert5 && assert6 )
2449 tet_result( TET_PASS );
2453 tet_result( TET_FAIL );
2457 static void UtcDaliTextViewMergeGroup01()
2459 ToolkitTestApplication application;
2461 tet_infoline("UtcDaliTextViewMergeGroup01 : ");
2463 struct MergeWordGroupsTest mergeWordGroupssTests[] =
2466 std::string( "Merge a void first group." ),
2468 std::string( "Hello world" ),
2469 std::string( "Hello world" ),
2472 std::string( "Merge a void last group." ),
2473 std::string( "Hello world" ),
2475 std::string( "Hello world" ),
2478 std::string( "Merge groups and merge last and first words." ),
2479 std::string( "Hello wor" ),
2480 std::string( "ld, hello world" ),
2481 std::string( "Hello world, hello world" ),
2484 std::string( "Merge groups and don't merge last and first words." ),
2485 std::string( "Hello world, " ),
2486 std::string( "hello world" ),
2487 std::string( "Hello world, hello world" )
2490 const std::size_t numberOfTests( 4 );
2492 for( std::size_t index = 0; index < numberOfTests; ++index )
2494 const MergeWordGroupsTest& test = mergeWordGroupssTests[index];
2496 if( !TestMergeGroupsOfWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2498 tet_result( TET_FAIL );
2502 tet_result(TET_PASS);
2505 static void UtcDaliTextViewMergeGroup02()
2507 ToolkitTestApplication application;
2509 tet_infoline("UtcDaliTextViewMergeGroup02 : ");
2511 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2512 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2513 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2514 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2515 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2516 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2518 std::string text01( "Hello \n" );
2519 std::string text02( "world" );
2520 std::string text03( "السلام عليكم" );
2521 MarkupProcessor::StyledTextArray styledText01;
2522 MarkupProcessor::StyledTextArray styledText02;
2523 MarkupProcessor::StyledTextArray styledText03;
2524 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2525 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2526 MarkupProcessor::GetStyledTextArray( text03, styledText03 );
2528 TextViewProcessor::CreateTextInfo( styledText01,
2529 DEFAULT_LAYOUT_PARAMETERS,
2532 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo01;
2534 wordGroupLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2536 TextViewProcessor::CreateTextInfo( styledText02,
2537 DEFAULT_LAYOUT_PARAMETERS,
2540 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo02;
2542 wordGroupLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2544 TextViewProcessor::CreateTextInfo( styledText03,
2545 DEFAULT_LAYOUT_PARAMETERS,
2548 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo03;
2550 wordGroupLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2552 bool assert1 = false;
2553 bool assert2 = false;
2557 MergeWordGroup( wordGroupLayoutInfo01,
2558 wordGroupLayoutInfo02 );
2560 catch( Dali::DaliException& e )
2562 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2563 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 );
2569 MergeWordGroup( wordGroupLayoutInfo03,
2570 wordGroupLayoutInfo02 );
2572 catch( Dali::DaliException& e )
2574 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2575 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWordGroup(). ERROR: groups with different direction can't be merged.\"", TEST_LOCATION );
2579 if( assert1 && assert2 )
2581 tet_result( TET_PASS );
2585 tet_result( TET_FAIL );
2589 static void UtcDaliTextViewMergeLine01()
2591 ToolkitTestApplication application;
2593 tet_infoline("UtcDaliTextViewMergeLine01 : ");
2595 struct MergeLinesTest mergeLinesTests[] =
2598 std::string( "Merge a void first line." ),
2600 std::string( "Hello world, this is a whole line" ),
2602 std::string( "Hello world, this is a whole line" )
2605 std::string( "Merge a void last line." ),
2606 std::string( "Hello world, this is a whole line" ),
2609 std::string( "Hello world, this is a whole line" )
2611 /* TODO: check when RTL text is working.
2613 std::string( "Merge lines and merge last and first groups" ),
2614 std::string( "Hello world, שלום" ),
2615 std::string( " עולם, hello world." ),
2617 std::string( "Hello world, שלום עולם, hello world." )
2620 std::string( "Merge lines and don't merge last and first words." ),
2621 std::string( "Hello world, " ),
2622 std::string( "שלום עולם, hello world." ),
2624 std::string( "Hello world, שלום עולם, hello world." )
2628 std::string( "Merge lines. Don't merge words" ),
2629 std::string( "Hello world," ),
2630 std::string( " this is a whole line" ),
2632 std::string( "Hello world, this is a whole line" )
2635 std::string( "Merge lines. Merge words" ),
2636 std::string( "Hello world, th" ),
2637 std::string( "is is a whole line" ),
2639 std::string( "Hello world, this is a whole line" )
2642 const std::size_t numberOfTests( 4 );
2644 for( std::size_t index = 0; index < numberOfTests; ++index )
2646 const MergeLinesTest& test = mergeLinesTests[index];
2648 if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2650 tet_result( TET_FAIL );
2654 tet_result( TET_PASS );
2657 static void UtcDaliTextViewMergeLine02()
2659 ToolkitTestApplication application;
2661 tet_infoline("UtcDaliTextViewMergeLine02 : ");
2663 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2664 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2665 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2666 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2668 std::string text01( "Hello world\n" );
2669 std::string text02( "hello world" );
2670 MarkupProcessor::StyledTextArray styledText01;
2671 MarkupProcessor::StyledTextArray styledText02;
2672 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2673 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2675 TextViewProcessor::CreateTextInfo( styledText01,
2676 DEFAULT_LAYOUT_PARAMETERS,
2679 TextViewProcessor::LineLayoutInfo lineLayoutInfo01;
2681 lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin();
2683 TextViewProcessor::CreateTextInfo( styledText02,
2684 DEFAULT_LAYOUT_PARAMETERS,
2687 TextViewProcessor::LineLayoutInfo lineLayoutInfo02;
2689 lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin();
2691 bool assert1 = false;
2695 MergeLine( lineLayoutInfo01,
2698 catch( Dali::DaliException& e )
2700 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2701 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 );
2707 tet_result( TET_PASS );
2711 tet_result( TET_FAIL );
2715 void UtcDaliTextViewRemoveCharactersFromWord()
2717 ToolkitTestApplication application;
2719 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2721 struct RemoveCharactersFromWordTest removeCharactersFromWordTests[] =
2724 std::string( "Delete 0 characters." ),
2725 std::string( "Hello" ),
2728 std::string( "Hello" ),
2731 std::string( "Delete within the same group of characters. Starting from the beginning" ),
2732 std::string( "Hello" ),
2735 std::string( "lo" ),
2738 std::string( "Delete within the same group of characters. Somewhere in the middle" ),
2739 std::string( "Hello" ),
2742 std::string( "Heo" ),
2745 std::string( "Delete within the same group of characters. Starting somewhere in the middle to the end" ),
2746 std::string( "Hello" ),
2749 std::string( "Hel" ),
2752 std::string( "Delete within the same group of characters. Finish just before a new one." ),
2753 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2756 std::string( "<font size='10'>H</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2759 std::string( "Delete starting in one group of characters and finishing in a different one. No merge of groups." ),
2760 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2763 std::string( "<font size='10'>He</font><font size='20'>Wo</font><font size='30'>rld</font>" ),
2766 std::string( "Delete within the same group of characters. Starting just after a different one." ),
2767 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2770 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>d</font>" ),
2773 std::string( "Delete whole group of characters. No merge" ),
2774 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2777 std::string( "<font size='10'>Hel</font><font size='30'>rld</font>" ),
2780 std::string( "Delete whole group of characters and part of the adjacent ones. No merge" ),
2781 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2784 std::string( "<font size='10'>He</font><font size='30'>ld</font>" ),
2787 std::string( "Delete whole group of characters. Merge" ),
2788 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2791 std::string( "<font size='10'>Helrld</font>" ),
2794 std::string( "Delete whole group of characters and part of the adjacent ones. Merge" ),
2795 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2798 std::string( "<font size='10'>Held</font>" ),
2801 const std::size_t numberOfTests( 11 );
2803 for( std::size_t index = 0; index < numberOfTests; ++index )
2805 const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
2807 if( !TestRemoveCharactersFromWord( test.description, test.input, test.position, test.numberOfCharacters, test.result, TEST_LOCATION ) )
2809 tet_result( TET_FAIL );
2813 tet_result( TET_PASS );
2816 static void UtcDaliTextViewRemoveWordsFromGroup()
2818 // Note: Currently RemoveWordsFromWordGroup() function is only used to remove a number of words from the beginning, or
2819 // from a given index to the end. RemoveWordsFromWordGroup() doesn't merge words (if a white space is removed) so
2820 // tehere isn't any TET case to cover these cases. To be done if needed.
2822 ToolkitTestApplication application;
2824 tet_infoline("UtcDaliTextViewRemoveWordsFromGroup : ");
2825 struct RemoveWordsFromGroupTest removeWordsFromGroupTests[] =
2828 std::string( "Delete 0 words." ),
2829 std::string( "Hello world, hello world" ),
2832 std::string( "Hello world, hello world" ),
2835 std::string( "Delete some words in the middle. Don't merge words" ),
2836 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2839 std::string( "<font size='10'>Hel</font><font size='20'>lo</font><font size='30'> world</font>" ),
2842 std::string( "Delete words up to the end" ),
2843 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2846 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello</font>" ),
2849 std::string( "Delete words from the beginning." ),
2850 std::string( "Hello world, hello world" ),
2853 std::string( " hello world" ),
2856 const std::size_t numberOfTests( 4 );
2858 for( std::size_t index = 0; index < numberOfTests; ++index )
2860 const RemoveWordsFromGroupTest& test = removeWordsFromGroupTests[index];
2862 if( !TestRemoveWordsFromGroup( test.description, test.input, test.wordIndex, test.numberOfWords, test.result, TEST_LOCATION ) )
2864 tet_result( TET_FAIL );
2868 tet_result( TET_PASS );
2871 static void UtcDaliTextViewRemoveGroupsFromLine()
2873 // Note: Currently RemoveWordGroupsFromLine() function is only used to remove a number of group of words from the beginning, or
2874 // from a given index to the end. RemoveWordGroupsFromLine() doesn't merge groups of words (if a whole group of words is removed) so
2875 // tehere isn't any TET case to cover these cases. To be done if needed.
2877 ToolkitTestApplication application;
2879 tet_infoline("UtcDaliTextViewRemoveGroupsFromLine : ");
2880 struct RemoveGroupsFromLineTest removeGroupsFromLineTests[] =
2883 std::string( "Delete 0 groups of words." ),
2884 std::string( "Hello hello, שלום עולם hello hello" ),
2888 std::string( "Hello hello, שלום עולם hello hello" ),
2891 std::string( "Delete from the middle to the end." ),
2892 std::string( "Hello hello, שלום עולם hello hello" ),
2896 std::string( "Hello hello, " ),
2899 std::string( "Delete from the beginning to the middle." ),
2900 std::string( "Hello hello, שלום עולם hello hello" ),
2904 std::string( "hello hello" ),
2907 const std::size_t numberOfTests( 3 );
2909 for( std::size_t index = 0; index < numberOfTests; ++index )
2911 const RemoveGroupsFromLineTest& test = removeGroupsFromLineTests[index];
2913 if( !TestRemoveGroupsFromLine( test.description, test.input, test.groupIndex, test.numberOfGroups, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2915 tet_result( TET_FAIL );
2919 tet_result( TET_PASS );