X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextLabel.cpp;h=f9128fd2d008c50c4a0969068c9e491ce7bb350f;hb=70162c49a1387daf074414b7c6223417fce53419;hp=bbe5db149983ec99c4dd76444a87ba650708dbcc;hpb=81691c01db9669685179b799bd88b9178d56e2c5;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp old mode 100755 new mode 100644 index bbe5db1..f9128fd --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -28,6 +28,8 @@ #include #include #include +#include +#include using namespace Dali; using namespace Toolkit; @@ -228,6 +230,23 @@ int UtcDaliToolkitTextLabelCopyConstructorP(void) END_TEST; } +int UtcDaliTextLabelMoveConstructor(void) +{ + ToolkitTestApplication application; + + TextLabel textLabel = TextLabel::New(); + textLabel.SetProperty( TextLabel::Property::TEXT, "Test" ); + DALI_TEST_CHECK( textLabel.GetProperty( TextLabel::Property::TEXT ) == "Test" ); + + TextLabel moved = std::move( textLabel ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( TextLabel::Property::TEXT ) == "Test" ); + DALI_TEST_CHECK( !textLabel ); + + END_TEST; +} + int UtcDaliToolkitTextLabelAssignmentOperatorP(void) { ToolkitTestApplication application; @@ -241,6 +260,24 @@ int UtcDaliToolkitTextLabelAssignmentOperatorP(void) END_TEST; } +int UtcDaliTextLabelMoveAssignment(void) +{ + ToolkitTestApplication application; + + TextLabel textLabel = TextLabel::New(); + textLabel.SetProperty( TextLabel::Property::TEXT, "Test" ); + DALI_TEST_CHECK( textLabel.GetProperty( TextLabel::Property::TEXT ) == "Test" ); + + TextLabel moved; + moved = std::move( textLabel ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( TextLabel::Property::TEXT ) == "Test" ); + DALI_TEST_CHECK( !textLabel ); + + END_TEST; +} + // Positive test case for a method int UtcDaliToolkitTextLabelGetPropertyP(void) { @@ -250,7 +287,7 @@ int UtcDaliToolkitTextLabelGetPropertyP(void) DALI_TEST_CHECK( label ); // Check Property Indices are correct - DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE ); @@ -284,11 +321,11 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) TextLabel label = TextLabel::New(); DALI_TEST_CHECK( label ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Note - we can't check the defaults since the stylesheets are platform-specific - label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); - DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION ); + label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS ); + DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION ); // Check that text can be correctly reset label.SetProperty( TextLabel::Property::TEXT, "Setting Text" ); @@ -658,7 +695,7 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void) // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Turn on all the effects label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -677,7 +714,7 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void) try { // Render some text with the shared atlas backend - label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); + label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS ); application.SendNotification(); application.Render(); } @@ -689,7 +726,7 @@ int UtcDaliToolkitTextlabelAtlasRenderP(void) try { // Render some text with the shared atlas backend - label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED ); + label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED ); application.SendNotification(); application.Render(); } @@ -707,7 +744,7 @@ int UtcDaliToolkitTextLabelLanguagesP(void) TextLabel label = TextLabel::New(); DALI_TEST_CHECK( label ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, " "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, " @@ -732,7 +769,7 @@ int UtcDaliToolkitTextLabelEmojisP(void) TextLabel label = TextLabel::New(); DALI_TEST_CHECK( label ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); @@ -775,7 +812,7 @@ int UtcDaliToolkitTextlabelScrollingP(void) DALI_TEST_CHECK( labelFinished ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( labelImmediate ); + application.GetScene().Add( labelImmediate ); // Turn on all the effects labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); @@ -783,7 +820,7 @@ int UtcDaliToolkitTextlabelScrollingP(void) labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE ); - Stage::GetCurrent().Add( labelFinished ); + application.GetScene().Add( labelFinished ); // Turn on all the effects labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); @@ -831,7 +868,7 @@ int UtcDaliToolkitTextlabelScrollingCenterAlignP(void) DALI_TEST_CHECK( labelLong ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( labelShort ); + application.GetScene().Add( labelShort ); // Turn on all the effects labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -840,7 +877,7 @@ int UtcDaliToolkitTextlabelScrollingCenterAlignP(void) labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE ); - Stage::GetCurrent().Add( labelLong ); + application.GetScene().Add( labelLong ); // Turn on all the effects labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -881,7 +918,7 @@ int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void) DALI_TEST_CHECK( labelLong ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( labelShort ); + application.GetScene().Add( labelShort ); // Turn on all the effects labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -890,7 +927,7 @@ int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void) labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE ); - Stage::GetCurrent().Add( labelLong ); + application.GetScene().Add( labelLong ); // Turn on all the effects labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); @@ -931,7 +968,7 @@ int UtcDaliToolkitTextlabelScrollingEndAlignP(void) DALI_TEST_CHECK( labelLong ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( labelShort ); + application.GetScene().Add( labelShort ); // Turn on all the effects labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); @@ -940,7 +977,7 @@ int UtcDaliToolkitTextlabelScrollingEndAlignP(void) labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE ); - Stage::GetCurrent().Add( labelLong ); + application.GetScene().Add( labelLong ); // Turn on all the effects labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); @@ -981,7 +1018,7 @@ int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void) DALI_TEST_CHECK( labelLong ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( labelShort ); + application.GetScene().Add( labelShort ); // Turn on all the effects labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); @@ -990,7 +1027,7 @@ int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void) labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE ); - Stage::GetCurrent().Add( labelLong ); + application.GetScene().Add( labelLong ); // Turn on all the effects labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); @@ -1029,7 +1066,7 @@ int UtcDaliToolkitTextlabelScrollingInterruptedP(void) DALI_TEST_CHECK( label ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) ); // Turn on all the effects label.SetProperty( TextLabel::Property::MULTI_LINE, false ); @@ -1082,7 +1119,7 @@ int UtcDaliToolkitTextlabelScrollingN(void) TextLabel label = TextLabel::New("Some text to scroll"); DALI_TEST_CHECK( label ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1113,7 +1150,7 @@ int UtcDaliToolkitTextlabelScrollingWithEllipsis(void) TextLabel label = TextLabel::New("Some text to scroll"); DALI_TEST_CHECK( label ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1161,7 +1198,7 @@ int UtcDaliToolkitTextlabelEllipsis(void) // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Turn on all the effects label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); @@ -1228,7 +1265,7 @@ int UtcDaliToolkitTextlabelTextWrapMode(void) //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" ); DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION ); @@ -1301,7 +1338,7 @@ int UtcDaliToolkitTextLabelColorComponents(void) label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" ); label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); drawTrace.Enable( true ); @@ -1341,7 +1378,7 @@ int UtcDaliToolkitTextlabelTextStyle01(void) label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) ); label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" ); label.SetProperty( TextLabel::Property::POINT_SIZE, 12 ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); Property::Map outlineMapSet; Property::Map outlineMapGet; @@ -1410,7 +1447,7 @@ int UtcDaliToolkitTextlabelMultiline(void) label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" ); label.SetProperty( TextLabel::Property::POINT_SIZE, 20 ); label.SetProperty( TextLabel::Property::MULTI_LINE, false ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); application.SendNotification(); application.Render(); @@ -1440,7 +1477,7 @@ int UtcDaliToolkitTextlabelTextDirection(void) label.SetProperty( TextLabel::Property::TEXT, "Hello world" ); label.SetProperty( TextLabel::Property::POINT_SIZE, 20 ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); // Test LTR text DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION ); @@ -1471,7 +1508,7 @@ int UtcDaliToolkitTextlabelVerticalLineAlignment(void) label.SetProperty( TextLabel::Property::TEXT, "Hello world" ); label.SetProperty( TextLabel::Property::POINT_SIZE, 15 ); label.SetProperty( TextLabel::Property::LINE_SPACING, 12 ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION ); label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE ); @@ -1519,7 +1556,7 @@ int UtcDaliToolkitTextLabelBitmapFont(void) // 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.GetScene().Add( label ); application.SendNotification(); application.Render(); @@ -1560,7 +1597,7 @@ int UtcDaliToolkitTextlabelTextFit(void) label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet ); label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); application.SendNotification(); application.Render(); @@ -1616,7 +1653,7 @@ int UtcDaliToolkitTextlabelMaxTextureSet(void) label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE ); - Stage::GetCurrent().Add( label ); + application.GetScene().Add( label ); application.SendNotification(); application.Render(); @@ -1630,3 +1667,25 @@ int UtcDaliToolkitTextlabelMaxTextureSet(void) END_TEST; } + +int UtcDaliToolkitTextlabelLastCharacterIndex(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex"); + + Vector2 size( 300.0f, 100.0f ); + + Dali::Toolkit::DevelText::RendererParameters textParameters; + textParameters.text = "This is a sample text to get the last index."; + textParameters.layout = "multiLine"; + textParameters.fontSize = 20.f; + textParameters.textWidth = 300u; + textParameters.textHeight = 100u; + textParameters.ellipsisEnabled = true; + Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters ); + + DALI_TEST_CHECK( !indexArray.Empty() ); + DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get(), 10, TEST_LOCATION ); + + END_TEST; +}