+int UtcDaliTextGetScript(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextGetScript");
+
+ Script script = TextAbstraction::LATIN;
+
+ // Text with no scripts.
+ Vector<ScriptRun> scriptRuns;
+ Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
+ script = GetScript( 0u,
+ scriptRunIt,
+ scriptRuns.End() );
+
+ DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
+
+ const unsigned int numberOfCharacters = 7u;
+ // Add scripts.
+ ScriptRun scriptRun01 =
+ {
+ {
+ 0u,
+ 2u,
+ },
+ TextAbstraction::LATIN
+ };
+ ScriptRun scriptRun02 =
+ {
+ {
+ 2u,
+ 2u,
+ },
+ TextAbstraction::HEBREW
+ };
+ ScriptRun scriptRun03 =
+ {
+ {
+ 4u,
+ 2u,
+ },
+ TextAbstraction::ARABIC
+ };
+ scriptRuns.PushBack( scriptRun01 );
+ scriptRuns.PushBack( scriptRun02 );
+ scriptRuns.PushBack( scriptRun03 );
+
+ // Expected results
+ TextAbstraction::Script expectedScripts[]=
+ {
+ TextAbstraction::LATIN,
+ TextAbstraction::LATIN,
+ TextAbstraction::HEBREW,
+ TextAbstraction::HEBREW,
+ TextAbstraction::ARABIC,
+ TextAbstraction::ARABIC,
+ TextAbstraction::UNKNOWN
+ };
+
+ scriptRunIt = scriptRuns.Begin();
+ for( unsigned int index = 0u; index < numberOfCharacters; ++index )
+ {
+ script = GetScript( index,
+ scriptRunIt,
+ scriptRuns.End() );
+
+ DALI_TEST_CHECK( expectedScripts[index] == script );
+ }
+ DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextMergeFontDescriptions(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextMergeFontDescriptions");
+
+ // Load some fonts.
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName( pathNamePtr );
+ free( pathNamePtr );
+
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
+ fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
+
+ // To test the font width as GetFontId() with the font file path can't cache the width property.
+ TextAbstraction::FontDescription widthDescription;
+ widthDescription.path = "";
+ widthDescription.family = "DejaVu Serif";
+ widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
+ widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
+ widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
+ fontClient.GetFontId( widthDescription );
+
+ // Test.
+
+ TextAbstraction::FontDescription defaultFontDescription01;
+ Vector<FontDescriptionRun> fontDescriptionRuns01;
+ Vector<FontId> expectedFontIds01;
+ Vector<bool> expectedIsFontDefault01;
+
+ TextAbstraction::FontDescription defaultFontDescription02;
+ Vector<FontDescriptionRun> fontDescriptionRuns02;
+ Vector<FontId> expectedFontIds02;
+ expectedFontIds02.PushBack( 0u );
+ expectedFontIds02.PushBack( 0u );
+ Vector<bool> expectedIsFontDefault02;
+ expectedIsFontDefault02.PushBack( true );
+ expectedIsFontDefault02.PushBack( true );
+
+ TextAbstraction::FontDescription defaultFontDescription03;
+ defaultFontDescription03.family = "DejaVu Serif";
+ Vector<FontDescriptionRun> fontDescriptionRuns03;
+
+ FontDescriptionRun fontDescription0301 =
+ {
+ {
+ 0u,
+ 2u
+ },
+ const_cast<char*>( "DejaVu Sans" ),
+ 11u,
+ TextAbstraction::FontWeight::NONE,
+ TextAbstraction::FontWidth::NONE,
+ TextAbstraction::FontSlant::NONE,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ true,
+ false,
+ false,
+ false,
+ false
+ };
+ FontDescriptionRun fontDescription0302 =
+ {
+ {
+ 2u,
+ 2u
+ },
+ NULL,
+ 0u,
+ TextAbstraction::FontWeight::NONE,
+ TextAbstraction::FontWidth::NONE,
+ TextAbstraction::FontSlant::ITALIC,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ false,
+ false,
+ false,
+ true,
+ false
+ };
+ FontDescriptionRun fontDescription0303 =
+ {
+ {
+ 4u,
+ 2u
+ },
+ NULL,
+ 0u,
+ TextAbstraction::FontWeight::BOLD,
+ TextAbstraction::FontWidth::NONE,
+ TextAbstraction::FontSlant::NONE,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ false,
+ true,
+ false,
+ false,
+ false
+ };
+ FontDescriptionRun fontDescription0304 =
+ {
+ {
+ 6u,
+ 2u
+ },
+ NULL,
+ 0u,
+ TextAbstraction::FontWeight::NONE,
+ TextAbstraction::FontWidth::NONE,
+ TextAbstraction::FontSlant::NONE,
+ NON_DEFAULT_FONT_SIZE,
+ false,
+ false,
+ false,
+ false,
+ true
+ };
+ FontDescriptionRun fontDescription0305 =
+ {
+ {
+ 8u,
+ 2u
+ },
+ NULL,
+ 0u,
+ TextAbstraction::FontWeight::NONE,
+ TextAbstraction::FontWidth::EXPANDED,
+ TextAbstraction::FontSlant::NONE,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ false,
+ false,
+ true,
+ false,
+ false
+ };
+
+ fontDescriptionRuns03.PushBack( fontDescription0301 );
+ fontDescriptionRuns03.PushBack( fontDescription0302 );
+ fontDescriptionRuns03.PushBack( fontDescription0303 );
+ fontDescriptionRuns03.PushBack( fontDescription0304 );
+ fontDescriptionRuns03.PushBack( fontDescription0305 );
+
+ Vector<FontId> expectedFontIds03;
+ expectedFontIds03.PushBack( 1u );
+ expectedFontIds03.PushBack( 1u );
+ expectedFontIds03.PushBack( 5u );
+ expectedFontIds03.PushBack( 5u );
+ expectedFontIds03.PushBack( 4u );
+ expectedFontIds03.PushBack( 4u );
+ expectedFontIds03.PushBack( 3u );
+ expectedFontIds03.PushBack( 3u );
+ expectedFontIds03.PushBack( 6u );
+ expectedFontIds03.PushBack( 6u );
+ Vector<bool> 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[] =
+ {
+ {
+ "void text.",
+ fontDescriptionRuns01,
+ defaultFontDescription01,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ 0u,
+ 0u,
+ expectedFontIds01,
+ expectedIsFontDefault01
+ },
+ {
+ "No description runs.",
+ fontDescriptionRuns02,
+ defaultFontDescription02,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ 0u,
+ 2u,
+ expectedFontIds02,
+ expectedIsFontDefault02
+ },
+ {
+ "Some description runs.",
+ fontDescriptionRuns03,
+ defaultFontDescription03,
+ TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ 0u,
+ 10u,
+ expectedFontIds03,
+ expectedIsFontDefault03
+ }
+ };
+ const unsigned int numberOfTests = 3u;
+
+ for( unsigned int index = 0u; index < numberOfTests; ++index )
+ {
+ if( !MergeFontDescriptionsTest( data[index] ) )
+ {
+ tet_result(TET_FAIL);
+ }
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+