X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextView-Processor.cpp;h=8fef8577ab1d58465fcaeb83ab8e4609da82d1cd;hp=9485689191bb4e11193f56b3066ca664e1111494;hb=e58197b2ce320f167a24865cdd048f0cc0c05e45;hpb=a881757839b7abb008873a68c67e17b3ba39669b diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp index 9485689..8fef857 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp @@ -22,6 +22,7 @@ // Internal headers are allowed here #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -53,11 +54,10 @@ struct BeginsRightToLeftCharacterTest bool TestBeginsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location ) { - // Creates a styled text with the markup or plain string. - MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( input, styledText, true ); + // Creates a text with the string. + Text text( input ); - const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( styledText ) ); + const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( text ) ); if( !ret ) { @@ -79,11 +79,10 @@ struct ContainsRightToLeftCharacterTest bool TestContainsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location ) { - // Creates a styled text with the markup or plain string. - MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( input, styledText, true ); + // Creates a text with the string. + Text text( input ); - const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( styledText ) ); + const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( text ) ); if( !ret ) { @@ -128,28 +127,30 @@ bool TestFindNearestWord( const std::string& description, const std::string& inp ////////////////////////////////////////////////////////////////// -struct SplitInLinesTest +struct SplitInParagraphsTest { std::string inputText; - std::size_t resultNumberOfLines; + std::size_t resultNumberOfParagraphs; }; -bool TestSplitInLines( const SplitInLinesTest& test, const char* location ) +bool TestSplitInParagraphs( const SplitInParagraphsTest& test, const char* location ) { // Creates a styled text with the markup or plain string. MarkupProcessor::StyledTextArray styledText; MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true ); - std::vector lines; + std::vector paragraphs; + std::vector< Vector > styles; - TextProcessor::SplitInLines( styledText, - lines ); + TextProcessor::SplitInParagraphs( styledText, + paragraphs, + styles ); - if( lines.size() != test.resultNumberOfLines ) + if( paragraphs.size() != test.resultNumberOfParagraphs ) { tet_printf( "Fail. %s", location ); - tet_printf( "Different number of lines, result %d, expected result %d", lines.size(), test.resultNumberOfLines ); + tet_printf( "Different number of paragraphs, result %d, expected result %d", paragraphs.size(), test.resultNumberOfParagraphs ); return false; } @@ -163,24 +164,23 @@ struct SplitInWordsTest { std::string inputText; - std::size_t resultNumberOfWords; + std::size_t resultNumberOfSeparators; }; bool TestSplitInWords( const SplitInWordsTest& test, const char* location ) { - // Creates a styled text with the markup or plain string. - MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true ); + // Creates a text with the string. + Text text( test.inputText ); - std::vector words; + Vector positions; - TextProcessor::SplitInWords( styledText, - words ); + TextProcessor::SplitInWords( text, + positions ); - if( words.size() != test.resultNumberOfWords ) + if( positions.Count() != test.resultNumberOfSeparators ) { tet_printf( "Fail. %s", location ); - tet_printf( "Different number of words, result %d, expected result %d", words.size(), test.resultNumberOfWords ); + tet_printf( "Different number of separators, result %d, expected result %d", positions.Count(), test.resultNumberOfSeparators ); return false; } @@ -193,13 +193,13 @@ bool TestSplitInWords( const SplitInWordsTest& test, const char* location ) } // namespace -int UtcDaliTextViewSplitInLines(void) +int UtcDaliTextViewSplitInParagraphs(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliTextViewSplitInLines : "); + tet_infoline("UtcDaliTextViewSplitInParagraphs : "); - struct SplitInLinesTest splitInLinesTest[] = + struct SplitInParagraphsTest splitInParagraphsTest[] = { { std::string( "Hello world\nhello world." ), @@ -214,9 +214,9 @@ int UtcDaliTextViewSplitInLines(void) for( std::size_t index = 0; index < numberOfTests; ++index ) { - const SplitInLinesTest& test = splitInLinesTest[index]; + const SplitInParagraphsTest& test = splitInParagraphsTest[index]; - if( !TestSplitInLines( test, TEST_LOCATION ) ) + if( !TestSplitInParagraphs( test, TEST_LOCATION ) ) { tet_result( TET_FAIL ); } @@ -236,10 +236,14 @@ int UtcDaliTextViewSplitInWords(void) { { std::string( "Hello world, hello word!" ), - 7 + 3u }, + { + std::string( "Hello world\n" ), + 2u + } }; - const std::size_t numberOfTests( 1 ); + const std::size_t numberOfTests( 2u ); for( std::size_t index = 0; index < numberOfTests; ++index ) {