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-Shaping.cpp;h=65a56da7007e6e0ded0e67b1f4f1908aac642356;hp=9e830ec27809e7fccb6cbd1c5e5a642b9c7ddb06;hb=184e719fa04c4a5bbe171c3be7da133e2a7a0399;hpb=e5a56dace042712c1d89015bcb43942dfb237af8 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp index 9e830ec..65a56da 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -21,7 +21,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; @@ -55,6 +55,8 @@ struct GlyphInfoData float yBearing; ///< The distance from the baseline to the topmost border of the glyph float advance; ///< The distance to move the cursor for this glyph float scaleFactor; ///< The scaling applied (fixed-size fonts only) + bool softwareItalic; ///< Whether glyph needs software support to draw italic style + bool softwareBold; ///< Whether glyph needs software support to draw bold style }; bool IsEqualGlyph ( const GlyphInfoData& glyphData, const GlyphInfo& glyph ) @@ -91,6 +93,14 @@ bool IsEqualGlyph ( const GlyphInfoData& glyphData, const GlyphInfo& glyph ) { return false; } + if( glyphData.softwareItalic != glyph.softwareItalic ) + { + return false; + } + if( glyphData.softwareBold != glyph.softwareBold ) + { + return false; + } return true; } @@ -107,13 +117,15 @@ struct ShapeInfoData Length* charactersPerGlyph; ///< The characters per glyph. uint32_t expectedNumberOfNewParagraphGlyphs; ///< The expected number of glyphs. GlyphIndex* newParagraphGlyphs; ///< Indices to the new paragraphs glyphs. + Vector fontDescriptions; ///< Fonts which is used for text. }; bool ShapeInfoTest( const ShapeInfoData& data ) { // 1) Create the model. - LogicalModelPtr logicalModel = LogicalModel::New(); - VisualModelPtr visualModel = VisualModel::New(); + LogicalModelPtr logicalModel; + VisualModelPtr visualModel; + MetricsPtr metrics; Size textArea(100.f, 60.f); Size layoutSize; @@ -121,11 +133,13 @@ bool ShapeInfoTest( const ShapeInfoData& data ) const LayoutOptions options; CreateTextModel( data.text, textArea, - fontDescriptions, + data.fontDescriptions, options, layoutSize, logicalModel, - visualModel ); + visualModel, + metrics, + false ); // 2) Clear the model. @@ -267,7 +281,6 @@ bool ShapeInfoTest( const ShapeInfoData& data ) int UtcDaliTextShape(void) { - ToolkitTestApplication application; tet_infoline(" UtcDaliTextShape"); struct GlyphInfoData glyphs02[] = @@ -315,18 +328,18 @@ int UtcDaliTextShape(void) struct GlyphInfoData glyphs04[] = { - { 2u, 160u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 123u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f }, - { 2u, 153u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 160u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 150u, 0.f, 0.f, 0.f, 0.f, 14.f, 0.f }, - { 2u, 153u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 160u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 151u, 0.f, 0.f, 0.f, 0.f, 12.f, 0.f }, - { 2u, 153u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 160u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, - { 2u, 147u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f }, - { 2u, 153u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, + { 2u, 1733u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1693u, 0.f, 0.f, 0.f, 0.f, 13.f, 0.f }, + { 2u, 1725u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1733u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1721u, 0.f, 0.f, 0.f, 0.f, 20.f, 0.f }, + { 2u, 1725u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1733u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1722u, 0.f, 0.f, 0.f, 0.f, 18.f, 0.f }, + { 2u, 1725u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1733u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, + { 2u, 1718u, 0.f, 0.f, 0.f, 0.f, 14.f, 0.f }, + { 2u, 1725u, 0.f, 0.f, 0.f, 0.f, 8.f, 0.f }, }; CharacterIndex characterIndices04[] = { 0u, 0u, 0u, 2u, 2u, 2u, 4u, 4u, 4u, 6u, 6u, 6u }; @@ -369,7 +382,7 @@ int UtcDaliTextShape(void) { 1u, 3u, 0.f, 0.f, 0.f, 0.f, 5.f, 0.f }, { 1u, 71u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f }, { 1u, 72u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f }, - { 1u, 5034u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f }, + { 1u, 5039u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f }, { 1u, 81u, 0.f, 0.f, 0.f, 0.f, 10.f, 0.f }, { 1u, 76u, 0.f, 0.f, 0.f, 0.f, 4.f, 0.f }, { 1u, 72u, 0.f, 0.f, 0.f, 0.f, 9.f, 0.f }, @@ -521,6 +534,155 @@ int UtcDaliTextShape(void) for( unsigned int index = 0u; index < numberOfTests; ++index ) { + ToolkitTestApplication application; + if( !ShapeInfoTest( data[index] ) ) + { + tet_result(TET_FAIL); + } + } + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextSoftwareStyling(void) +{ + tet_infoline(" UtcDaliTextSoftwareStyling"); + + struct GlyphInfoData glyphs01[] = + { + { 2u, 4857u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, true, false }, + { 2u, 7316u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, true, false }, + { 2u, 4364u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, true, false }, + }; + struct GlyphInfoData glyphs02[] = + { + { 2u, 4857u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, false, false }, + { 2u, 7316u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, false, false }, + { 2u, 4364u, 0.f, 0.f, 0.f, 0.f, 15.f, 0.f, true, false }, + }; + + CharacterIndex characterIndices[] = { 0u, 1u, 2u }; + Length charactersPerGlyph[] = { 1u, 1u, 1u }; + + Vector fontDescriptions01; + Vector fontDescriptions02; + + FontDescriptionRun fontDescriptionRun01 = + { + { + 0u, + 3u + }, + NULL, + 0u, + TextAbstraction::FontWeight::BOLD, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::ITALIC, + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + false, + true, + false, + true, + false + }; + fontDescriptions01.PushBack(fontDescriptionRun01); + + FontDescriptionRun fontDescriptionRun02 = + { + { + 0u, + 1u + }, + NULL, + 0u, + TextAbstraction::FontWeight::NONE, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::NONE, + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + false, + false, + false, + false, + false + }; + FontDescriptionRun fontDescriptionRun03 = + { + { + 1u, + 1u + }, + NULL, + 0u, + TextAbstraction::FontWeight::BOLD, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::NONE, + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + false, + true, + false, + false, + false + }; + FontDescriptionRun fontDescriptionRun04 = + { + { + 2u, + 1u + }, + NULL, + 0u, + TextAbstraction::FontWeight::NONE, + TextAbstraction::FontWidth::NONE, + TextAbstraction::FontSlant::ITALIC, + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + false, + false, + false, + true, + false + }; + + fontDescriptions02.PushBack(fontDescriptionRun02); + fontDescriptions02.PushBack(fontDescriptionRun03); + fontDescriptions02.PushBack(fontDescriptionRun04); + + + struct ShapeInfoData data[] = + { + { + "Chiness script. Characters have same font description", + "未取得", + 0u, + 3u, + 3u, + glyphs01, + characterIndices, + charactersPerGlyph, + 0u, + NULL, + fontDescriptions01 + }, + { + "Chiness script. Each character has different font description.", + "未取得", + 0u, + 3u, + 3u, + glyphs02, + characterIndices, + charactersPerGlyph, + 0u, + NULL, + fontDescriptions02 + } + }; + + const unsigned int numberOfTests = 2u; + + for( unsigned int index = 0u; index < numberOfTests; ++index ) + { + ToolkitTestApplication application; if( !ShapeInfoTest( data[index] ) ) { tet_result(TET_FAIL);