X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-VisualModel.cpp;h=c0e6a7690448578ebb81d489671bd1cdf3a07fc8;hb=41e93476dff5dd7dd826f43e99aa3ef7e3ee2906;hp=c36fed6b10341942e9362cb7f7152ecb9a789424;hpb=9346cf33ef49063185d54fbbfc186864d96c51ca;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp index c36fed6..c0e6a76 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -23,7 +23,6 @@ #include #include - using namespace Dali; using namespace Toolkit; using namespace Text; @@ -36,12 +35,10 @@ using namespace Text; // void CreateGlyphsPerCharacterTable( CharacterIndex startIndex, // Length numberOfCharacters ) - ////////////////////////////////////////////////////////// namespace { - struct SetGlyphsPerCharacterData { std::string description; ///< Description of the test. @@ -62,78 +59,85 @@ struct SetCharacterToGlyphData unsigned int* glyphsIndices; ///< The glyph indices. }; -bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data ) +bool SetGlyphsPerCharacterTest(const SetGlyphsPerCharacterData& data) { // 1) Create the model. - LogicalModelPtr logicalModel; - VisualModelPtr visualModel; + ModelPtr textModel; MetricsPtr metrics; - Size textArea(100.f, 60.f); - Size layoutSize; + Size textArea(100.f, 60.f); + Size layoutSize; const Vector fontDescriptions; - const LayoutOptions options; - CreateTextModel( data.text, - textArea, - fontDescriptions, - options, - layoutSize, - logicalModel, - visualModel, - metrics, - false ); - - Vector& charactersToGlyph = visualModel->mCharactersToGlyph; - Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; + const LayoutOptions options; + CreateTextModel(data.text, + textArea, + fontDescriptions, + options, + layoutSize, + textModel, + metrics, + false, + LineWrap::WORD, + false, + Toolkit::DevelText::EllipsisPosition::END, + 0.0f, // lineSpacing + 0.0f // characterSpacing + ); + + LogicalModelPtr logicalModel = textModel->mLogicalModel; + VisualModelPtr visualModel = textModel->mVisualModel; + + Vector& charactersToGlyph = visualModel->mCharactersToGlyph; + Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; // 2) Clear the model. GlyphIndex startGlyphIndex = 0u; - if( 0u != charactersToGlyph.Count() ) + if(0u != charactersToGlyph.Count()) { // The number of glyphs to be removed. const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex]; - startGlyphIndex = charactersToGlyph[data.startIndex]; + startGlyphIndex = charactersToGlyph[data.startIndex]; - charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex, - charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters ); - glyphsPerCharacter.Erase( glyphsPerCharacter.Begin() + data.startIndex, - glyphsPerCharacter.Begin() + data.startIndex + data.numberOfCharacters ); + charactersToGlyph.Erase(charactersToGlyph.Begin() + data.startIndex, + charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters); + glyphsPerCharacter.Erase(glyphsPerCharacter.Begin() + data.startIndex, + glyphsPerCharacter.Begin() + data.startIndex + data.numberOfCharacters); // Update the character to glyph indices. - for( Vector::Iterator it = charactersToGlyph.Begin() + data.startIndex, - endIt = charactersToGlyph.End(); - it != endIt; - ++it ) + for(Vector::Iterator it = charactersToGlyph.Begin() + data.startIndex, + endIt = charactersToGlyph.End(); + it != endIt; + ++it) { *it -= numberOfGlyphs; } } // 3) Call the CreateGlyphsPerCharacterTable() function - visualModel->CreateGlyphsPerCharacterTable( data.startIndex, - startGlyphIndex, - data.numberOfCharacters ); + visualModel->CreateGlyphsPerCharacterTable(data.startIndex, + startGlyphIndex, + data.numberOfCharacters); // 4) Compare the results. - if( data.totalNumberOfCharacters != glyphsPerCharacter.Count() ) + if(data.totalNumberOfCharacters != glyphsPerCharacter.Count()) { std::cout << " Different number of characters : " << glyphsPerCharacter.Count() << ", expected : " << data.totalNumberOfCharacters << std::endl; return false; } - for( unsigned int i = 0u; i < data.totalNumberOfCharacters; ++i ) + for(unsigned int i = 0u; i < data.totalNumberOfCharacters; ++i) { - if( data.glyphsPerCharacter[i] != glyphsPerCharacter[i] ) + if(data.glyphsPerCharacter[i] != glyphsPerCharacter[i]) { std::cout << " Different number of glyphs for index " << i << std::endl; - for( unsigned int j = 0; j < data.totalNumberOfCharacters; ++j ) + for(unsigned int j = 0; j < data.totalNumberOfCharacters; ++j) { std::cout << glyphsPerCharacter[j] << " "; } std::cout << std::endl; std::cout << " expected" << std::endl; - for( unsigned int j = 0; j < data.totalNumberOfCharacters; ++j ) + for(unsigned int j = 0; j < data.totalNumberOfCharacters; ++j) { std::cout << data.glyphsPerCharacter[j] << " "; } @@ -145,76 +149,83 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data ) return true; } -bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data ) +bool SetCharacterToGlyphTest(const SetCharacterToGlyphData& data) { // 1) Create the model. - LogicalModelPtr logicalModel; - VisualModelPtr visualModel; + ModelPtr textModel; MetricsPtr metrics; - Size textArea(100.f, 60.f); - Size layoutSize; + Size textArea(100.f, 60.f); + Size layoutSize; const Vector fontDescriptions; - const LayoutOptions options; - CreateTextModel( data.text, - textArea, - fontDescriptions, - options, - layoutSize, - logicalModel, - visualModel, - metrics, - false ); - - Vector& charactersToGlyph = visualModel->mCharactersToGlyph; - Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; + const LayoutOptions options; + CreateTextModel(data.text, + textArea, + fontDescriptions, + options, + layoutSize, + textModel, + metrics, + false, + LineWrap::WORD, + false, + Toolkit::DevelText::EllipsisPosition::END, + 0.0f, // lineSpacing + 0.0f // characterSpacing + ); + + LogicalModelPtr logicalModel = textModel->mLogicalModel; + VisualModelPtr visualModel = textModel->mVisualModel; + + Vector& charactersToGlyph = visualModel->mCharactersToGlyph; + Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; // 2) Clear the model. GlyphIndex startGlyphIndex = 0u; - if( 0u != charactersToGlyph.Count() ) + if(0u != charactersToGlyph.Count()) { // The number of glyphs to be removed. const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex]; - startGlyphIndex = charactersToGlyph[data.startIndex]; + startGlyphIndex = charactersToGlyph[data.startIndex]; - charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex, - charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters ); + charactersToGlyph.Erase(charactersToGlyph.Begin() + data.startIndex, + charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters); // Update the character to glyph indices. - for( Vector::Iterator it = charactersToGlyph.Begin() + data.startIndex, - endIt = charactersToGlyph.End(); - it != endIt; - ++it ) + for(Vector::Iterator it = charactersToGlyph.Begin() + data.startIndex, + endIt = charactersToGlyph.End(); + it != endIt; + ++it) { *it -= numberOfGlyphs; } } // 3) Call the CreateCharacterToGlyphTable() function - visualModel->CreateCharacterToGlyphTable( data.startIndex, - startGlyphIndex, - data.numberOfCharacters ); + visualModel->CreateCharacterToGlyphTable(data.startIndex, + startGlyphIndex, + data.numberOfCharacters); // 4) Compare the results. - if( data.totalNumberOfCharacters != charactersToGlyph.Count() ) + if(data.totalNumberOfCharacters != charactersToGlyph.Count()) { std::cout << " Different number of character : " << charactersToGlyph.Count() << ", expected : " << data.totalNumberOfCharacters << std::endl; return false; } - for( unsigned int i = 0u; i < data.totalNumberOfCharacters; ++i ) + for(unsigned int i = 0u; i < data.totalNumberOfCharacters; ++i) { - if( data.glyphsIndices[i] != charactersToGlyph[i] ) + if(data.glyphsIndices[i] != charactersToGlyph[i]) { std::cout << " Different number of character to glyph index " << i << std::endl; - for( unsigned int j = 0; j < data.totalNumberOfCharacters; ++j ) + for(unsigned int j = 0; j < data.totalNumberOfCharacters; ++j) { std::cout << charactersToGlyph[j] << " "; } std::cout << std::endl; std::cout << " expected" << std::endl; - for( unsigned int j = 0; j < data.totalNumberOfCharacters; ++j ) + for(unsigned int j = 0; j < data.totalNumberOfCharacters; ++j) { std::cout << data.glyphsIndices[j] << " "; } @@ -234,72 +245,65 @@ int UtcDaliSetGlyphsPerCharacter(void) { tet_infoline(" UtcDaliSetGlyphsPerCharacter"); - Length glyphsPerCharacter02[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u }; - Length glyphsPerCharacter03[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u }; - Length glyphsPerCharacter04[] = { 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, - 1u, 1u, 1u, 1u, 0u, 1u, 0u, 2u, 1u, 0u, - 2u, 0u, 2u, 0u, 2u, 1u, 1u, 0u, 0u, 0u, - 2u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 2u, 1u, - 0u, 2u, 1u, 1u }; + Length glyphsPerCharacter02[] = {1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u}; + Length glyphsPerCharacter03[] = {1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u}; + Length glyphsPerCharacter04[] = {1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 1u, 0u, 2u, 1u, 0u, 2u, 0u, 2u, 0u, 2u, 1u, 1u, 0u, 0u, 0u, 2u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 2u, 1u, 0u, 2u, 1u, 1u}; struct SetGlyphsPerCharacterData data[] = - { - { - "Zero characters text", - "", - 0u, - 0u, - 0u, - NULL - }, - { - "Simple 1 to 1 text", - "Hello world", - 0u, - 11u, - 11u, - glyphsPerCharacter02, - }, - { - "Text with different number of glyphs and characters.", - "Hello different world", - 0u, - 21u, - 21u, - glyphsPerCharacter03, - }, { - "Text paragraphs with different number of glyphs and characters. Update initial paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 0u, - 22u, - 54u, - glyphsPerCharacter04, - }, - { - "Text paragraphs with different number of glyphs and characters. Update mid paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 22u, - 14u, - 54u, - glyphsPerCharacter04, - }, - { - "Text paragraphs with different number of glyphs and characters. Update final paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 36u, - 18u, - 54u, - glyphsPerCharacter04, - }, - }; + {"Zero characters text", + "", + 0u, + 0u, + 0u, + NULL}, + { + "Simple 1 to 1 text", + "Hello world", + 0u, + 11u, + 11u, + glyphsPerCharacter02, + }, + { + "Text with different number of glyphs and characters.", + "Hello different world", + 0u, + 21u, + 21u, + glyphsPerCharacter03, + }, + { + "Text paragraphs with different number of glyphs and characters. Update initial paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 0u, + 22u, + 54u, + glyphsPerCharacter04, + }, + { + "Text paragraphs with different number of glyphs and characters. Update mid paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 22u, + 14u, + 54u, + glyphsPerCharacter04, + }, + { + "Text paragraphs with different number of glyphs and characters. Update final paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 36u, + 18u, + 54u, + glyphsPerCharacter04, + }, + }; const unsigned int numberOfTests = 6u; - for( unsigned int index = 0u; index < numberOfTests; ++index ) + for(unsigned int index = 0u; index < numberOfTests; ++index) { ToolkitTestApplication application; - if( !SetGlyphsPerCharacterTest( data[index] ) ) + if(!SetGlyphsPerCharacterTest(data[index])) { tet_result(TET_FAIL); } @@ -313,70 +317,66 @@ int UtcDaliSetCharacterToGlyph(void) { tet_infoline(" UtcDaliSetGlyphsPerCharacter"); - GlyphIndex glyphIndices02[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u }; - GlyphIndex glyphIndices03[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u }; - GlyphIndex glyphIndices04[] = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, - 21u, 22u, 23u, 23u, 24u, 24u, 26u, 27u, 27u, 29u, 29u, 31u, 31u, 33u, - 34u, 35u, 35u, 35u, 35u, 37u, 38u, 39u, 40u, 41u, 42u, 42u, 42u, 44u, 45u, 45u, 47u, 48u }; + GlyphIndex glyphIndices02[] = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u}; + GlyphIndex glyphIndices03[] = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u}; + GlyphIndex glyphIndices04[] = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u, 23u, 24u, 24u, 26u, 27u, 27u, 29u, 29u, 31u, 31u, 33u, 34u, 35u, 35u, 35u, 35u, 37u, 38u, 39u, 40u, 41u, 42u, 42u, 42u, 44u, 45u, 45u, 47u, 48u}; struct SetCharacterToGlyphData data[] = - { - { - "Zero characters text", - "", - 0u, - 0u, - 0u, - NULL - }, - { - "Simple 1 to 1 text", - "Hello world", - 0u, - 11u, - 11u, - glyphIndices02, - }, - { - "Text with different number of glyphs and characters.", - "Hello different world", - 0u, - 21u, - 21u, - glyphIndices03, - }, - { - "Text paragraphs with different number of glyphs and characters. Update initial paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 0u, - 22u, - 54u, - glyphIndices04, - }, { - "Text paragraphs with different number of glyphs and characters. Update mid paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 22u, - 14u, - 54u, - glyphIndices04, - }, - { - "Text paragraphs with different number of glyphs and characters. Update final paragraphs.", - "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", - 36u, - 18u, - 54u, - glyphIndices04, - }, - }; + {"Zero characters text", + "", + 0u, + 0u, + 0u, + NULL}, + { + "Simple 1 to 1 text", + "Hello world", + 0u, + 11u, + 11u, + glyphIndices02, + }, + { + "Text with different number of glyphs and characters.", + "Hello different world", + 0u, + 21u, + 21u, + glyphIndices03, + }, + { + "Text paragraphs with different number of glyphs and characters. Update initial paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 0u, + 22u, + 54u, + glyphIndices04, + }, + { + "Text paragraphs with different number of glyphs and characters. Update mid paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 22u, + 14u, + 54u, + glyphIndices04, + }, + { + "Text paragraphs with different number of glyphs and characters. Update final paragraphs.", + "Hello different world\nनमस्ते दुनिया\nမင်္ဂလာပါကမ္ဘာလောက", + 36u, + 18u, + 54u, + glyphIndices04, + }, + }; const unsigned int numberOfTests = 6u; - for( unsigned int index = 0u; index < numberOfTests; ++index ) + for(unsigned int index = 0u; index < numberOfTests; ++index) { ToolkitTestApplication application; - if( !SetCharacterToGlyphTest( data[index] ) ) + if(!SetCharacterToGlyphTest(data[index])) { tet_result(TET_FAIL); }