X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-ViewModel.cpp;h=b13fcdaf9e1b9b7730f35e850f0c2d49f90b34f8;hb=31d704fbcf71a27571c66b30452a0c6ab4fe9b6e;hp=a3ad9010d72867d9e1effb5a99df00c28ce65e9b;hpb=fa5d5fb58397f47073bec868cb9d4a7a8be1427a;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 a3ad901..b13fcda 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -21,11 +21,12 @@ #include #include -#include +#include +#include #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; @@ -669,3 +670,89 @@ int UtcDaliTextViewModelElideText02(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextViewModelGetFontRuns(void) +{ + tet_infoline(" UtcDaliTextViewModelGetFontRuns"); + ToolkitTestApplication application; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi(93u, 93u); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName(pathNamePtr); + free(pathNamePtr); + + fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf"); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel()); + DALI_TEST_CHECK(typesetter); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK(NULL != model); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor(controller); + + // Sets a text and relais-out. + controller->SetMarkupProcessorEnabled(true); + controller->SetText("Hello HelloHello"); + controller->Relayout(CONTROL_SIZE); + + const Vector& validFonts = model->GetFontRuns(); + + // The font-runs should be equal to number of segments have different fonts. + DALI_TEST_EQUALS(validFonts.Count(), 3u, TEST_LOCATION); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetFontDescriptionRuns(void) +{ + tet_infoline(" UtcDaliTextViewModelGetFontDescriptionRuns"); + ToolkitTestApplication application; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi(93u, 93u); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName(pathNamePtr); + free(pathNamePtr); + + fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf"); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel()); + DALI_TEST_CHECK(typesetter); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK(NULL != model); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor(controller); + + // Sets a text and relais-out. + controller->SetMarkupProcessorEnabled(true); + controller->SetText("Hello HelloHello"); + controller->Relayout(CONTROL_SIZE); + + const Vector& validFonts = model->GetFontDescriptionRuns(); + + // The font-description-runs should be equal number of the used fonts. + DALI_TEST_EQUALS(validFonts.Count(), 2u, TEST_LOCATION); + + tet_result(TET_PASS); + END_TEST; +} \ No newline at end of file