X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextView.cpp;h=91dcc57e2b312d7a2bafbe56ba89e2973efb89ed;hp=ee43cbd7de5a26063867054e07ddd70f802e118a;hb=2ddfbb9e23a7c3fc30e604236c41e0ef6d2ed6a2;hpb=8c06d1257654f498737607c2dc9153d9178ece43 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp index ee43cbd..91dcc57 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp @@ -66,6 +66,7 @@ struct SplitParagraphTest std::string input; std::size_t wordIndex; std::size_t characterIndex; + std::size_t characterParagraphIndex; float lineHeightOffset; std::string firstResult; std::string lastResult; @@ -141,10 +142,6 @@ void Print( const TextViewProcessor::CharacterLayoutInfo& character ) { std::cout << "[" << textActor.GetText() << "]"; } - else - { - std::cout << "{" << character.mStyledText.mText.GetText() << "}"; - } } void Print( const TextViewProcessor::WordLayoutInfo& word ) @@ -186,21 +183,13 @@ void Print( const TextViewProcessor::TextLayoutInfo& text ) std::cout << "||" << std::endl; } -std::string GetText( const TextViewProcessor::CharacterLayoutInfo& character ) -{ - return character.mStyledText.mText.GetText(); -} - -std::string GetText( const TextViewProcessor::WordLayoutInfo& word ) +std::string GetText( const TextViewProcessor::WordLayoutInfo& word, const Text& paragraphText ) { - std::string text; + Text text; - for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it ) - { - text += GetText( *it ); - } + paragraphText.GetSubText( word.mFirstCharacter, word.mFirstCharacter + word.mCharactersLayoutInfo.size() - 1u, text ); - return text; + return text.GetText(); } std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph ) @@ -209,7 +198,7 @@ std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph ) for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it ) { - text += GetText( *it ); + text += GetText( *it, paragraph.mText ); } return text; @@ -288,27 +277,6 @@ bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1, return false; } - text1 = character1.mStyledText.mText.GetText(); - style1 = character1.mStyledText.mStyle; - - text2 = character2.mStyledText.mText.GetText(); - style2 = character2.mStyledText.mStyle; - - if( text1 != text2 ) - { - return false; - } - - if( style1 != style2 ) - { - std::cout << " style1 : " << std::endl; - TextViewProcessor::dbgPrint( style1 ); - - std::cout << " style2 : " << std::endl; - TextViewProcessor::dbgPrint( style2 ); - return false; - } - return true; } @@ -557,6 +525,7 @@ bool TestSplitWord( const std::string& description, const std::string& input, co * @param input The input word. * @param wordIndex Index to the word within the paragraph where to split it. * @param characterIndex Where to split the word. + * @param characterIndex Character index within the paragraph. * @param lineHeightOffset Offset between lines. * @param firstResult First part of the split paragraph. * @param lastResult Last part of the split paragraph. @@ -568,6 +537,7 @@ bool TestSplitParagraph( const std::string& description, const std::string& input, size_t wordIndex, size_t characterIndex, + size_t characterParagraphIndex, float lineHeightOffset, const std::string& firstResult, const std::string& lastResult, @@ -589,7 +559,6 @@ bool TestSplitParagraph( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); @@ -616,7 +585,6 @@ bool TestSplitParagraph( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), firstRelayoutData ); @@ -643,7 +611,6 @@ bool TestSplitParagraph( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..."), true ), lastRelayoutData ); @@ -660,6 +627,7 @@ bool TestSplitParagraph( const std::string& description, TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo; TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex ); + indices.mCharacterParagraphIndex = characterParagraphIndex; SplitParagraph( indices, PointSize( lineHeightOffset ), @@ -812,7 +780,6 @@ bool TestMergeParagraphs( const std::string& description, const std::string& inp static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), firstRelayoutData ); @@ -838,7 +805,6 @@ bool TestMergeParagraphs( const std::string& description, const std::string& inp static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), lastRelayoutData ); @@ -864,7 +830,6 @@ bool TestMergeParagraphs( const std::string& description, const std::string& inp static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); @@ -998,7 +963,6 @@ bool TestRemoveWordsFromParagraph( const std::string& description, const std::st static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); @@ -1024,7 +988,6 @@ bool TestRemoveWordsFromParagraph( const std::string& description, const std::st static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); @@ -1099,7 +1062,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), relayoutData ); @@ -1117,7 +1079,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ), resultRelayoutData ); @@ -1128,7 +1089,6 @@ bool TestUpdateTextInfo( const std::string& description, static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Center, PointSize( lineHeightOffset ), - std::string( "..." ), true ); switch( operation ) @@ -1254,15 +1214,6 @@ int UtcDaliTextViewCreateTextInfo(void) layoutInfo12.mBearing = BEARING_12; layoutInfo12.mAscender = ASCENDER_12; - TextStyle style10; - style10.SetFontName( "" ); - style10.SetFontPointSize( PointSize( 10.f ) ); - TextStyle style12; - style12.SetFontName( "" ); - - layoutInfo12.mStyledText.mStyle = style12; - layoutInfo10.mStyledText.mStyle = style10; - // Words TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4; @@ -1272,46 +1223,33 @@ int UtcDaliTextViewCreateTextInfo(void) wordLayout1.mAscender = ASCENDER_12; wordLayout1.mType = TextViewProcessor::NoSeparator; - layoutInfo12.mStyledText.mText = Text( "H" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H - layoutInfo12.mStyledText.mText = Text( "e" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e - layoutInfo12.mStyledText.mText = Text( "l" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l - layoutInfo10.mStyledText.mText = Text( "l" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l - layoutInfo10.mStyledText.mText = Text( "o" ); wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o // (white space) wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 ); wordLayout2.mAscender = ASCENDER_10; wordLayout2.mType = TextViewProcessor::WordSeparator; - layoutInfo10.mStyledText.mText = Text( " " ); wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space) // world! wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 ); wordLayout3.mAscender = ASCENDER_12; wordLayout3.mType = TextViewProcessor::NoSeparator; - layoutInfo10.mStyledText.mText = Text( "w" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w - layoutInfo10.mStyledText.mText = Text( "o" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o - layoutInfo12.mStyledText.mText = Text( "r" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r - layoutInfo12.mStyledText.mText = Text( "l" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l - layoutInfo12.mStyledText.mText = Text( "d" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d - layoutInfo12.mStyledText.mText = Text( "!" ); wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // ! // (new paragraph character) wordLayout4.mSize = Size( 0.f, HEIGHT_12 ); wordLayout4.mAscender = ASCENDER_12; wordLayout4.mType = TextViewProcessor::ParagraphSeparator; - layoutInfo12.mStyledText.mText = Text( "\n" ); layoutInfo12.mSize.width = 0.f; wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char) @@ -1533,7 +1471,6 @@ int UtcDaliTextViewUpdateTextInfo(void) std::string( "Hello worldhello world" ) }, // * Remove RTL text within LTR - /* TODO check this when RTL text is working { std::string( "Remove within the same paragraph, RTL text within LTR." ), Remove, @@ -1544,7 +1481,6 @@ int UtcDaliTextViewUpdateTextInfo(void) 0.f, std::string( "Hello worlello world" ) }, - */ // * Remove whole paragraph { std::string( "Remove whole paragraph" ), @@ -1668,7 +1604,7 @@ int UtcDaliTextViewUpdateTextInfo(void) std::string( "Touch me\nhello\nworld" ) }, }; - const std::size_t numberOfTests( 21u ); + const std::size_t numberOfTests( 22u ); for( std::size_t index = 0u; index < numberOfTests; ++index ) { @@ -1697,6 +1633,7 @@ int UtcDaliTextViewSplitParagraph(void) std::string( "Helloooo wooorld שלום עולם text text" ), 0, 0, + 0, 3.f, std::string( "" ), std::string( "Helloooo wooorld שלום עולם text text" ), @@ -1706,6 +1643,7 @@ int UtcDaliTextViewSplitParagraph(void) std::string( "Helloooo wooorld שלום עולם text text" ), 10, 4, + 36, 0.f, std::string( "Helloooo wooorld שלום עולם text text" ), std::string( "" ), @@ -1715,16 +1653,17 @@ int UtcDaliTextViewSplitParagraph(void) std::string("Hello world, hello world"), 2, 4, + 10, 0.f, std::string("Hello worl"), std::string("d, hello world") - } - /* TODO RTL + }, { std::string( "Split paragraph, wordPosition 6, position 0." ), std::string( "Helloooo wooorld שלום עולם text text" ), 6, 0, + 21, 0.f, std::string( "Helloooo wooorld שלום " ), std::string( "עולם text text" ), @@ -1734,6 +1673,7 @@ int UtcDaliTextViewSplitParagraph(void) std::string( "Helloooo wooorld שלום עולם text text" ), 4, 0, + 17, 0.f, std::string( "Helloooo wooorld " ), std::string( "שלום עולם text text" ), @@ -1743,13 +1683,13 @@ int UtcDaliTextViewSplitParagraph(void) std::string( "Helloooo wooorld שלום עולם text text" ), 8, 0, + 27, 6.f, std::string( "Helloooo wooorld שלום עולם " ), std::string( "text text" ), }, - */ }; - const std::size_t numberOfTests( 3u ); + const std::size_t numberOfTests( 6u ); for( std::size_t index = 0u; index < numberOfTests; ++index ) { @@ -1759,6 +1699,7 @@ int UtcDaliTextViewSplitParagraph(void) test.input, test.wordIndex, test.characterIndex, + test.characterParagraphIndex, test.lineHeightOffset, test.firstResult, test.lastResult, @@ -1876,8 +1817,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert1 = true; } try @@ -1887,8 +1828,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert2 = true; } try @@ -1898,8 +1839,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert3 = true; } try @@ -1909,8 +1850,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert4 = true; } try @@ -1920,8 +1861,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert5 = true; } try @@ -1931,8 +1872,8 @@ int UtcDaliTextViewMergeWord02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION ); assert6 = true; } @@ -1969,7 +1910,6 @@ int UtcDaliTextViewMergeParagraph01(void) 0.f, std::string( "Hello world, this is a whole paragraph" ) }, - /* TODO RTL { std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ), std::string( "Hello world, שלום" ), @@ -1984,7 +1924,6 @@ int UtcDaliTextViewMergeParagraph01(void) 3.f, std::string( "Hello world, שלום עולם, hello world." ) }, - */ { std::string( "Merge paragraphs. Don't merge words" ), std::string( "Hello world," ), @@ -2000,7 +1939,7 @@ int UtcDaliTextViewMergeParagraph01(void) std::string( "Hello world, this is a whole paragraph" ) }, }; - const std::size_t numberOfTests( 4u ); + const std::size_t numberOfTests( 6u ); for( std::size_t index = 0u; index < numberOfTests; ++index ) { @@ -2059,8 +1998,8 @@ int UtcDaliTextViewMergeParagraph02(void) } catch( Dali::DaliException& e ) { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION ); + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION ); assert1 = true; }