X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-ViewModel.cpp;h=a3ad9010d72867d9e1effb5a99df00c28ce65e9b;hb=076f84a43592f26ff0aa2bced54583f712800fe3;hp=74be44b0b7bad76dc5933106eeaa1051ae3a7ae0;hpb=a74a83237cb006215b7da0757da8d1e498f2c68f;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp index 74be44b..a3ad901 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -53,10 +53,10 @@ const Vector2 LOREM_SCROLL_POSITION( 0.f, -265.f ); const Length LOREM_NUMBER_OF_LINES = 35u; const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u; const Length LOREM_NUMBER_OF_GLYPHS = 632; -const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 395u; +const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 393u; // The expected layout size for UtcDaliTextViewModelGetLayoutSize -const Size LAYOUT_SIZE( 194.f, 45.f ); +const Size LAYOUT_SIZE( 181.f, 48.f ); // The expected color indices for UtcDaliTextViewModelGetColors const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u }; @@ -132,16 +132,16 @@ bool ElideTest( const ElideData& data ) const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u ); const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex; - std::cout << " last line alignment offset : " << lastLine.alignmentOffset << std::endl; + std::cout << " last line alignment offset : " << floor(lastLine.alignmentOffset) << std::endl; for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index ) { - if( *( data.positions + index ) != ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) ) + if( *( data.positions + index ) != floor(lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) ) { std::cout << " different layout :"; for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i ) { - std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x ); + std::cout << " " << floor( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x ); } std::cout << std::endl; std::cout << " expected :"; @@ -572,6 +572,24 @@ int UtcDaliTextViewModelElideText01(void) DALI_TEST_CHECK( NULL != glyphs ); DALI_TEST_CHECK( NULL != layouts ); + // When the ellipsis is enabled, at least a glyph has to be rendered. + // Even if the given width is too narrow for rendering an ellipsis glyph. + controller->SetText( "…" ); + Vector3 sizeEllipsis = controller->GetNaturalSize(); + controller->SetText( "A" ); + Vector3 sizeA = controller->GetNaturalSize(); + float testWidth = sizeA.width < sizeEllipsis.width ? sizeA.width : sizeEllipsis.width - 1.0; + + controller->SetText( "AB" ); + Vector3 sizeAB = controller->GetNaturalSize(); + + controller->Relayout( Size(testWidth, sizeAB.height) ); + + // Elide the glyphs. + model->ElideGlyphs(); + DALI_TEST_EQUALS( 1u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, model->GetNumberOfLines(), TEST_LOCATION ); + tet_result(TET_PASS); END_TEST; } @@ -583,16 +601,16 @@ int UtcDaliTextViewModelElideText02(void) Size textSize00( 100.f, 100.f ); Size textSize01( 80.f, 100.f ); - float positions01[] = { 0.f, 8.f, 16.f, 26.f, 33.f, 41.f, 45.f, 54.f, 64.0f }; + float positions01[] = { 0.f, 7.f, 16.f, 26.f, 33.f, 41.f, 45.f, 55.f, 64.0f }; Size textSize02( 80.f, 100.f ); - float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 13.0f }; + float positions02[] = { 68.f, 62.f, 58.f, 50.f, 46.f, 42.f, 32.f, 24.f, 5.f }; Size textSize03( 80.f, 100.f ); - float positions03[] = { 74.f, 69.f, 66.f, 61.f, 53.f, 51.f, 47.f, 46.f, 41.f, 31.f, 28.f, 14.f, 7.f }; + float positions03[] = { 78.f, 72.f, 66.f, 62.f, 57.f, 50.f, 45.f, 41.f, 39.f, 33.f, 30.f, 24.f, 5.0f }; Size textSize04( 80.f, 10.f ); - float positions04[] = { 2.f }; + float positions04[] = { 1.f }; struct ElideData data[] = { @@ -609,7 +627,7 @@ int UtcDaliTextViewModelElideText02(void) "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.", textSize01, 5u, - 37u, + 36u, positions01 }, { @@ -617,7 +635,7 @@ int UtcDaliTextViewModelElideText02(void) "צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.", textSize02, 5u, - 49u, + 44u, positions02 }, { @@ -625,7 +643,7 @@ int UtcDaliTextViewModelElideText02(void) "عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.", textSize03, 5u, - 73u, + 66u, positions03 }, {