/*
- * 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.
#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali-toolkit/devel-api/text/bitmap-font.h>
+#include <dali-toolkit/devel-api/text/rendering-backend.h>
+#include <dali-toolkit/devel-api/text/text-utils-devel.h>
using namespace Dali;
using namespace Toolkit;
END_TEST;
}
+int UtcDaliTextLabelMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ TextLabel textLabel = TextLabel::New();
+ textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
+ DALI_TEST_CHECK( textLabel.GetProperty<std::string>( 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<std::string>( TextLabel::Property::TEXT ) == "Test" );
+ DALI_TEST_CHECK( !textLabel );
+
+ END_TEST;
+}
+
int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
{
ToolkitTestApplication application;
END_TEST;
}
+int UtcDaliTextLabelMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ TextLabel textLabel = TextLabel::New();
+ textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
+ DALI_TEST_CHECK( textLabel.GetProperty<std::string>( 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<std::string>( TextLabel::Property::TEXT ) == "Test" );
+ DALI_TEST_CHECK( !textLabel );
+
+ END_TEST;
+}
+
// Positive test case for a method
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 );
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<int>( 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<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
// Check that text can be correctly reset
label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
// 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" );
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();
}
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();
}
TextLabel label = TextLabel::New();
DALI_TEST_CHECK( label );
- Stage::GetCurrent().Add( label );
+ application.GetScene().Add( label );
const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
"բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
TextLabel label = TextLabel::New();
DALI_TEST_CHECK( label );
- Stage::GetCurrent().Add( label );
+ application.GetScene().Add( label );
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
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 );
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 );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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 );
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 );
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 );
// 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 );
//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 );
label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
// Test a transparent text - Rendering should be skipped.
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 );
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;
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();
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 );
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 );
// 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();
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();
- const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
+ const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
// check pixel size
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();
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<int>(), 10, TEST_LOCATION );
+
+ END_TEST;
+}