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 if( character.mTextActor )
162 std::cout << "[" << character.mTextActor.GetText() << "]";
166 std::cout << "{" << character.mStyledText.mText.GetText() << "}";
170 void Print( const TextViewProcessor::WordLayoutInfo& word )
173 std::cout << " mSize : " << word.mSize << std::endl;
174 std::cout << " mAscender : " << word.mAscender << std::endl;
175 std::cout << " mType : " << word.mType << std::endl;
176 std::cout << "mNumberOfCharacters : " << word.mCharactersLayoutInfo.size() << std::endl;
178 for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it )
182 std::cout << "]"; std::cout << std::endl;
183 std::cout << "]"; std::cout << std::endl;
186 void Print( const TextViewProcessor::WordGroupLayoutInfo& wordGroup )
189 std::cout << " mSize : " << wordGroup.mSize << std::endl;
190 std::cout << " mAscender : " << wordGroup.mAscender << std::endl;
191 std::cout << " mDirection : " << wordGroup.mDirection << std::endl;
192 std::cout << "mNumberOfCharacters : " << wordGroup.mNumberOfCharacters << std::endl;
193 for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = wordGroup.mWordsLayoutInfo.begin(), endIt = wordGroup.mWordsLayoutInfo.end(); it != endIt; ++it )
197 std::cout << ")"; std::cout << std::endl;
200 void Print( const TextViewProcessor::LineLayoutInfo& line )
203 std::cout << " mSize : " << line.mSize << std::endl;
204 std::cout << " mAscender : " << line.mAscender << std::endl;
205 std::cout << "mNumberOfCharacters : " << line.mNumberOfCharacters << std::endl;
206 for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it = line.mWordGroupsLayoutInfo.begin(), endIt = line.mWordGroupsLayoutInfo.end(); it != endIt; ++it )
210 std::cout << ">" << std::endl;
213 void Print( const TextViewProcessor::TextLayoutInfo& text )
216 for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it = text.mLinesLayoutInfo.begin(), endIt = text.mLinesLayoutInfo.end(); it != endIt; ++it )
220 std::cout << "||" << std::endl;
223 void Print( const TextStyle& style )
225 std::cout << " font name : " << style.GetFontName() << std::endl;
226 std::cout << " : " << style.GetFontStyle() << std::endl;
227 std::cout << " : " << style.GetFontPointSize() << std::endl;
228 std::cout << " : " << style.GetWeight() << std::endl;
229 std::cout << " : " << style.GetTextColor() << std::endl;
230 std::cout << " : " << style.GetItalics() << std::endl;
231 std::cout << " : " << style.GetUnderline() << std::endl;
232 std::cout << " : " << style.GetShadow() << std::endl;
233 std::cout << " : " << style.GetShadowColor() << std::endl;
234 std::cout << " : " << style.GetShadowOffset() << std::endl;
235 std::cout << " : " << style.GetGlow() << std::endl;
236 std::cout << " : " << style.GetGlowColor() << std::endl;
237 std::cout << " : " << style.GetGlowIntensity() << std::endl;
238 std::cout << " : " << style.GetSmoothEdge() << std::endl;
239 std::cout << " : " << style.GetOutline() << std::endl;
240 std::cout << " : " << style.GetOutlineThickness() << std::endl;
243 // Test functions used to check if two data structures are equal.
245 bool TestEqual( float x, float y )
247 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
250 bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
251 const TextViewProcessor::CharacterLayoutInfo& character2 )
253 if( !TestEqual( character1.mHeight, character2.mHeight ) )
257 if( !TestEqual( character1.mAdvance, character2.mAdvance ) )
261 if( !TestEqual( character1.mBearing, character2.mBearing ) )
266 if( !TestEqual( character1.mPosition.x, character2.mPosition.x ) )
270 if( !TestEqual( character1.mPosition.y, character2.mPosition.y ) )
275 if( !TestEqual( character1.mSize.x, character2.mSize.x ) )
279 if( !TestEqual( character1.mSize.y, character2.mSize.y ) )
284 if( !TestEqual( character1.mAscender, character2.mAscender ) )
289 if( character1.mTextActor && !character2.mTextActor )
294 if( !character1.mTextActor && character2.mTextActor )
304 if( character1.mTextActor )
306 text1 = character1.mTextActor.GetText();
307 style1 = character1.mTextActor.GetTextStyle();
309 text2 = character2.mTextActor.GetText();
310 style2 = character2.mTextActor.GetTextStyle();
318 if( style1 != style2 )
323 text1 = character1.mStyledText.mText.GetText();
324 style1 = character1.mStyledText.mStyle;
326 text2 = character2.mStyledText.mText.GetText();
327 style2 = character2.mStyledText.mStyle;
334 if( style1 != style2 )
342 bool TestEqual( const TextViewProcessor::WordLayoutInfo& word1,
343 const TextViewProcessor::WordLayoutInfo& word2 )
345 if( !TestEqual( word1.mSize.x, word2.mSize.x ) )
349 if( !TestEqual( word1.mSize.y, word2.mSize.y ) )
354 if( !TestEqual( word1.mAscender, word2.mAscender ) )
359 if( word1.mType != word2.mType )
364 if( word1.mCharactersLayoutInfo.size() != word2.mCharactersLayoutInfo.size() )
369 for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it1 = word1.mCharactersLayoutInfo.begin(), endIt1 = word1.mCharactersLayoutInfo.end(),
370 it2 = word2.mCharactersLayoutInfo.begin(), endIt2 = word2.mCharactersLayoutInfo.end();
371 ( it1 != endIt1 ) && ( it2 != endIt2 );
374 if( !TestEqual( *it1, *it2 ) )
383 bool TestEqual( const TextViewProcessor::WordGroupLayoutInfo& group1,
384 const TextViewProcessor::WordGroupLayoutInfo& group2 )
387 if( group1.mNumberOfCharacters != group2.mNumberOfCharacters )
392 if( group1.mWordsLayoutInfo.size() != group2.mWordsLayoutInfo.size() )
397 if( !TestEqual( group1.mSize.x, group2.mSize.x ) )
401 if( !TestEqual( group1.mSize.y, group2.mSize.y ) )
406 if( !TestEqual( group1.mAscender, group2.mAscender ) )
411 if( group1.mDirection != group2.mDirection )
416 for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = group1.mWordsLayoutInfo.begin(), endIt1 = group1.mWordsLayoutInfo.end(),
417 it2 = group2.mWordsLayoutInfo.begin(), endIt2 = group2.mWordsLayoutInfo.end();
418 ( it1 != endIt1 ) && ( it2 != endIt2 );
421 if( !TestEqual( *it1, *it2 ) )
430 bool TestEqual( const TextViewProcessor::LineLayoutInfo& line1,
431 const TextViewProcessor::LineLayoutInfo& line2 )
433 if( !TestEqual( line1.mSize.x, line2.mSize.x ) )
437 if( !TestEqual( line1.mSize.y, line2.mSize.y ) )
442 if( !TestEqual( line1.mAscender, line2.mAscender ) )
447 if( line1.mNumberOfCharacters != line2.mNumberOfCharacters )
452 if( line1.mWordGroupsLayoutInfo.size() != line2.mWordGroupsLayoutInfo.size() )
457 for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it1 = line1.mWordGroupsLayoutInfo.begin(), endIt1 = line1.mWordGroupsLayoutInfo.end(),
458 it2 = line2.mWordGroupsLayoutInfo.begin(), endIt2 = line2.mWordGroupsLayoutInfo.end();
459 ( it1 != endIt1 ) && ( it2 != endIt2 );
462 if( !TestEqual( *it1, *it2 ) )
471 bool TestEqual( const TextViewProcessor::TextLayoutInfo& text1,
472 const TextViewProcessor::TextLayoutInfo& text2 )
474 if( !TestEqual( text1.mWholeTextSize.x, text2.mWholeTextSize.x ) )
478 if( !TestEqual( text1.mWholeTextSize.y, text2.mWholeTextSize.y ) )
483 if( !TestEqual( text1.mMaxWordWidth, text2.mMaxWordWidth ) )
488 if( text1.mNumberOfCharacters != text2.mNumberOfCharacters )
493 if( text1.mLinesLayoutInfo.size() != text2.mLinesLayoutInfo.size() )
498 for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it1 = text1.mLinesLayoutInfo.begin(), endIt1 = text1.mLinesLayoutInfo.end(),
499 it2 = text2.mLinesLayoutInfo.begin(), endIt2 = text2.mLinesLayoutInfo.end();
500 ( it1 != endIt1 ) && ( it2 != endIt2 );
503 if( !TestEqual( *it1, *it2 ) )
513 * Splits the \e input word in two by the given \e position and checks the results with \e firstResult and \e lastResult.
515 * If the test fails it prints a short description and the line where this function was called.
517 * @param description Short description of the experiment. i.e. "Split the word from the beginning. (position 0)".
518 * @param input The input word.
519 * @param position Where to split the word.
520 * @param firstResult First part of the split word.
521 * @param lastResult Last part of the split word.
522 * @param location Where this function has been called.
524 * @return \e true if the experiment is successful. Otherwise returns \e false.
526 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 )
528 tet_printf( "%s", description.c_str() );
530 // Create layout info for the input word.
531 Toolkit::Internal::TextView::RelayoutData relayoutData;
532 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
534 MarkupProcessor::StyledTextArray inputStyledText;
535 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
537 TextViewProcessor::CreateTextInfo( inputStyledText,
538 DEFAULT_LAYOUT_PARAMETERS,
541 // Get the input word
542 TextViewProcessor::WordLayoutInfo inputWordLayout;
544 if( !inputLayout.mLinesLayoutInfo.empty() )
546 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
547 if( !line.mWordGroupsLayoutInfo.empty() )
549 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
550 if( !group.mWordsLayoutInfo.empty() )
552 inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
557 // Create layout info for the first part of the result (after split the word)
559 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
560 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
562 MarkupProcessor::StyledTextArray firstResultStyledText;
563 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText );
565 TextViewProcessor::CreateTextInfo( firstResultStyledText,
566 DEFAULT_LAYOUT_PARAMETERS,
569 // Get the first result word
570 TextViewProcessor::WordLayoutInfo firstResultWordLayout;
572 if( !firstResultLayout.mLinesLayoutInfo.empty() )
574 const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
575 if( !line.mWordGroupsLayoutInfo.empty() )
577 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
578 if( !group.mWordsLayoutInfo.empty() )
580 firstResultWordLayout = *( *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
585 // Create layout info for the last part of the result (after split the word)
587 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
588 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
590 MarkupProcessor::StyledTextArray lastResultStyledText;
591 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText );
593 TextViewProcessor::CreateTextInfo( lastResultStyledText,
594 DEFAULT_LAYOUT_PARAMETERS,
597 // Get the last result word
598 TextViewProcessor::WordLayoutInfo lastResultWordLayout;
600 if( !lastResultLayout.mLinesLayoutInfo.empty() )
602 const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
603 if( !line.mWordGroupsLayoutInfo.empty() )
605 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
606 if( !group.mWordsLayoutInfo.empty() )
608 lastResultWordLayout = *( *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
615 TextViewProcessor::WordLayoutInfo lastWordLayoutInfo;
619 lastWordLayoutInfo );
622 if( !TestEqual( inputWordLayout, firstResultWordLayout ) )
624 tet_printf( "Fail. different layout info. %s", location );
628 if( !TestEqual( lastWordLayoutInfo, lastResultWordLayout ) )
630 tet_printf( "Fail. different layout info. %s", location );
638 * 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.
640 * If the test fails it prints a short description and the line where this function was called.
642 * @param description Short description of the experiment. i.e. "Split the group of words from the beginning. (wordPosition 0 and position 0)".
643 * @param input The input word.
644 * @param wordPosition Index to the word within the group where to split the group.
645 * @param position Where to split the word.
646 * @param firstResult First part of the split group of words.
647 * @param lastResult Last part of the split group of words.
648 * @param location Where this function has been called.
650 * @return \e true if the experiment is successful. Otherwise returns \e false.
652 bool TestSplitWordGroup( const std::string& description,
653 const std::string& input,
654 const size_t wordPosition,
655 const size_t position,
656 const std::string& firstResult,
657 const std::string& lastResult,
658 const char* location )
660 tet_printf( "%s", description.c_str() );
662 // Create layout info for the input group of words.
663 Toolkit::Internal::TextView::RelayoutData relayoutData;
664 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
666 MarkupProcessor::StyledTextArray inputStyledText;
667 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
669 TextViewProcessor::CreateTextInfo( inputStyledText,
670 DEFAULT_LAYOUT_PARAMETERS,
673 // Get the input group of words
674 TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
676 if( !inputLayout.mLinesLayoutInfo.empty() )
678 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
679 if( !line.mWordGroupsLayoutInfo.empty() )
681 inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
685 // Create layout info for the first part of the result (after split the group of words)
687 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
688 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
690 MarkupProcessor::StyledTextArray firstResultStyledText;
691 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText );
693 TextViewProcessor::CreateTextInfo( firstResultStyledText,
694 DEFAULT_LAYOUT_PARAMETERS,
697 // Get the first result group of words
698 TextViewProcessor::WordGroupLayoutInfo firstResultWordGroupLayout;
700 if( !firstResultLayout.mLinesLayoutInfo.empty() )
702 const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
703 if( !line.mWordGroupsLayoutInfo.empty() )
705 firstResultWordGroupLayout = *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
709 // Create layout info for the last part of the result (after split the group of words)
711 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
712 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
714 MarkupProcessor::StyledTextArray lastResultStyledText;
715 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText );
717 TextViewProcessor::CreateTextInfo( lastResultStyledText,
718 DEFAULT_LAYOUT_PARAMETERS,
721 // Get the last result group of words
722 TextViewProcessor::WordGroupLayoutInfo lastResultWordGroupLayout;
724 if( !lastResultLayout.mLinesLayoutInfo.empty() )
726 const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
727 if( !line.mWordGroupsLayoutInfo.empty() )
729 lastResultWordGroupLayout = *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
733 // Split the group of words.
735 TextViewProcessor::WordGroupLayoutInfo lastWordGroupLayoutInfo;
737 TextViewProcessor::TextInfoIndices indices( 0, 0, wordPosition, position );
738 SplitWordGroup( indices,
739 inputWordGroupLayout,
740 lastWordGroupLayoutInfo );
743 if( !TestEqual( inputWordGroupLayout, firstResultWordGroupLayout ) )
745 tet_printf( "Fail. different layout info. %s", location );
749 if( !TestEqual( lastWordGroupLayoutInfo, lastResultWordGroupLayout ) )
751 tet_printf( "Fail. different layout info. %s", location );
759 * 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.
761 * If the test fails it prints a short description and the line where this function was called.
763 * @param description Short description of the experiment. i.e. "Split the line from the beginning. (groupPosition 0, wordPosition 0 and position 0)".
764 * @param input The input word.
765 * @param groupPosition Index to the group of words within the line where to split the line.
766 * @param wordPosition Index to the word within the group where to split the group.
767 * @param position Where to split the word.
768 * @param lineHeightOffset Offset between lines.
769 * @param firstResult First part of the split line.
770 * @param lastResult Last part of the split line.
771 * @param location Where this function has been called.
773 * @return \e true if the experiment is successful. Otherwise returns \e false.
775 bool TestSplitLine( const std::string& description,
776 const std::string& input,
777 const size_t groupPosition,
778 const size_t wordPosition,
779 const size_t position,
780 const float lineHeightOffset,
781 const std::string& firstResult,
782 const std::string& lastResult,
783 const char* location )
785 tet_printf( "%s", description.c_str() );
787 // Create layout info for the input line.
788 Toolkit::Internal::TextView::RelayoutData relayoutData;
789 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
791 MarkupProcessor::StyledTextArray inputStyledText;
792 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
794 TextViewProcessor::CreateTextInfo( inputStyledText,
795 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
796 Toolkit::TextView::Original,
797 Toolkit::TextView::Original,
798 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
799 Toolkit::TextView::Center,
800 PointSize( lineHeightOffset ),
801 std::string( "..." ) ),
804 // Get the input line
805 TextViewProcessor::LineLayoutInfo inputLineLayout;
807 if( !inputLayout.mLinesLayoutInfo.empty() )
809 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
812 // Create layout info for the first part of the result (after split the line)
814 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
815 TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
817 MarkupProcessor::StyledTextArray firstResultStyledText;
818 MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText );
820 TextViewProcessor::CreateTextInfo( firstResultStyledText,
821 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
822 Toolkit::TextView::Original,
823 Toolkit::TextView::Original,
824 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
825 Toolkit::TextView::Center,
826 PointSize( lineHeightOffset ),
827 std::string( "..." ) ),
830 // Get the first result line
831 TextViewProcessor::LineLayoutInfo firstResultLineLayout;
833 if( !firstResultLayout.mLinesLayoutInfo.empty() )
835 firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin();
838 // Create layout info for the last part of the result (after split the line)
840 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
841 TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
843 MarkupProcessor::StyledTextArray lastResultStyledText;
844 MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText );
846 TextViewProcessor::CreateTextInfo( lastResultStyledText,
847 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
848 Toolkit::TextView::Original,
849 Toolkit::TextView::Original,
850 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
851 Toolkit::TextView::Center,
852 PointSize( lineHeightOffset ),
853 std::string( "..." ) ),
856 // Get the last result line
857 TextViewProcessor::LineLayoutInfo lastResultLineLayout;
859 if( !lastResultLayout.mLinesLayoutInfo.empty() )
861 lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin();
866 TextViewProcessor::LineLayoutInfo lastLineLayoutInfo;
868 TextViewProcessor::TextInfoIndices indices( 0, groupPosition, wordPosition, position );
870 PointSize( lineHeightOffset ),
872 lastLineLayoutInfo );
875 if( !TestEqual( inputLineLayout, firstResultLineLayout ) )
877 tet_printf( "Fail. different layout info. %s", location );
881 if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) )
883 tet_printf( "Fail. different layout info. %s", location );
891 * Merges the \e inputFirst word and the \e inputLast word, and checks the results with \e result.
893 * If the test fails it prints a short description and the line where this function was called.
895 * @param description Short description of the experiment. i.e. "Merge two words with same style".
896 * @param inputFirst The first part of the word.
897 * @param inputLast The last part of the word.
898 * @param result The merged word.
899 * @param location Where this function has been called.
901 * @return \e true if the experiment is successful. Otherwise returns \e false.
903 bool TestMergeWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
905 tet_printf( "%s", description.c_str() );
907 // Create layout info for the inputFirst word.
908 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
909 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
911 MarkupProcessor::StyledTextArray inputFirstStyledText;
912 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
914 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
915 DEFAULT_LAYOUT_PARAMETERS,
918 // Get the input word
919 TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
921 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
923 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
924 if( !line.mWordGroupsLayoutInfo.empty() )
926 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
927 if( !group.mWordsLayoutInfo.empty() )
929 inputFirstWordLayout = *( *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
934 // Create layout info for the inputLast word.
935 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
936 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
938 MarkupProcessor::StyledTextArray inputLastStyledText;
939 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
941 TextViewProcessor::CreateTextInfo( inputLastStyledText,
942 DEFAULT_LAYOUT_PARAMETERS,
945 // Get the input word
946 TextViewProcessor::WordLayoutInfo inputLastWordLayout;
948 if( !inputLastLayout.mLinesLayoutInfo.empty() )
950 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
951 if( !line.mWordGroupsLayoutInfo.empty() )
953 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
954 if( !group.mWordsLayoutInfo.empty() )
956 inputLastWordLayout = *( *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
961 // Create layout info for the result word.
962 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
963 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
965 MarkupProcessor::StyledTextArray resultStyledText;
966 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
968 TextViewProcessor::CreateTextInfo( resultStyledText,
969 DEFAULT_LAYOUT_PARAMETERS,
970 resultRelayoutData );
972 // Get the result word
973 TextViewProcessor::WordLayoutInfo resultWordLayout;
975 if( !resultLayout.mLinesLayoutInfo.empty() )
977 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
978 if( !line.mWordGroupsLayoutInfo.empty() )
980 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
981 if( !group.mWordsLayoutInfo.empty() )
983 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
988 MergeWord( inputFirstWordLayout,
989 inputLastWordLayout );
991 if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
993 tet_printf( "Fail. different layout info. %s", location );
1001 * Merges the \e inputFirst group of words and the \e inputLast group of words, and checks the results with \e result.
1003 * If the test fails it prints a short description and the line where this function was called.
1005 * @param description Short description of the experiment.
1006 * @param inputFirst The first part of the group of words.
1007 * @param inputLast The last part of the group of words.
1008 * @param result The merged group of word.
1009 * @param location Where this function has been called.
1011 * @return \e true if the experiment is successful. Otherwise returns \e false.
1013 bool TestMergeGroupsOfWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
1015 tet_printf( "%s", description.c_str() );
1017 // Create layout info for the inputFirst group of word.
1018 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1019 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1021 MarkupProcessor::StyledTextArray inputFirstStyledText;
1022 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
1024 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1025 DEFAULT_LAYOUT_PARAMETERS,
1026 firstRelayoutData );
1028 // Get the input group of words.
1029 TextViewProcessor::WordGroupLayoutInfo inputFirstWordGroupLayout;
1031 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1033 const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
1034 if( !line.mWordGroupsLayoutInfo.empty() )
1036 inputFirstWordGroupLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1040 // Create layout info for the inputLast group of words.
1041 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1042 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1044 MarkupProcessor::StyledTextArray inputLastStyledText;
1045 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
1047 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1048 DEFAULT_LAYOUT_PARAMETERS,
1051 // Get the input group of words
1052 TextViewProcessor::WordGroupLayoutInfo inputLastWordGroupLayout;
1054 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1056 const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
1057 if( !line.mWordGroupsLayoutInfo.empty() )
1059 inputLastWordGroupLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1063 // Create layout info for the result group of words.
1064 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1065 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1067 MarkupProcessor::StyledTextArray resultStyledText;
1068 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1070 TextViewProcessor::CreateTextInfo( resultStyledText,
1071 DEFAULT_LAYOUT_PARAMETERS,
1072 resultRelayoutData );
1074 // Get the result word
1075 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1077 if( !resultLayout.mLinesLayoutInfo.empty() )
1079 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1080 if( !line.mWordGroupsLayoutInfo.empty() )
1082 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1086 MergeWordGroup( inputFirstWordGroupLayout,
1087 inputLastWordGroupLayout );
1089 if( !TestEqual( inputFirstWordGroupLayout, resultWordGroupLayout ) )
1091 tet_printf( "Fail. different layout info. %s", location );
1099 * Merges the \e inputFirst line and the \e inputLast line, and checks the results with \e result.
1101 * If the test fails it prints a short description and the line where this function was called.
1103 * @param description Short description of the experiment.
1104 * @param inputFirst The first part of the line.
1105 * @param inputLast The last part of the line.
1106 * @param lineHeightOffset Offset between lines.
1107 * @param result The merged line.
1108 * @param location Where this function has been called.
1110 * @return \e true if the experiment is successful. Otherwise returns \e false.
1112 bool TestMergeLines( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
1114 tet_printf( "%s", description.c_str() );
1116 // Create layout info for the inputFirst line.
1117 Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
1118 TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
1120 MarkupProcessor::StyledTextArray inputFirstStyledText;
1121 MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText );
1123 TextViewProcessor::CreateTextInfo( inputFirstStyledText,
1124 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1125 Toolkit::TextView::Original,
1126 Toolkit::TextView::Original,
1127 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1128 Toolkit::TextView::Center,
1129 PointSize( lineHeightOffset ),
1130 std::string( "..." ) ),
1131 firstRelayoutData );
1133 // Get the input word
1134 TextViewProcessor::LineLayoutInfo inputFirstLineLayout;
1136 if( !inputFirstLayout.mLinesLayoutInfo.empty() )
1138 inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin();
1141 // Create layout info for the inputLast line.
1142 Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
1143 TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
1145 MarkupProcessor::StyledTextArray inputLastStyledText;
1146 MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText );
1148 TextViewProcessor::CreateTextInfo( inputLastStyledText,
1149 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1150 Toolkit::TextView::Original,
1151 Toolkit::TextView::Original,
1152 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1153 Toolkit::TextView::Center,
1154 PointSize( lineHeightOffset ),
1155 std::string( "..." ) ),
1158 // Get the input word
1159 TextViewProcessor::LineLayoutInfo inputLastLineLayout;
1161 if( !inputLastLayout.mLinesLayoutInfo.empty() )
1163 inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.begin();
1166 // Create layout info for the result word.
1167 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1168 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1170 MarkupProcessor::StyledTextArray resultStyledText;
1171 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1173 TextViewProcessor::CreateTextInfo( resultStyledText,
1174 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1175 Toolkit::TextView::Original,
1176 Toolkit::TextView::Original,
1177 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1178 Toolkit::TextView::Center,
1179 PointSize( lineHeightOffset ),
1180 std::string( "..." ) ),
1181 resultRelayoutData );
1183 // Get the result word
1184 TextViewProcessor::LineLayoutInfo resultLineLayout;
1186 if( !resultLayout.mLinesLayoutInfo.empty() )
1188 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1191 MergeLine( inputFirstLineLayout,
1192 inputLastLineLayout );
1194 if( !TestEqual( inputFirstLineLayout, resultLineLayout ) )
1196 tet_printf( "Fail. different layout info. %s", location );
1204 * Removes from the \e input word the \e numberOfCharacters characters starting from the given \e position and checks the results with \e result.
1206 * If the test fails it prints a short description and the line where this function was called.
1208 * @param description Short description of the experiment. i.e. "Remove a whole group of characters. Merge".
1209 * @param input The input word.
1210 * @param position Where to start to remove characters
1211 * @param numberOfCharacters The number of characters to remove.
1212 * @param result The word without the removed characters.
1213 * @param location Where this function has been called.
1215 * @return \e true if the experiment is successful. Otherwise returns \e false.
1217 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 )
1219 tet_printf( "%s", description.c_str() );
1221 // Create layout info for the input word.
1222 Toolkit::Internal::TextView::RelayoutData relayoutData;
1223 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1225 MarkupProcessor::StyledTextArray inputStyledText;
1226 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1228 TextViewProcessor::CreateTextInfo( inputStyledText,
1229 DEFAULT_LAYOUT_PARAMETERS,
1232 // Get the input word
1233 TextViewProcessor::WordLayoutInfo inputWordLayout;
1235 if( !inputLayout.mLinesLayoutInfo.empty() )
1237 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1238 if( !line.mWordGroupsLayoutInfo.empty() )
1240 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1241 if( !group.mWordsLayoutInfo.empty() )
1243 inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1248 // Create layout info for the result word.
1249 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1250 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1252 MarkupProcessor::StyledTextArray resultStyledText;
1253 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1255 TextViewProcessor::CreateTextInfo( resultStyledText,
1256 DEFAULT_LAYOUT_PARAMETERS,
1257 resultRelayoutData );
1259 // Get the result word
1260 TextViewProcessor::WordLayoutInfo resultWordLayout;
1262 if( !resultLayout.mLinesLayoutInfo.empty() )
1264 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1265 if( !line.mWordGroupsLayoutInfo.empty() )
1267 const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
1268 if( !group.mWordsLayoutInfo.empty() )
1270 resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
1275 RemoveCharactersFromWord( position,
1279 if( !TestEqual( inputWordLayout, resultWordLayout ) )
1281 tet_printf( "Fail. different layout info. %s", location );
1289 * 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.
1291 * If the test fails it prints a short description and the line where this function was called.
1293 * @param description Short description of the experiment.
1294 * @param input The input group of words.
1295 * @param wordIndex Where to start to remove words.
1296 * @param numberOfWords The number of words to remove.
1297 * @param result The group of words without the removed words.
1298 * @param location Where this function has been called.
1300 * @return \e true if the experiment is successful. Otherwise returns \e false.
1302 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 )
1304 tet_printf( "%s", description.c_str() );
1306 // Create layout info for the input group of words.
1307 Toolkit::Internal::TextView::RelayoutData relayoutData;
1308 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1310 MarkupProcessor::StyledTextArray inputStyledText;
1311 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1313 TextViewProcessor::CreateTextInfo( inputStyledText,
1314 DEFAULT_LAYOUT_PARAMETERS,
1317 // Get the input group of words
1318 TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
1320 if( !inputLayout.mLinesLayoutInfo.empty() )
1322 const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
1323 if( !line.mWordGroupsLayoutInfo.empty() )
1325 inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1329 // Create layout info for the result group of words.
1330 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1331 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1333 MarkupProcessor::StyledTextArray resultStyledText;
1334 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1336 TextViewProcessor::CreateTextInfo( resultStyledText,
1337 DEFAULT_LAYOUT_PARAMETERS,
1338 resultRelayoutData );
1340 // Get the result group of words.
1341 TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
1343 if( !resultLayout.mLinesLayoutInfo.empty() )
1345 const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
1346 if( !line.mWordGroupsLayoutInfo.empty() )
1348 resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
1352 RemoveWordsFromWordGroup( wordIndex,
1354 inputWordGroupLayout );
1356 if( !TestEqual( inputWordGroupLayout, resultWordGroupLayout ) )
1358 tet_printf( "Fail. different layout info. %s", location );
1367 * 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.
1369 * If the test fails it prints a short description and the line where this function was called.
1371 * @param description Short description of the experiment.
1372 * @param input The input line.
1373 * @param groupIndex Where to start to remove groups of words
1374 * @param numberOfGroups The number of groups of words to remove.
1375 * @param lineHeightOffset Offset between lines.
1376 * @param result The line without the removed groups of words.
1377 * @param location Where this function has been called.
1379 * @return \e true if the experiment is successful. Otherwise returns \e false.
1381 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 )
1383 tet_printf( "%s", description.c_str() );
1385 // Create layout info for the input line.
1386 Toolkit::Internal::TextView::RelayoutData relayoutData;
1387 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1389 MarkupProcessor::StyledTextArray inputStyledText;
1390 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1392 TextViewProcessor::CreateTextInfo( inputStyledText,
1393 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1394 Toolkit::TextView::Original,
1395 Toolkit::TextView::Original,
1396 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1397 Toolkit::TextView::Center,
1398 PointSize( lineHeightOffset ),
1399 std::string( "..." ) ),
1402 // Get the input line
1403 TextViewProcessor::LineLayoutInfo inputLineLayout;
1405 if( !inputLayout.mLinesLayoutInfo.empty() )
1407 inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
1410 // Create layout info for the result line.
1411 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1412 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1414 MarkupProcessor::StyledTextArray resultStyledText;
1415 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1417 TextViewProcessor::CreateTextInfo( resultStyledText,
1418 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1419 Toolkit::TextView::Original,
1420 Toolkit::TextView::Original,
1421 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1422 Toolkit::TextView::Center,
1423 PointSize( lineHeightOffset ),
1424 std::string( "..." ) ),
1425 resultRelayoutData );
1427 // Get the result line
1428 TextViewProcessor::LineLayoutInfo resultLineLayout;
1430 if( !resultLayout.mLinesLayoutInfo.empty() )
1432 resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
1435 RemoveWordGroupsFromLine( groupIndex,
1437 PointSize( lineHeightOffset ),
1440 if( !TestEqual( inputLineLayout, resultLineLayout ) )
1442 tet_printf( "Fail. different layout info. %s", location );
1450 * Tests inserts, removes and updates operation in the given \e input text and checks with the given \e result.
1452 * If the test fails it prints a short description and the line where this function was called.
1454 * @param description Short description of the experiment.
1455 * @param operation Type of update operation (insert, remove, replace)
1456 * @param input The input text.
1457 * @param position Where to insert, remove or replace text.
1458 * @param numberOfCharacters Number of characters to remove or replace.
1459 * @param inputText Inserted or updated text.
1460 * @param lineHeightOffset Offset between lines.
1461 * @param result Expected result.
1462 * @param location Where this function has been called.
1464 * @return \e true if the experiment is successful. Otherwise returns \e false.
1466 bool TestUpdateTextInfo( const std::string& description,
1467 const UpdateTextInfoOperation operation,
1468 const std::string& input,
1469 const std::size_t position,
1470 const std::size_t numberOfCharacters,
1471 const std::string& inputText,
1472 const float lineHeightOffset,
1473 const std::string& result,
1474 const char* location )
1476 tet_printf( "%s", description.c_str() );
1478 // Create layout info for the input.
1479 Toolkit::Internal::TextView::RelayoutData relayoutData;
1480 TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
1482 MarkupProcessor::StyledTextArray inputStyledText;
1483 MarkupProcessor::GetStyledTextArray( input, inputStyledText );
1485 TextViewProcessor::CreateTextInfo( inputStyledText,
1486 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1487 Toolkit::TextView::Original,
1488 Toolkit::TextView::Original,
1489 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1490 Toolkit::TextView::Center,
1491 PointSize( lineHeightOffset ),
1492 std::string( "..." ) ),
1495 // Create layout info for the result.
1496 Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
1497 TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
1499 MarkupProcessor::StyledTextArray resultStyledText;
1500 MarkupProcessor::GetStyledTextArray( result, resultStyledText );
1502 TextViewProcessor::CreateTextInfo( resultStyledText,
1503 Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
1504 Toolkit::TextView::Original,
1505 Toolkit::TextView::Original,
1506 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1507 Toolkit::TextView::Center,
1508 PointSize( lineHeightOffset ),
1509 std::string( "..." ) ),
1510 resultRelayoutData );
1512 // Choose operation and call appropiate UpdateTextInfo() method.
1513 const Toolkit::Internal::TextView::LayoutParameters layoutParameters( Toolkit::TextView::SplitByNewLineChar,
1514 Toolkit::TextView::Original,
1515 Toolkit::TextView::Original,
1516 static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
1517 Toolkit::TextView::Center,
1518 PointSize( lineHeightOffset ),
1519 std::string( "..." ) );
1525 MarkupProcessor::StyledTextArray inputStyledText;
1526 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText );
1528 TextViewProcessor::UpdateTextInfo( position,
1536 TextViewProcessor::UpdateTextInfo( position,
1540 TextViewProcessor::CLEAR_TEXT );
1545 MarkupProcessor::StyledTextArray inputStyledText;
1546 MarkupProcessor::GetStyledTextArray( inputText, inputStyledText );
1548 TextViewProcessor::UpdateTextInfo( position,
1557 tet_printf( "TestUpdateTextInfo: unknown update operation. %s", location );
1562 if( !TestEqual( inputLayout, resultLayout ) )
1564 tet_printf( "Fail. different layout info. %s", location );
1566 std::cout << " result : "; Print( inputLayout );
1567 std::cout << " expected result : "; Print( resultLayout );
1576 static void Startup();
1577 static void Cleanup();
1580 void (*tet_startup)() = Startup;
1581 void (*tet_cleanup)() = Cleanup;
1585 POSITIVE_TC_IDX = 0x01,
1589 #define MAX_NUMBER_OF_TESTS 10000
1591 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
1594 // Add test functionality for all APIs in the class (Positive and Negative)
1595 TEST_FUNCTION( UtcDaliTextViewCreateTextInfo, POSITIVE_TC_IDX ); // Tests data structures are built well.
1596 TEST_FUNCTION( UtcDaliTextViewUpdateTextInfo, POSITIVE_TC_IDX ); // Tests update operations within a whole text (insert, remove, replace).
1597 TEST_FUNCTION( UtcDaliTextViewSplitWord, POSITIVE_TC_IDX ); // Tests the split word operation.
1598 TEST_FUNCTION( UtcDaliTextViewSplitWordGroup, POSITIVE_TC_IDX ); // Tests the split group of words operation.
1599 TEST_FUNCTION( UtcDaliTextViewSplitLine, POSITIVE_TC_IDX ); // Tests the split line operation.
1600 TEST_FUNCTION( UtcDaliTextViewMergeWord01, POSITIVE_TC_IDX ); // Tests the merge word operation.
1601 TEST_FUNCTION( UtcDaliTextViewMergeWord02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge word operation.
1602 TEST_FUNCTION( UtcDaliTextViewMergeGroup01, POSITIVE_TC_IDX ); // Tests the merge group of words operation.
1603 TEST_FUNCTION( UtcDaliTextViewMergeGroup02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge group of words operation.
1604 TEST_FUNCTION( UtcDaliTextViewMergeLine01, POSITIVE_TC_IDX ); // Tests the merge line operation.
1605 TEST_FUNCTION( UtcDaliTextViewMergeLine02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge line operation.
1606 TEST_FUNCTION( UtcDaliTextViewRemoveCharactersFromWord, POSITIVE_TC_IDX ); // Tests the remove characters from a word operation.
1607 TEST_FUNCTION( UtcDaliTextViewRemoveWordsFromGroup, POSITIVE_TC_IDX ); // Tests the remove words from a group of words operation.
1608 TEST_FUNCTION( UtcDaliTextViewRemoveGroupsFromLine, POSITIVE_TC_IDX ); // Tests the remove groups of words from a line operation.
1610 // Called only once before first test is run.
1611 static void Startup()
1615 // Called only once after last test is run
1616 static void Cleanup()
1620 static void UtcDaliTextViewCreateTextInfo()
1622 ToolkitTestApplication application;
1624 tet_infoline("UtcDaliTextViewCreateTextInfo : ");
1626 // Metrics for characters
1629 // size : [9.48351, 9.48351]
1630 // advance : 9.48351
1631 // bearing : 8.53516
1632 // ascender : 8.53516
1635 // size : [11.3802, 11.3802]
1636 // advance : 11.3802
1637 // bearing : 10.2422
1638 // ascender : 10.2422
1641 // size : [13.2769, 13.2769]
1642 // advance : 13.2769
1643 // bearing : 11.9492
1644 // ascender : 11.9492
1646 const float WIDTH_10( 9.48351f );
1647 const float HEIGHT_10( 9.48351f );
1648 const float ADVANCE_10( 9.48351f );
1649 const float BEARING_10( 8.53516f );
1650 const float ASCENDER_10( 8.53516f );
1652 const float WIDTH_12( 11.3802f );
1653 const float HEIGHT_12( 11.3802f );
1654 const float ADVANCE_12( 11.3802f );
1655 const float BEARING_12( 10.2422f );
1656 const float ASCENDER_12( 10.2422f );
1660 Toolkit::Internal::TextView::RelayoutData relayoutData;
1661 TextViewProcessor::TextLayoutInfo& textLayoutInfo( relayoutData.mTextLayoutInfo );
1663 std::string text( "Hel<font size='10'>lo wo</font>rld!\n"
1666 MarkupProcessor::StyledTextArray styledText;
1667 MarkupProcessor::GetStyledTextArray( text, styledText );
1669 TextViewProcessor::CreateTextInfo( styledText,
1670 DEFAULT_LAYOUT_PARAMETERS,
1674 // Build the text info with metric values.
1678 TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
1679 layoutInfo10.mHeight = HEIGHT_10;
1680 layoutInfo10.mAdvance = ADVANCE_10;
1681 layoutInfo10.mBearing = BEARING_10;
1682 layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
1683 layoutInfo10.mAscender = ASCENDER_10;
1684 TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
1685 layoutInfo12.mHeight = HEIGHT_12;
1686 layoutInfo12.mAdvance = ADVANCE_12;
1687 layoutInfo12.mBearing = BEARING_12;
1688 layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
1689 layoutInfo12.mAscender = ASCENDER_12;
1692 style10.SetFontPointSize( PointSize( 10.f ) );
1694 style12.SetFontPointSize( PointSize( 0.f ) ); // point size is set to zero because is a default point size.
1696 layoutInfo12.mStyledText.mStyle = style12;
1697 layoutInfo10.mStyledText.mStyle = style10;
1701 TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
1704 wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
1705 wordLayout1.mAscender = ASCENDER_12;
1706 wordLayout1.mType = TextViewProcessor::NoSeparator;
1708 layoutInfo12.mStyledText.mText = Text( "H" );
1709 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
1710 layoutInfo12.mStyledText.mText = Text( "e" );
1711 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
1712 layoutInfo12.mStyledText.mText = Text( "l" );
1713 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1714 layoutInfo10.mStyledText.mText = Text( "l" );
1715 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
1716 layoutInfo10.mStyledText.mText = Text( "o" );
1717 wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1720 wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
1721 wordLayout2.mAscender = ASCENDER_10;
1722 wordLayout2.mType = TextViewProcessor::WordSeparator;
1723 layoutInfo10.mStyledText.mText = Text( " " );
1724 wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
1727 wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
1728 wordLayout3.mAscender = ASCENDER_12;
1729 wordLayout3.mType = TextViewProcessor::NoSeparator;
1730 layoutInfo10.mStyledText.mText = Text( "w" );
1731 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
1732 layoutInfo10.mStyledText.mText = Text( "o" );
1733 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
1734 layoutInfo12.mStyledText.mText = Text( "r" );
1735 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
1736 layoutInfo12.mStyledText.mText = Text( "l" );
1737 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
1738 layoutInfo12.mStyledText.mText = Text( "d" );
1739 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
1740 layoutInfo12.mStyledText.mText = Text( "!" );
1741 wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
1743 // (new line character)
1744 wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
1745 wordLayout4.mAscender = ASCENDER_12;
1746 wordLayout4.mType = TextViewProcessor::LineSeparator;
1747 layoutInfo12.mStyledText.mText = Text( "\n" );
1748 layoutInfo12.mSize.width = 0.f;
1749 wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char)
1753 TextViewProcessor::WordGroupLayoutInfo groupLayout1, groupLayout2;
1755 groupLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1756 groupLayout1.mAscender = ASCENDER_12;
1757 groupLayout1.mDirection = TextViewProcessor::LTR;
1758 groupLayout1.mNumberOfCharacters = 13;
1759 groupLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
1760 groupLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
1761 groupLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
1762 groupLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
1764 groupLayout2.mSize = Size( 0.f, HEIGHT_12 );
1765 groupLayout2.mAscender = ASCENDER_12;
1766 groupLayout2.mDirection = TextViewProcessor::LTR;
1767 groupLayout2.mNumberOfCharacters = 1;
1768 groupLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
1772 TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3;
1774 lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
1775 lineLayout1.mAscender = ASCENDER_12;
1776 lineLayout1.mNumberOfCharacters = 13;
1777 lineLayout1.mWordGroupsLayoutInfo.push_back( groupLayout1 );
1779 lineLayout2.mSize = Size( 0.f, HEIGHT_12 );
1780 lineLayout2.mAscender = ASCENDER_12;
1781 lineLayout2.mNumberOfCharacters = 1;
1782 lineLayout2.mWordGroupsLayoutInfo.push_back( groupLayout2 );
1784 lineLayout3.mSize = Size( 0.f, HEIGHT_12 );
1787 TextViewProcessor::TextLayoutInfo textLayout;
1789 textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
1790 textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
1791 textLayout.mNumberOfCharacters = 14;
1792 textLayout.mLinesLayoutInfo.push_back( lineLayout1 );
1793 textLayout.mLinesLayoutInfo.push_back( lineLayout2 );
1794 textLayout.mLinesLayoutInfo.push_back( lineLayout3 );
1796 if(!TestEqual( textLayout, textLayoutInfo ))
1798 std::cout << "Layout fails" << std::endl;
1799 Print(textLayout); std::cout << std::endl;
1800 Print(textLayoutInfo); std::cout << std::endl;
1803 DALI_TEST_CHECK( TestEqual( textLayout, textLayoutInfo ) );
1806 static void UtcDaliTextViewSplitWord()
1808 ToolkitTestApplication application;
1810 tet_infoline("UtcDaliTextViewSplitWord : ");
1812 struct SplitWordTest splitWordTests[] =
1815 std::string( "Split word, position 0." ),
1816 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1819 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1822 std::string( "Split word, position 8." ),
1823 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1825 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1829 std::string( "Split word, position 2." ),
1830 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1832 std::string( "<font size='10'>He</font>" ),
1833 std::string( "<font size='12'>ll</font><font size='10'>oooo</font>" ),
1836 std::string( "Split word, position 3." ),
1837 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1839 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
1840 std::string( "<font size='12'>l</font><font size='10'>oooo</font>" ),
1843 std::string( "Split word, position 4." ),
1844 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
1846 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
1847 std::string( "<font size='10'>oooo</font>" ),
1850 const std::size_t numberOfTests( 5 );
1852 for( std::size_t index = 0; index < numberOfTests; ++index )
1854 const SplitWordTest& test = splitWordTests[index];
1856 if( !TestSplitWord( test.description, test.input, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
1858 tet_result( TET_FAIL );
1862 tet_result( TET_PASS );
1865 static void UtcDaliTextViewUpdateTextInfo()
1867 ToolkitTestApplication application;
1869 tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
1871 struct UpdateTextInfoTest updateTextInfoTest[] =
1873 // Remove operations
1876 std::string( "Remove from new line character to first character next line." ),
1878 std::string("Hello world\nhello world."),
1883 std::string("Hello worldello world."),
1886 std::string( "Replace style from new line character to first character next line." ),
1888 std::string("Hello world\nhello world."),
1891 std::string("<b>\nh</b>"),
1893 std::string("Hello world<b>\nh</b>ello world."),
1896 std::string( "Remove from the beginning to the middle of last word." ),
1898 std::string("Hello world, hello world."),
1901 std::string(), // Not used.
1906 std::string( "Remove from the beginning to the middle of the text." ),
1908 std::string("Hello world hello world."),
1911 std::string(), // Not used.
1913 std::string("hello world."),
1915 // Remove within the same word:
1916 // * within the same group of characters.
1918 std::string( "Remove within the same word, within the same group of characters" ),
1920 std::string("Hello <font size='30'>world\nhello</font> world"),
1923 std::string(), // Not used.
1925 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1927 // * whole group of characters (merge adjacent group of characters)
1929 std::string( "Remove within the same word, whole group of characters (merge adjacent group of characters)" ),
1931 std::string("Hello <font size='30'>w<font size='20'>orl</font>d\nhello</font> world"),
1934 std::string(), // Not used.
1936 std::string( "Hello <font size='30'>wd\nhello</font> world" )
1938 // * whole group of characters (don't merge adjacent gtoup of characters)
1940 std::string( "Remove within the same word, whole group of characters (don't merge adjacent gtoup of characters)" ),
1942 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1945 std::string(), // Not used.
1947 std::string( "Hello <font size='30'>w</font><font size='10'>d\nhello</font> world" )
1949 // * Remove whole word (merge words)
1951 std::string( "Remove within the same word, whole word (merge words)" ),
1953 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1956 std::string(), // Not used.
1958 std::string( "Hello<font size='30'>w</font>orl<font size='10'>d\nhello</font> world" )
1960 // * Remove whole word (don't merge words)
1962 std::string( "Remove within the same word, whole word (don't merge words)" ),
1964 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1967 std::string(), // Not used.
1969 std::string( "Hello <font size='10'>\nhello</font> world" )
1971 // * Remove whole word (merge lines)
1973 std::string( "Remove within the same word, whole word (merge lines)" ),
1975 std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
1978 std::string(), // Not used.
1980 std::string( "Hello <font size='30'>w</font>orl<font size='10'>dhello</font> world" )
1982 // * Remove whole group of words
1983 /* TODO check this when RTL text is working
1985 std::string( "Remove within the same line, whole group of words (merge groups)" ),
1987 std::string("Hello world, שלום עולם, hello world"),
1990 std::string(), // Not used.
1992 std::string( "Hello worlello world" )
1995 // * Remove whole line
1997 std::string( "Remove whole line" ),
1999 std::string("Hello world, hello world\n"
2000 "Hello world, hello world\n"
2001 "Hello world, hello world\n"
2002 "Hello world, hello world\n"),
2005 std::string(), // Not used.
2007 std::string("Hello world, hello world\n"
2008 "Hello world, hello world\n"
2009 "Hello world, hello world\n"),
2012 std::string( "Remove whole line" ),
2014 std::string("Hello world, hello world\n"
2018 std::string(), // Not used.
2020 std::string("Hello world, hello world\n"),
2024 // Insert operations
2026 std::string( "insert some text" ),
2028 std::string("inpuext"),
2031 std::string( "t t" ),
2033 std::string( "input text" )
2036 std::string( "Insert text at the end" ),
2038 std::string("touch "),
2041 std::string("me\nhello"),
2043 std::string("touch me\nhello")
2046 // Replace operations.
2048 std::string( "Replace style from the beginning to some point in the middle of the text." ),
2050 std::string( "Hello <font color='green'>world</font>" ),
2053 std::string( "<font color='red'>Hello w</font>" ),
2055 std::string( "<font color='red'>Hello w</font><font color='green'>orld</font>" )
2058 std::string( "Replace style from the middle of the text to the end." ),
2060 std::string( "Touch me\nhello" ),
2063 std::string( "<b>me\nhello</b>" ),
2065 std::string( "Touch <b>me\nhello</b>" )
2068 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 1." ),
2070 std::string( "Touch me\nhello\nworld" ),
2075 std::string( "Touch \nworld" )
2078 std::string( "Insert styled text in the middle of a text. Previous: Replace style from the middle of the text 1." ),
2080 std::string( "Touch \nworld" ),
2083 std::string( "<b>me\nhello</b>" ),
2085 std::string( "Touch <b>me\nhello</b>\nworld" )
2088 std::string( "Replace style from the middle of the text 1." ),
2090 std::string( "Touch me\nhello\nworld" ),
2093 std::string( "<b>me\nhello</b>" ),
2095 std::string( "Touch <b>me\nhello</b>\nworld" )
2098 std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 2." ),
2100 std::string( "Touch me\nhello\nworld" ),
2105 std::string( "Touch world" )
2108 std::string( "Replace style from the middle of the text 2." ),
2110 std::string( "Touch me\nhello\nworld" ),
2113 std::string( "<b>me\nhello\n</b>" ),
2115 std::string( "Touch <b>me\nhello\n</b>world" )
2118 const std::size_t numberOfTests( 21 );
2120 for( std::size_t index = 0; index < numberOfTests; ++index )
2122 const UpdateTextInfoTest& test = updateTextInfoTest[index];
2124 if( !TestUpdateTextInfo( test.description, test.operation, test.input, test.position, test.numberOfCharacters, test.inputText, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2126 tet_result( TET_FAIL );
2130 tet_result( TET_PASS );
2133 static void UtcDaliTextViewSplitWordGroup()
2135 ToolkitTestApplication application;
2137 tet_infoline("UtcDaliTextViewSplitWordGroup : ");
2139 struct SplitWordGroupTest splitWordGroupTests[] =
2142 std::string( "Split word group, wordPosition 0, position 0." ),
2143 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2147 std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
2150 std::string( "Split word group, wordPosition 2, position 8." ),
2151 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2154 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2158 std::string( "Split word group, wordPosition 0, position 2." ),
2159 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2162 std::string( "<font size='10'>He</font>" ),
2163 std::string( "<font size='12'>ll</font><font size='10'>oooo wooorld</font>" ),
2166 std::string( "Split word group, wordPosition 0, position 3." ),
2167 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2170 std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
2171 std::string( "<font size='12'>l</font><font size='10'>oooo wooorld</font>" ),
2174 std::string( "Split word group, wordPosition 0, position 4." ),
2175 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2178 std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
2179 std::string( "<font size='10'>oooo wooorld</font>" ),
2182 std::string( "Split word group, wordPosition 1, position 0." ),
2183 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
2186 std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
2187 std::string( "<font size='10'> wooorld</font>" ),
2190 const std::size_t numberOfTests( 6 );
2192 for( std::size_t index = 0; index < numberOfTests; ++index )
2194 const SplitWordGroupTest& test = splitWordGroupTests[index];
2196 if( !TestSplitWordGroup( test.description, test.input, test.wordPosition, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
2198 tet_result( TET_FAIL );
2202 tet_result( TET_PASS );
2205 static void UtcDaliTextViewSplitLine()
2207 ToolkitTestApplication application;
2209 tet_infoline("UtcDaliTextViewSplitLine : ");
2211 struct SplitLineTest splitLineTests[] =
2214 std::string( "Split line, groupPosition 0, wordPosition 0, position 0." ),
2215 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2221 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2224 std::string( "Split line, groupPosition 2, wordPosition 2, position 4." ),
2225 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2230 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2233 /* TODO check when RTL is working.
2235 std::string( "Split line, groupPosition 1, wordPosition 2, position 0." ),
2236 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2241 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום" ),
2242 std::string( " עולם text text" ),
2245 std::string( "Split line, groupPosition 1, wordPosition 0, position 0." ),
2246 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2251 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
2252 std::string( "שלום עולם text text" ),
2256 std::string( "Split line, groupPosition 2, wordPosition 0, position 0." ),
2257 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
2262 std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם " ),
2263 std::string( "text text" ),
2266 const std::size_t numberOfTests( 3 );
2268 for( std::size_t index = 0; index < numberOfTests; ++index )
2270 const SplitLineTest& test = splitLineTests[index];
2272 if( !TestSplitLine( test.description, test.input, test.groupPosition, test.wordPosition, test.position, test.lineHeightOffset, test.firstResult, test.lastResult, TEST_LOCATION ) )
2274 tet_result( TET_FAIL );
2278 tet_result( TET_PASS );
2281 static void UtcDaliTextViewMergeWord01()
2283 ToolkitTestApplication application;
2285 tet_infoline("UtcDaliTextViewMergeWord01 : ");
2287 struct MergeWordsTest mergeWordsTests[] =
2290 std::string( "Merge words with same style." ),
2291 std::string( "Hel" ),
2292 std::string( "lo" ),
2293 std::string( "Hello" ),
2296 std::string( "Merge words with different styles." ),
2297 std::string( "<font size='10>Hel</font>" ),
2298 std::string( "<font size='20'>lo</font>" ),
2299 std::string( "<font size='10'>Hel</font><font size='20'>lo</font>" )
2302 const std::size_t numberOfTests( 2 );
2304 for( std::size_t index = 0; index < numberOfTests; ++index )
2306 const MergeWordsTest& test = mergeWordsTests[index];
2308 if( !TestMergeWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2310 tet_result( TET_FAIL );
2314 tet_result( TET_PASS );
2317 static void UtcDaliTextViewMergeWord02()
2320 // It test white spaces and new line characters can't be merged to other words.
2322 ToolkitTestApplication application;
2324 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2326 // Generate three words
2328 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2329 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2330 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2331 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2332 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2333 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2335 std::string text01( " " );
2336 std::string text02( "\n" );
2337 std::string text03( "a" );
2338 MarkupProcessor::StyledTextArray styledText01;
2339 MarkupProcessor::StyledTextArray styledText02;
2340 MarkupProcessor::StyledTextArray styledText03;
2341 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2342 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2343 MarkupProcessor::GetStyledTextArray( text03, styledText03 );
2345 TextViewProcessor::CreateTextInfo( styledText01,
2346 DEFAULT_LAYOUT_PARAMETERS,
2349 TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
2351 wordLayoutInfo01 = *( *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2353 TextViewProcessor::CreateTextInfo( styledText02,
2354 DEFAULT_LAYOUT_PARAMETERS,
2357 TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
2359 wordLayoutInfo02 = *( *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2361 TextViewProcessor::CreateTextInfo( styledText03,
2362 DEFAULT_LAYOUT_PARAMETERS,
2365 TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
2367 wordLayoutInfo03 = *( *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
2369 // Test MergeWord() asserts if white spaces or new line chars are merged.
2370 bool assert1 = false;
2371 bool assert2 = false;
2372 bool assert3 = false;
2373 bool assert4 = false;
2374 bool assert5 = false;
2375 bool assert6 = false;
2379 MergeWord( wordLayoutInfo01,
2382 catch( Dali::DaliException& e )
2384 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2385 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2390 MergeWord( wordLayoutInfo01,
2393 catch( Dali::DaliException& e )
2395 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2396 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2401 MergeWord( wordLayoutInfo02,
2404 catch( Dali::DaliException& e )
2406 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2407 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2412 MergeWord( wordLayoutInfo02,
2415 catch( Dali::DaliException& e )
2417 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2418 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2423 MergeWord( wordLayoutInfo03,
2426 catch( Dali::DaliException& e )
2428 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2429 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2434 MergeWord( wordLayoutInfo03,
2437 catch( Dali::DaliException& e )
2439 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2440 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new line characters can't be merged with other words.\"", TEST_LOCATION );
2444 if( assert1 && assert2 && assert3 && assert4 && assert5 && assert6 )
2446 tet_result( TET_PASS );
2450 tet_result( TET_FAIL );
2454 static void UtcDaliTextViewMergeGroup01()
2456 ToolkitTestApplication application;
2458 tet_infoline("UtcDaliTextViewMergeGroup01 : ");
2460 struct MergeWordGroupsTest mergeWordGroupssTests[] =
2463 std::string( "Merge a void first group." ),
2465 std::string( "Hello world" ),
2466 std::string( "Hello world" ),
2469 std::string( "Merge a void last group." ),
2470 std::string( "Hello world" ),
2472 std::string( "Hello world" ),
2475 std::string( "Merge groups and merge last and first words." ),
2476 std::string( "Hello wor" ),
2477 std::string( "ld, hello world" ),
2478 std::string( "Hello world, hello world" ),
2481 std::string( "Merge groups and don't merge last and first words." ),
2482 std::string( "Hello world, " ),
2483 std::string( "hello world" ),
2484 std::string( "Hello world, hello world" )
2487 const std::size_t numberOfTests( 4 );
2489 for( std::size_t index = 0; index < numberOfTests; ++index )
2491 const MergeWordGroupsTest& test = mergeWordGroupssTests[index];
2493 if( !TestMergeGroupsOfWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
2495 tet_result( TET_FAIL );
2499 tet_result(TET_PASS);
2502 static void UtcDaliTextViewMergeGroup02()
2504 ToolkitTestApplication application;
2506 tet_infoline("UtcDaliTextViewMergeGroup02 : ");
2508 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2509 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2510 Toolkit::Internal::TextView::RelayoutData relayoutData03;
2511 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2512 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2513 TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
2515 std::string text01( "Hello \n" );
2516 std::string text02( "world" );
2517 std::string text03( "السلام عليكم" );
2518 MarkupProcessor::StyledTextArray styledText01;
2519 MarkupProcessor::StyledTextArray styledText02;
2520 MarkupProcessor::StyledTextArray styledText03;
2521 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2522 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2523 MarkupProcessor::GetStyledTextArray( text03, styledText03 );
2525 TextViewProcessor::CreateTextInfo( styledText01,
2526 DEFAULT_LAYOUT_PARAMETERS,
2529 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo01;
2531 wordGroupLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2533 TextViewProcessor::CreateTextInfo( styledText02,
2534 DEFAULT_LAYOUT_PARAMETERS,
2537 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo02;
2539 wordGroupLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2541 TextViewProcessor::CreateTextInfo( styledText03,
2542 DEFAULT_LAYOUT_PARAMETERS,
2545 TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo03;
2547 wordGroupLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
2549 bool assert1 = false;
2550 bool assert2 = false;
2554 MergeWordGroup( wordGroupLayoutInfo01,
2555 wordGroupLayoutInfo02 );
2557 catch( Dali::DaliException& e )
2559 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2560 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 );
2566 MergeWordGroup( wordGroupLayoutInfo03,
2567 wordGroupLayoutInfo02 );
2569 catch( Dali::DaliException& e )
2571 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2572 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWordGroup(). ERROR: groups with different direction can't be merged.\"", TEST_LOCATION );
2576 if( assert1 && assert2 )
2578 tet_result( TET_PASS );
2582 tet_result( TET_FAIL );
2586 static void UtcDaliTextViewMergeLine01()
2588 ToolkitTestApplication application;
2590 tet_infoline("UtcDaliTextViewMergeLine01 : ");
2592 struct MergeLinesTest mergeLinesTests[] =
2595 std::string( "Merge a void first line." ),
2597 std::string( "Hello world, this is a whole line" ),
2599 std::string( "Hello world, this is a whole line" )
2602 std::string( "Merge a void last line." ),
2603 std::string( "Hello world, this is a whole line" ),
2606 std::string( "Hello world, this is a whole line" )
2608 /* TODO: check when RTL text is working.
2610 std::string( "Merge lines and merge last and first groups" ),
2611 std::string( "Hello world, שלום" ),
2612 std::string( " עולם, hello world." ),
2614 std::string( "Hello world, שלום עולם, hello world." )
2617 std::string( "Merge lines and don't merge last and first words." ),
2618 std::string( "Hello world, " ),
2619 std::string( "שלום עולם, hello world." ),
2621 std::string( "Hello world, שלום עולם, hello world." )
2625 std::string( "Merge lines. Don't merge words" ),
2626 std::string( "Hello world," ),
2627 std::string( " this is a whole line" ),
2629 std::string( "Hello world, this is a whole line" )
2632 std::string( "Merge lines. Merge words" ),
2633 std::string( "Hello world, th" ),
2634 std::string( "is is a whole line" ),
2636 std::string( "Hello world, this is a whole line" )
2639 const std::size_t numberOfTests( 4 );
2641 for( std::size_t index = 0; index < numberOfTests; ++index )
2643 const MergeLinesTest& test = mergeLinesTests[index];
2645 if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2647 tet_result( TET_FAIL );
2651 tet_result( TET_PASS );
2654 static void UtcDaliTextViewMergeLine02()
2656 ToolkitTestApplication application;
2658 tet_infoline("UtcDaliTextViewMergeLine02 : ");
2660 Toolkit::Internal::TextView::RelayoutData relayoutData01;
2661 Toolkit::Internal::TextView::RelayoutData relayoutData02;
2662 TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
2663 TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
2665 std::string text01( "Hello world\n" );
2666 std::string text02( "hello world" );
2667 MarkupProcessor::StyledTextArray styledText01;
2668 MarkupProcessor::StyledTextArray styledText02;
2669 MarkupProcessor::GetStyledTextArray( text01, styledText01 );
2670 MarkupProcessor::GetStyledTextArray( text02, styledText02 );
2672 TextViewProcessor::CreateTextInfo( styledText01,
2673 DEFAULT_LAYOUT_PARAMETERS,
2676 TextViewProcessor::LineLayoutInfo lineLayoutInfo01;
2678 lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin();
2680 TextViewProcessor::CreateTextInfo( styledText02,
2681 DEFAULT_LAYOUT_PARAMETERS,
2684 TextViewProcessor::LineLayoutInfo lineLayoutInfo02;
2686 lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin();
2688 bool assert1 = false;
2692 MergeLine( lineLayoutInfo01,
2695 catch( Dali::DaliException& e )
2697 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
2698 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 );
2704 tet_result( TET_PASS );
2708 tet_result( TET_FAIL );
2712 void UtcDaliTextViewRemoveCharactersFromWord()
2714 ToolkitTestApplication application;
2716 tet_infoline("UtcDaliTextViewMergeWord02 : ");
2718 struct RemoveCharactersFromWordTest removeCharactersFromWordTests[] =
2721 std::string( "Delete 0 characters." ),
2722 std::string( "Hello" ),
2725 std::string( "Hello" ),
2728 std::string( "Delete within the same group of characters. Starting from the beginning" ),
2729 std::string( "Hello" ),
2732 std::string( "lo" ),
2735 std::string( "Delete within the same group of characters. Somewhere in the middle" ),
2736 std::string( "Hello" ),
2739 std::string( "Heo" ),
2742 std::string( "Delete within the same group of characters. Starting somewhere in the middle to the end" ),
2743 std::string( "Hello" ),
2746 std::string( "Hel" ),
2749 std::string( "Delete within the same group of characters. Finish just before a new one." ),
2750 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2753 std::string( "<font size='10'>H</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2756 std::string( "Delete starting in one group of characters and finishing in a different one. No merge of groups." ),
2757 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2760 std::string( "<font size='10'>He</font><font size='20'>Wo</font><font size='30'>rld</font>" ),
2763 std::string( "Delete within the same group of characters. Starting just after a different 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'>Hel</font><font size='20'>loWo</font><font size='30'>d</font>" ),
2770 std::string( "Delete whole group of characters. No merge" ),
2771 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2774 std::string( "<font size='10'>Hel</font><font size='30'>rld</font>" ),
2777 std::string( "Delete whole group of characters and part of the adjacent ones. No merge" ),
2778 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
2781 std::string( "<font size='10'>He</font><font size='30'>ld</font>" ),
2784 std::string( "Delete whole group of characters. Merge" ),
2785 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2788 std::string( "<font size='10'>Helrld</font>" ),
2791 std::string( "Delete whole group of characters and part of the adjacent ones. Merge" ),
2792 std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
2795 std::string( "<font size='10'>Held</font>" ),
2798 const std::size_t numberOfTests( 11 );
2800 for( std::size_t index = 0; index < numberOfTests; ++index )
2802 const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
2804 if( !TestRemoveCharactersFromWord( test.description, test.input, test.position, test.numberOfCharacters, test.result, TEST_LOCATION ) )
2806 tet_result( TET_FAIL );
2810 tet_result( TET_PASS );
2813 static void UtcDaliTextViewRemoveWordsFromGroup()
2815 // Note: Currently RemoveWordsFromWordGroup() function is only used to remove a number of words from the beginning, or
2816 // from a given index to the end. RemoveWordsFromWordGroup() doesn't merge words (if a white space is removed) so
2817 // tehere isn't any TET case to cover these cases. To be done if needed.
2819 ToolkitTestApplication application;
2821 tet_infoline("UtcDaliTextViewRemoveWordsFromGroup : ");
2822 struct RemoveWordsFromGroupTest removeWordsFromGroupTests[] =
2825 std::string( "Delete 0 words." ),
2826 std::string( "Hello world, hello world" ),
2829 std::string( "Hello world, hello world" ),
2832 std::string( "Delete some words in the middle. Don't merge words" ),
2833 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2836 std::string( "<font size='10'>Hel</font><font size='20'>lo</font><font size='30'> world</font>" ),
2839 std::string( "Delete words up to the end" ),
2840 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
2843 std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello</font>" ),
2846 std::string( "Delete words from the beginning." ),
2847 std::string( "Hello world, hello world" ),
2850 std::string( " hello world" ),
2853 const std::size_t numberOfTests( 4 );
2855 for( std::size_t index = 0; index < numberOfTests; ++index )
2857 const RemoveWordsFromGroupTest& test = removeWordsFromGroupTests[index];
2859 if( !TestRemoveWordsFromGroup( test.description, test.input, test.wordIndex, test.numberOfWords, test.result, TEST_LOCATION ) )
2861 tet_result( TET_FAIL );
2865 tet_result( TET_PASS );
2868 static void UtcDaliTextViewRemoveGroupsFromLine()
2870 // Note: Currently RemoveWordGroupsFromLine() function is only used to remove a number of group of words from the beginning, or
2871 // from a given index to the end. RemoveWordGroupsFromLine() doesn't merge groups of words (if a whole group of words is removed) so
2872 // tehere isn't any TET case to cover these cases. To be done if needed.
2874 ToolkitTestApplication application;
2876 tet_infoline("UtcDaliTextViewRemoveGroupsFromLine : ");
2877 struct RemoveGroupsFromLineTest removeGroupsFromLineTests[] =
2880 std::string( "Delete 0 groups of words." ),
2881 std::string( "Hello hello, שלום עולם hello hello" ),
2885 std::string( "Hello hello, שלום עולם hello hello" ),
2888 std::string( "Delete from the middle to the end." ),
2889 std::string( "Hello hello, שלום עולם hello hello" ),
2893 std::string( "Hello hello, " ),
2896 std::string( "Delete from the beginning to the middle." ),
2897 std::string( "Hello hello, שלום עולם hello hello" ),
2901 std::string( "hello hello" ),
2904 const std::size_t numberOfTests( 3 );
2906 for( std::size_t index = 0; index < numberOfTests; ++index )
2908 const RemoveGroupsFromLineTest& test = removeGroupsFromLineTests[index];
2910 if( !TestRemoveGroupsFromLine( test.description, test.input, test.groupIndex, test.numberOfGroups, test.lineHeightOffset, test.result, TEST_LOCATION ) )
2912 tet_result( TET_FAIL );
2916 tet_result( TET_PASS );