X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextLabel.cpp;h=9eea425710f163fe519c6e2e321e85da207a3c10;hp=67dc221b4e52891fefde9c917a2ed33eb83c6791;hb=a267f3da043b1b792ffc64d1848542aa761e44c0;hpb=1b032e3f72c144d2da593a1c20d15041a3de00a3 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 67dc221..9eea425 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace Dali; using namespace Toolkit; @@ -67,7 +69,6 @@ const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize"; const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis"; const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay"; -const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64 @@ -373,9 +374,9 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) Property::Map underlineMapSet; Property::Map underlineMapGet; - underlineMapSet.Insert( "enable", "false" ); - underlineMapSet.Insert( "color", "blue" ); - underlineMapSet.Insert( "height", "0" ); + underlineMapSet.Insert( "enable", false ); + underlineMapSet.Insert( "color", Color::BLUE ); + underlineMapSet.Insert( "height", 0 ); underlineMapGet = label.GetProperty( TextLabel::Property::UNDERLINE ); DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION ); @@ -394,8 +395,18 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) label.SetProperty( TextLabel::Property::TEXT, "MarkupText" ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION ); - application.SendNotification(); - application.Render(); + // Check for incomplete marks. + label.SetProperty( TextLabel::Property::TEXT, "MarkupText" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION ); + try + { + application.SendNotification(); + application.Render(); + } + catch( ... ) + { + tet_result(TET_FAIL); + } // Check autoscroll properties const int SCROLL_SPEED = 80; @@ -466,9 +477,9 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) // Check the underline property underlineMapSet.Clear(); - underlineMapSet.Insert( "enable", "true" ); - underlineMapSet.Insert( "color", "red" ); - underlineMapSet.Insert( "height", "1" ); + underlineMapSet.Insert( "enable", true ); + underlineMapSet.Insert( "color", Color::RED ); + underlineMapSet.Insert( "height", 1 ); label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); @@ -480,9 +491,9 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION ); underlineMapSet.Clear(); - underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, "true" ); - underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, "green" ); - underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, "2" ); + underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true ); + underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN ); + underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 ); label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); @@ -497,9 +508,9 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) underlineMapSet.Clear(); Property::Map underlineDisabledMapGet; - underlineDisabledMapGet.Insert( "enable", "false" ); - underlineDisabledMapGet.Insert( "color", "green" ); - underlineDisabledMapGet.Insert( "height", "2" ); + underlineDisabledMapGet.Insert( "enable", false ); + underlineDisabledMapGet.Insert( "color", Color::GREEN ); + underlineDisabledMapGet.Insert( "height", 2 ); label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); @@ -647,8 +658,8 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void) label.SetProperty( TextLabel::Property::MULTI_LINE, true ); Property::Map underlineMap; - underlineMap.Insert( "enable", "true" ); - underlineMap.Insert( "color", "red" ); + underlineMap.Insert( "enable", true ); + underlineMap.Insert( "color", Color::RED ); label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap ); Property::Map shadowMap; @@ -1174,7 +1185,7 @@ int UtcDaliToolkitTextlabelTextWrapMode(void) application.Render(); lineCount = label.GetProperty( TextLabel::Property::LINE_COUNT ); - DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION ); label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" ); DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION ); @@ -1189,7 +1200,7 @@ int UtcDaliToolkitTextlabelTextWrapMode(void) application.Render(); lineCount = label.GetProperty( TextLabel::Property::LINE_COUNT ); - DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION ); label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER ); DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION ); @@ -1198,7 +1209,7 @@ int UtcDaliToolkitTextlabelTextWrapMode(void) application.Render(); lineCount = label.GetProperty( TextLabel::Property::LINE_COUNT ); - DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION ); + DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION ); tet_infoline( "Ensure invalid string does not change wrapping mode" ); label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" ); @@ -1420,3 +1431,106 @@ int UtcDaliToolkitTextlabelVerticalLineAlignment(void) END_TEST; } + +int UtcDaliToolkitTextLabelBitmapFont(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextLabelBitmapFont"); + + DevelText::BitmapFontDescription fontDescription; + fontDescription.name = "Digits"; + fontDescription.underlinePosition = 0.f; + fontDescription.underlineThickness = 0.f; + + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } ); + fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } ); + + TextAbstraction::BitmapFont bitmapFont; + DevelText::CreateBitmapFont( fontDescription, bitmapFont ); + + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetFontId( bitmapFont ); + + TextLabel label = TextLabel::New(); + + label.SetProperty( TextLabel::Property::TEXT, "0123456789:" ); + label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" ); + + // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height. + DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + Stage::GetCurrent().Add( label ); + + application.SendNotification(); + application.Render(); + + // The text has been rendered if the height of the text-label is the height of the line. + DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + END_TEST; +} + +int ConvertPointToPixel( float point ) +{ + unsigned int horizontalDpi = 0u; + unsigned int verticalDpi = 0u; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetDpi( horizontalDpi, verticalDpi ); + + return ( point * 72.f ) / static_cast< float >( horizontalDpi ); +} + +int UtcDaliToolkitTextlabelTextFit(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelTextFit"); + TextLabel label = TextLabel::New(); + Vector2 size( 460.0f, 100.0f ); + label.SetSize( size ); + label.SetProperty( TextLabel::Property::TEXT, "Hello world" ); + + // check point size + Property::Map textFitMapSet; + textFitMapSet["enable"] = true; + textFitMapSet["minSize"] = 10.f; + textFitMapSet["maxSize"] = 100.f; + textFitMapSet["stepSize"] = -1.f; + textFitMapSet["fontSizeType"] = "pointSize"; + + label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet ); + label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f); + + Stage::GetCurrent().Add( label ); + + application.SendNotification(); + application.Render(); + + const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f ); + DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION ); + + // check pixel size + textFitMapSet.Clear(); + textFitMapSet["enable"] = true; + textFitMapSet["minSize"] = ConvertPointToPixel( 10.f ); + textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f ); + textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f ); + textFitMapSet["fontSizeType"] = "pixelSize"; + + label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION ); + + END_TEST; +}