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-Text-MultiLanguage.cpp;h=eba6b054d705909ccf60410980b77dba78c56c2f;hp=eea51a6cb16fd7c958d59ca03ffd23610aeeb429;hb=95cb5c463e9ddbbf63ad58077b198c8e961a318f;hpb=848787435a85536032861126d0feffe7b1870911 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp index eea51a6..eba6b05 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -36,11 +36,12 @@ using namespace Text; // Tests the following functions with different scripts. // // void MergeFontDescriptions( const Vector& fontDescriptions, -// Vector& fontIds, // const TextAbstraction::FontDescription& defaultFontDescription, // TextAbstraction::PointSize26Dot6 defaultPointSize, -// CharacterIndex startIndex, -// Length numberOfCharacters ); +// CharacterIndex characterIndex, +// TextAbstraction::FontDescription& fontDescription, +// TextAbstraction::PointSize26Dot6& fontPointSize, +// bool& isDefaultFont ); // // Script GetScript( Length index, // Vector::ConstIterator& scriptRunIt, @@ -56,7 +57,8 @@ using namespace Text; // void MultilanguageSupport::ValidateFonts( const Vector& text, // const Vector& scripts, // const Vector& fontDescriptions, -// FontId defaultFontId, +// const TextAbstraction::FontDescription& defaultFontDescription, +// TextAbstraction::PointSize26Dot6 defaultFontPointSize, // CharacterIndex startIndex, // Length numberOfCharacters, // Vector& fonts ); @@ -79,6 +81,7 @@ struct MergeFontDescriptionsData unsigned int startIndex; ///< The start index. unsigned int numberOfCharacters; ///< The number of characters. Vector expectedFontIds; ///< The expected font ids. + Vector expectedIsDefault; ///< The expected font ids. }; struct ScriptsData @@ -103,18 +106,33 @@ struct ValidateFontsData }; ////////////////////////////////////////////////////////// - bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data ) { + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + Vector fontIds; fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u ); + Vector isDefaultFont; + isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true ); - MergeFontDescriptions( data.fontDescriptionRuns, - fontIds, - data.defaultFontDescription, - data.defaultPointSize, - data.startIndex, - data.numberOfCharacters ); + for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index ) + { + TextAbstraction::FontDescription fontDescription; + TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE; + + MergeFontDescriptions( data.fontDescriptionRuns, + data.defaultFontDescription, + data.defaultPointSize, + index, + fontDescription, + fontPointSize, + isDefaultFont[index] ); + + if( !isDefaultFont[index] ) + { + fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize ); + } + } if( fontIds.Count() != data.expectedFontIds.Count() ) { @@ -141,6 +159,12 @@ bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data ) std::cout << std::endl; return false; } + + if( isDefaultFont[index] != data.expectedIsDefault[index] ) + { + std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl; + return false; + } } return true; @@ -186,6 +210,12 @@ bool ScriptsTest( const ScriptsData& data ) if( scripts.Count() != data.scriptRuns.Count() ) { tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() ); + for( Vector::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it) + { + const ScriptRun& run = *it; + + std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl; + } return false; } @@ -244,6 +274,10 @@ bool ValidateFontTest( const ValidateFontsData& data ) // Get the default font id. const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont, data.defaultFontSize ); + TextAbstraction::FontDescription defaultFontDescription; + fontClient.GetDescription( defaultFontId, defaultFontDescription ); + + const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId ); Vector fontRuns; @@ -251,7 +285,8 @@ bool ValidateFontTest( const ValidateFontsData& data ) multilanguageSupport.ValidateFonts( utf32, scripts, data.fontDescriptionRuns, - defaultFontId, + defaultFontDescription, + defaultPointSize, 0u, numberOfCharacters, fontRuns ); @@ -267,7 +302,8 @@ bool ValidateFontTest( const ValidateFontsData& data ) multilanguageSupport.ValidateFonts( utf32, scripts, data.fontDescriptionRuns, - defaultFontId, + defaultFontDescription, + defaultPointSize, data.index, data.numberOfCharacters, fontRuns ); @@ -413,12 +449,16 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontDescription defaultFontDescription01; Vector fontDescriptionRuns01; Vector expectedFontIds01; + Vector expectedIsFontDefault01; TextAbstraction::FontDescription defaultFontDescription02; Vector fontDescriptionRuns02; Vector expectedFontIds02; expectedFontIds02.PushBack( 0u ); expectedFontIds02.PushBack( 0u ); + Vector expectedIsFontDefault02; + expectedIsFontDefault02.PushBack( true ); + expectedIsFontDefault02.PushBack( true ); TextAbstraction::FontDescription defaultFontDescription03; defaultFontDescription03.family = "DejaVu Serif"; @@ -432,9 +472,9 @@ int UtcDaliTextMergeFontDescriptions(void) }, const_cast( "DejaVu Sans" ), 11u, - TextAbstraction::FontWeight::NORMAL, - TextAbstraction::FontWidth::NORMAL, - TextAbstraction::FontSlant::NORMAL, + TextAbstraction::FontWeight::NONE, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::NONE, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, true, false, @@ -450,8 +490,8 @@ int UtcDaliTextMergeFontDescriptions(void) }, NULL, 0u, - TextAbstraction::FontWeight::NORMAL, - TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontWeight::NONE, + TextAbstraction::FontWidth::NONE, TextAbstraction::FontSlant::ITALIC, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, false, @@ -469,8 +509,8 @@ int UtcDaliTextMergeFontDescriptions(void) NULL, 0u, TextAbstraction::FontWeight::BOLD, - TextAbstraction::FontWidth::NORMAL, - TextAbstraction::FontSlant::NORMAL, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::NONE, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, false, true, @@ -486,9 +526,9 @@ int UtcDaliTextMergeFontDescriptions(void) }, NULL, 0u, - TextAbstraction::FontWeight::NORMAL, - TextAbstraction::FontWidth::NORMAL, - TextAbstraction::FontSlant::NORMAL, + TextAbstraction::FontWeight::NONE, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::NONE, NON_DEFAULT_FONT_SIZE, false, false, @@ -504,9 +544,9 @@ int UtcDaliTextMergeFontDescriptions(void) }, NULL, 0u, - TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWeight::NONE, TextAbstraction::FontWidth::EXPANDED, - TextAbstraction::FontSlant::NORMAL, + TextAbstraction::FontSlant::NONE, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, false, false, @@ -532,6 +572,17 @@ int UtcDaliTextMergeFontDescriptions(void) expectedFontIds03.PushBack( 3u ); expectedFontIds03.PushBack( 6u ); expectedFontIds03.PushBack( 6u ); + Vector expectedIsFontDefault03; + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); + expectedIsFontDefault03.PushBack( false ); const MergeFontDescriptionsData data[] = { @@ -542,7 +593,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 0u, - expectedFontIds01 + expectedFontIds01, + expectedIsFontDefault01 }, { "No description runs.", @@ -551,7 +603,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 2u, - expectedFontIds02 + expectedFontIds02, + expectedIsFontDefault02 }, { "Some description runs.", @@ -560,7 +613,8 @@ int UtcDaliTextMergeFontDescriptions(void) TextAbstraction::FontClient::DEFAULT_POINT_SIZE, 0u, 10u, - expectedFontIds03 + expectedFontIds03, + expectedIsFontDefault03 } }; const unsigned int numberOfTests = 3u; @@ -666,7 +720,7 @@ int UtcDaliTextMultiLanguageSetScripts(void) { { 0u, - 16u, + 15u, }, TextAbstraction::LATIN }; @@ -678,7 +732,7 @@ int UtcDaliTextMultiLanguageSetScripts(void) { { 0u, - 16u, + 15u, }, TextAbstraction::LATIN }; @@ -690,7 +744,7 @@ int UtcDaliTextMultiLanguageSetScripts(void) { { 0u, - 16u, + 15u, }, TextAbstraction::LATIN }; @@ -1091,23 +1145,23 @@ int UtcDaliTextMultiLanguageSetScripts(void) }, { "White spaces. At the beginning of the text.", - " Hello world.", + " Hello world", 0u, - 16u, + 15u, scriptRuns04, }, { "White spaces. At the end of the text.", - "Hello world. ", + "Hello world ", 0u, - 16u, + 15u, scriptRuns05, }, { "White spaces. At the middle of the text.", - "Hello world.", + "Hello world", 0u, - 16u, + 15u, scriptRuns06, }, {