2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
25 #include <dali-toolkit/internal/text/text-controller.h>
26 #include <dali-toolkit/internal/text/text-controller-impl.h>
29 using namespace Toolkit;
32 int UtcDaliTextLabelMarkupUnderline(void)
34 ToolkitTestApplication application;
35 tet_infoline(" UtcDaliTextLabelMarkupUnderline ");
37 TextLabel textLabel = TextLabel::New();
39 application.GetScene().Add( textLabel );
41 textLabel.SetProperty( TextLabel::Property::TEXT, "<u>ABC</u>EF<u>GH</u>" );
42 textLabel.SetProperty( TextLabel ::Property::ENABLE_MARKUP, true );
44 application.SendNotification();
47 uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
49 Toolkit::Internal::TextLabel& textLabelImpl = GetImpl( textLabel );
50 const Text::Length numberOfUnderlineRuns = textLabelImpl.getController()->GetTextModel()->GetNumberOfUnderlineRuns();
52 DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION );
54 Vector<GlyphRun> underlineRuns;
55 underlineRuns.Resize(numberOfUnderlineRuns);
56 textLabelImpl.getController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
59 DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
60 DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
61 DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
64 DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
65 DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);