X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-Segmentation.cpp;h=cfbf325910907aeb0a7f04d0a1f0b457ff45539c;hb=610495b8647d1a25c98bf0773ccc0dd6d1996263;hp=0023240662e8f5b2532f451cea2113a0ee3d9500;hpb=b899c4999231a14190e804e13b941527c3c437a1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Segmentation.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Segmentation.cpp index 0023240..cfbf325 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Segmentation.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Segmentation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,19 +56,38 @@ bool LineBreakInfoTest( const BreakInfoData& data ) Vector utf32; utf32.Resize( data.text.size() ); - const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast( data.text.c_str() ), - data.text.size(), - &utf32[0u] ); + const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 : + Utf8ToUtf32( reinterpret_cast( data.text.c_str() ), + data.text.size(), + &utf32[0u] ); utf32.Resize( numberOfCharacters ); - // 2) Set the line break info. + // 2) Set the line break info for the whole text. Vector lineBreakInfo; lineBreakInfo.Resize( numberOfCharacters ); - SetLineBreakInfo( utf32, lineBreakInfo ); + SetLineBreakInfo( utf32, + 0u, + numberOfCharacters, + lineBreakInfo ); + + // 3) Update the word text info if it's requested for part of the text. + if( ( 0u != data.index ) && + ( numberOfCharacters != data.numberOfCharacters ) ) + { + // Clear part of the line break info. + lineBreakInfo.Erase( lineBreakInfo.Begin() + data.index, + lineBreakInfo.Begin() + data.index + data.numberOfCharacters ); - // 3) compare the results + // Update the word line info. + SetLineBreakInfo( utf32, + data.index, + data.numberOfCharacters, + lineBreakInfo ); + } + + // 4) compare the results std::ostringstream breakInfo; for( unsigned int index = 0u; index < numberOfCharacters; ++index ) @@ -78,8 +97,11 @@ bool LineBreakInfoTest( const BreakInfoData& data ) if( data.breakInfo != breakInfo.str() ) { - std::cout << " expected : [" << data.breakInfo << "]" << std::endl; - std::cout << " got : [" << breakInfo.str() << "]" << std::endl; + std::cout << " text : [" << data.text << "]" << std::endl; + std::cout << " index : " << data.index << std::endl; + std::cout << " numberOfCharacters : " << data.numberOfCharacters << std::endl; + std::cout << " expected : [" << data.breakInfo << "]" << std::endl; + std::cout << " got : [" << breakInfo.str() << "]" << std::endl; return false; } @@ -92,9 +114,10 @@ bool WordBreakInfoTest( const BreakInfoData& data ) Vector utf32; utf32.Resize( data.text.size() ); - const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast( data.text.c_str() ), - data.text.size(), - &utf32[0u] ); + const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 : + Utf8ToUtf32( reinterpret_cast( data.text.c_str() ), + data.text.size(), + &utf32[0u] ); utf32.Resize( numberOfCharacters ); @@ -149,7 +172,6 @@ bool WordBreakInfoTest( const BreakInfoData& data ) int UtcDaliTextSegnemtationSetLineBreakInfo(void) { - ToolkitTestApplication application; tet_infoline(" UtcDaliTextSegnemtationSetLineBreakInfo"); struct BreakInfoData data[] = @@ -177,6 +199,51 @@ int UtcDaliTextSegnemtationSetLineBreakInfo(void) "222222122222221221222212212221222222122222222220", }, { + "Latin script. Update initial paragraphs.", + "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n" + "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n" + "Ne nec nulla regione albucius, mea doctus delenit ad!\n" + "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n" + "Quidam corpora at duo. An eos possim scripserit?", + 0u, + 141u, + "22222122222122222122212222212222212222222222122122221222221222222222122122220" + "2221221222212222222122222222221222222122222222122222222122212220" + "221222122222122222221222222222122212222221222222212220" + "22122222212222222122222222222122221222122222122222222222122222222222212220" + "222222122222221221222212212221222222122222222220", + }, + { + "Latin script. Update mid paragraphs.", + "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n" + "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n" + "Ne nec nulla regione albucius, mea doctus delenit ad!\n" + "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n" + "Quidam corpora at duo. An eos possim scripserit?", + 141u, + 128u, + "22222122222122222122212222212222212222222222122122221222221222222222122122220" + "2221221222212222222122222222221222222122222222122222222122212220" + "221222122222122222221222222222122212222221222222212220" + "22122222212222222122222222222122221222122222122222222222122222222222212220" + "222222122222221221222212212221222222122222222220", + }, + { + "Latin script. Update final paragraphs.", + "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n" + "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n" + "Ne nec nulla regione albucius, mea doctus delenit ad!\n" + "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n" + "Quidam corpora at duo. An eos possim scripserit?", + 195u, + 122u, + "22222122222122222122212222212222212222222222122122221222221222222222122122220" + "2221221222212222222122222222221222222122222222122222222122212220" + "221222122222122222221222222222122212222221222222212220" + "22122222212222222122222222222122221222122222122222222222122222222222212220" + "222222122222221221222212212221222222122222222220", + }, + { "Japanese script", "韓国側は北朝鮮当局を通じて米ドルで賃金を支払う。\n" "国際社会から様々な経済制裁を受ける北朝鮮にとっては出稼ぎ労働などと並んで重要な外貨稼ぎの手段となっている。\n" @@ -199,10 +266,11 @@ int UtcDaliTextSegnemtationSetLineBreakInfo(void) "21111112112111111111111211121111111111120", } }; - const unsigned int numberOfTests = 4u; + const unsigned int numberOfTests = 7u; for( unsigned int index = 0u; index < numberOfTests; ++index ) { + ToolkitTestApplication application; if( !LineBreakInfoTest( data[index] ) ) { tet_result(TET_FAIL); @@ -215,7 +283,6 @@ int UtcDaliTextSegnemtationSetLineBreakInfo(void) int UtcDaliTextSegnemtationSetWordBreakInfo(void) { - ToolkitTestApplication application; tet_infoline(" UtcDaliTextSegnemtationSetWordBreakInfo"); struct BreakInfoData data[] = @@ -380,6 +447,7 @@ int UtcDaliTextSegnemtationSetWordBreakInfo(void) for( unsigned int index = 0u; index < numberOfTests; ++index ) { + ToolkitTestApplication application; if( !WordBreakInfoTest( data[index] ) ) { tet_result(TET_FAIL);