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-TextSpannable.cpp;h=1f710000ab6bf252629ddace57b86c7edf09f750;hp=098e660e48dcdb0649c8141abe425999111c973d;hb=31d704fbcf71a27571c66b30452a0c6ab4fe9b6e;hpb=f834473c34a464b52c467fcb16350747a8e456b0 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-TextSpannable.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-TextSpannable.cpp index 098e660..1f71000 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-TextSpannable.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-TextSpannable.cpp @@ -29,8 +29,13 @@ #include #include #include +#include #include +#include +#include +#include #include +#include using namespace Dali; using namespace Toolkit; @@ -38,7 +43,7 @@ using namespace Toolkit; namespace { const std::string DEFAULT_FONT_DIR("/resources/fonts"); -const float PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format. +const float PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format. } // namespace Text::SpannableString CreateSpannableStringForForegroundColorSpan() @@ -100,8 +105,8 @@ int UtcDaliToolkitTextLabelSetSpannedText(void) application.SendNotification(); application.Render(); - Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel); - const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices(); + Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel); + const Text::ColorIndex* const colorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetColorIndices(); CheckColorIndices(colorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u}); @@ -182,7 +187,7 @@ int UtcDaliToolkitTextLabelSetSpannedText_FontSpan(void) application.SendNotification(); application.Render(); - Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel); + Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel); const Vector& validFontRuns = labelImpl.GetTextController()->GetTextModel()->GetFontRuns(); DALI_TEST_EQUALS(validFontRuns.Count(), 3u, TEST_LOCATION); @@ -212,4 +217,89 @@ int UtcDaliToolkitTextLabelSetSpannedText_FontSpan(void) DALI_TEST_EQUALS(validFontDescriptionRuns[0].slant, Dali::TextAbstraction::FontSlant::OBLIQUE, TEST_LOCATION); END_TEST; +} + +int UtcDaliTextModelIsSpannedTextPlaced(void) + +{ + tet_infoline(" UtcDaliTextModelIsSpannedTextPlaced"); + + ToolkitTestApplication application; + + // Create spanned-text and set it + Text::SpannableString spannedText = Text::SpannableString::New("Hello مرحبا"); + DALI_TEST_CHECK(spannedText); + + // Creates a text controller. + Dali::Toolkit::Text::ControllerPtr controllerTextEditor = Dali::Toolkit::Text::Controller::New(); + const Dali::Toolkit::Text::ModelInterface* modelEditor = controllerTextEditor->GetTextModel(); + + // Tests the rendering controller has been created. + Dali::Toolkit::Text::TypesetterPtr typesetterEditor = Dali::Toolkit::Text::Typesetter::New(controllerTextEditor->GetTextModel()); + DALI_TEST_CHECK(typesetterEditor); + + // Tests the view model has been created. + Dali::Toolkit::Text::ViewModel* viewModelEditor = typesetterEditor->GetViewModel(); + DALI_TEST_CHECK(viewModelEditor); + + // Configures the text controller similarly to the text-editor. + Dali::Toolkit::Text::ConfigureTextEditor(controllerTextEditor); + + DALI_TEST_EQUALS(false, modelEditor->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(false, viewModelEditor->IsSpannedTextPlaced(), TEST_LOCATION); + + controllerTextEditor->SetSpannedText(spannedText); + + DALI_TEST_EQUALS(true, modelEditor->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(true, viewModelEditor->IsSpannedTextPlaced(), TEST_LOCATION); + + // Creates a text controller. + Dali::Toolkit::Text::ControllerPtr controllerTextLabel = Dali::Toolkit::Text::Controller::New(); + const Dali::Toolkit::Text::ModelInterface* modelLabel = controllerTextLabel->GetTextModel(); + + // Tests the rendering controller has been created. + Dali::Toolkit::Text::TypesetterPtr typesetterLabel = Dali::Toolkit::Text::Typesetter::New(controllerTextLabel->GetTextModel()); + DALI_TEST_CHECK(typesetterLabel); + + // Tests the view model has been created. + Dali::Toolkit::Text::ViewModel* viewModelLabel = typesetterLabel->GetViewModel(); + DALI_TEST_CHECK(viewModelLabel); + + // Configures the text controller similarly to the text-label. + Dali::Toolkit::Text::ConfigureTextLabel(controllerTextLabel); + + DALI_TEST_EQUALS(false, modelLabel->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(false, viewModelLabel->IsSpannedTextPlaced(), TEST_LOCATION); + + controllerTextLabel->SetSpannedText(spannedText); + + DALI_TEST_EQUALS(true, modelLabel->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(true, viewModelLabel->IsSpannedTextPlaced(), TEST_LOCATION); + + // Creates a text controller. + Dali::Toolkit::Text::ControllerPtr controllerTextField = Dali::Toolkit::Text::Controller::New(); + const Dali::Toolkit::Text::ModelInterface* modelField = controllerTextField->GetTextModel(); + + // Tests the rendering controller has been created. + Dali::Toolkit::Text::TypesetterPtr typesetterField = Dali::Toolkit::Text::Typesetter::New(controllerTextField->GetTextModel()); + DALI_TEST_CHECK(typesetterField); + + // Tests the view model has been created. + Dali::Toolkit::Text::ViewModel* viewModelField = typesetterField->GetViewModel(); + DALI_TEST_CHECK(viewModelField); + + // Configures the text controller similarly to the text-field. + Dali::Toolkit::Text::ConfigureTextField(controllerTextField); + + DALI_TEST_EQUALS(false, modelField->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(false, viewModelField->IsSpannedTextPlaced(), TEST_LOCATION); + + controllerTextField->SetSpannedText(spannedText); + + DALI_TEST_EQUALS(true, modelField->IsSpannedTextPlaced(), TEST_LOCATION); + DALI_TEST_EQUALS(true, viewModelField->IsSpannedTextPlaced(), TEST_LOCATION); + + tet_result(TET_PASS); + + END_TEST; } \ No newline at end of file