[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Text-Range.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/text/range.h>
25
26 using namespace Dali;
27 using namespace Toolkit;
28
29 int UtcDaliToolkitTextRangeNew(void)
30 {
31   ToolkitTestApplication application;
32   tet_infoline(" UtcDaliToolkitTextRangeNew");
33
34   auto range15to20 = Dali::Toolkit::Text::Range::New(15u, 20u);
35   DALI_TEST_CHECK(range15to20);
36
37   auto range25to20 = Dali::Toolkit::Text::Range::New(25u, 20u);
38   DALI_TEST_CHECK(range25to20);
39
40   END_TEST;
41 }
42
43 int UtcDaliToolkitTextRangeGetStartIndex(void)
44 {
45   ToolkitTestApplication application;
46   tet_infoline(" UtcDaliToolkitTextRangeGetStartIndex");
47
48   auto range15to20 = Dali::Toolkit::Text::Range::New(15u, 20u);
49   DALI_TEST_CHECK(range15to20);
50   DALI_TEST_EQUALS(15u, range15to20.GetStartIndex(), TEST_LOCATION);
51
52   auto range25to20 = Dali::Toolkit::Text::Range::New(25u, 20u);
53   DALI_TEST_CHECK(range25to20);
54   DALI_TEST_EQUALS(20u, range25to20.GetStartIndex(), TEST_LOCATION);
55
56   END_TEST;
57 }
58
59 int UtcDaliToolkitTextRangeGetEndIndex(void)
60 {
61   ToolkitTestApplication application;
62   tet_infoline(" UtcDaliToolkitTextRangeGetEndIndex");
63
64   auto range15to20 = Dali::Toolkit::Text::Range::New(15u, 20u);
65   DALI_TEST_CHECK(range15to20);
66   DALI_TEST_EQUALS(20u, range15to20.GetEndIndex(), TEST_LOCATION);
67
68   auto range25to20 = Dali::Toolkit::Text::Range::New(25u, 20u);
69   DALI_TEST_CHECK(range25to20);
70   DALI_TEST_EQUALS(25u, range25to20.GetEndIndex(), TEST_LOCATION);
71
72   END_TEST;
73 }
74
75 int UtcDaliToolkitTextRangeGetNumberOfIndices(void)
76 {
77   ToolkitTestApplication application;
78   tet_infoline(" UtcDaliToolkitTextRangeGetNumberOfIndices");
79
80   auto range15to20 = Dali::Toolkit::Text::Range::New(15u, 20u);
81   DALI_TEST_CHECK(range15to20);
82   DALI_TEST_EQUALS(6u, range15to20.GetNumberOfIndices(), TEST_LOCATION);
83
84   auto range25to20 = Dali::Toolkit::Text::Range::New(25u, 20u);
85   DALI_TEST_CHECK(range25to20);
86   DALI_TEST_EQUALS(6u, range25to20.GetNumberOfIndices(), TEST_LOCATION);
87
88   END_TEST;
89 }