X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-MultiLanguage.cpp;h=eba6b054d705909ccf60410980b77dba78c56c2f;hb=1e86d6f1a754a11410f1d5b89a4520757cb53ff5;hp=7fc8f71fd37070bf2712e51b28c471b61504ca17;hpb=d8cbd048a3d77a627c97eba193afd3c0514a789a;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 7fc8f71..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 ); + + 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, - fontIds, - data.defaultFontDescription, - data.defaultPointSize, - data.startIndex, - data.numberOfCharacters ); + 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, }, { @@ -1243,15 +1297,26 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) const std::string pathName( pathNamePtr ); free( pathNamePtr ); + const PointSize26Dot6 pointSize01 = static_cast( 21.f * 64.f ); + const PointSize26Dot6 pointSize02 = static_cast( 35.f * 64.f ); + // Load some fonts. fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" ); fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" ); fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 ); // Font id 1 --> TizenSansArabicRegular.ttf // Font id 2 --> TizenSansHebrewRegular.ttf // Font id 3 --> TizenColorEmoji.ttf - // Font id 4 --> (default) + // Font id 4 --> TizenSansRegular.ttf, size 8 + // Font id 5 --> TizenSansRegular.ttf, size 16 + // Font id 6 --> TizenSansHebrewRegular.ttf, size 8 + // Font id 7 --> TizenSansHebrewRegular.ttf, size 16 + // Font id 8 --> (default) Vector fontRuns01; Vector fontDescriptions01; @@ -1262,7 +1327,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) 0u, 11u }, - 4u + 8u }; Vector fontRuns02; fontRuns02.PushBack( fontRun0201 ); @@ -1294,7 +1359,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) 0u, 12u }, - 4u + 8u }; FontRun fontRun0302 = { @@ -1302,7 +1367,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) 12u, 12u }, - 4u + 8u }; FontRun fontRun0303 = { @@ -1310,7 +1375,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) 24u, 4u }, - 4u + 8u }; Vector fontRuns03; fontRuns03.PushBack( fontRun0301 ); @@ -1333,7 +1398,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) 4u, 1u }, - 4u + 8u }; FontRun fontRun0703 = { @@ -1433,6 +1498,122 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) }; fontDescriptions09.PushBack( fontDescription0901 ); + FontRun fontRun1001 = + { + { + 0u, + 13u + }, + 4u + }; + FontRun fontRun1002 = + { + { + 13u, + 9u + }, + 6u + }; + FontRun fontRun1003 = + { + { + 22u, + 15u + }, + 5u + }; + FontRun fontRun1004 = + { + { + 37u, + 9u + }, + 7u + }; + Vector fontRuns10; + fontRuns10.PushBack( fontRun1001 ); + fontRuns10.PushBack( fontRun1002 ); + fontRuns10.PushBack( fontRun1003 ); + fontRuns10.PushBack( fontRun1004 ); + + FontDescriptionRun fontDescription1001 = + { + { + 0u, + 13u + }, + const_cast( "TizenSans" ), + 9u, + TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontSlant::NORMAL, + pointSize01, + true, + false, + false, + false, + true + }; + FontDescriptionRun fontDescription1002 = + { + { + 13u, + 9u + }, + const_cast( "TizenSansHebrew" ), + 15u, + TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontSlant::NORMAL, + pointSize01, + true, + false, + false, + false, + true + }; + FontDescriptionRun fontDescription1003 = + { + { + 22u, + 15u + }, + const_cast( "TizenSans" ), + 9u, + TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontSlant::NORMAL, + pointSize02, + true, + false, + false, + false, + true + }; + FontDescriptionRun fontDescription1004 = + { + { + 37u, + 9u + }, + const_cast( "TizenSansHebrew" ), + 15u, + TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontSlant::NORMAL, + pointSize02, + true, + false, + false, + false, + true + }; + Vector fontDescriptions10; + fontDescriptions10.PushBack( fontDescription1001 ); + fontDescriptions10.PushBack( fontDescription1002 ); + fontDescriptions10.PushBack( fontDescription1003 ); + fontDescriptions10.PushBack( fontDescription1004 ); + const ValidateFontsData data[] = { { @@ -1525,8 +1706,18 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) fontDescriptions09, fontRuns09 }, + { + "Mix text. Default font: latin. Different font sizes", + "Hello world, שלום עולם, hello world, שלום עולם", + "/tizen/TizenSansRegular.ttf", + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 0u, + 46u, + fontDescriptions10, + fontRuns10 + }, }; - const unsigned int numberOfTests = 9u; + const unsigned int numberOfTests = 10u; for( unsigned int index = 0u; index < numberOfTests; ++index ) {