X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-Typesetter.cpp;h=63f9a22db418095b2e79145c5bb9deab5a46671d;hp=e7226ba9fb43ae79ca5552ae2e0fbf302630520e;hb=09ae840a22681a4bbdc770f00674498ab75aec69;hpb=534e542d7dcc1a1507a0e5e6845d49c06a15d326 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp index e7226ba..63f9a22 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp @@ -19,9 +19,11 @@ #include #include +#include #include #include +#include #include #include #include @@ -30,6 +32,12 @@ using namespace Dali; using namespace Toolkit; using namespace Text; +namespace +{ +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const PointSize26Dot6 EMOJI_FONT_SIZE = 62u * 64u; +} // namespace + int UtcDaliTextTypesetter(void) { tet_infoline(" UtcDaliTextTypesetter"); @@ -65,3 +73,71 @@ int UtcDaliTextTypesetterGetViewModel(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextRenderingControllerRender(void) +{ + tet_infoline(" UtcDaliTextRenderingControllerRender"); + ToolkitTestApplication application; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Sets the text. + controller->SetMarkupProcessorEnabled( true ); + controller->SetText( "Hello world \xF0\x9F\x98\x81" ); + + // Creates the text's model and relais-out the text. + const Size relayoutSize( 120.f, 60.f ); + controller->Relayout( relayoutSize ); + + // Tests the rendering controller has been created. + TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( renderingController ); + + // Renders the text and creates the final bitmap. + PixelData bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + // Changes vertical alignment. + controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER ); + controller->Relayout( relayoutSize ); + + // Renders the text and creates the final bitmap. + bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_BOTTOM ); + controller->Relayout( relayoutSize ); + + // Renders the text and creates the final bitmap. + bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +}