removed reliance on dali-adaptor
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Character.cpp
1 /*
2  * Copyright (c) 2014 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 <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 void utc_dali_character_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void utc_dali_character_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 int UtcDaliCharacterCopyConstructor(void)
37 {
38   tet_infoline("UtcDaliCharacterCopyConstructor ");
39   TestApplication application;
40
41   Text text( std::string("12") );
42
43   Character c1 = text[0];
44   Character c2 = text[1];
45
46   Character c3( c1 );
47   Character c4 = c2;
48
49   DALI_TEST_CHECK( (c1==c3) && (c2==c4) );
50   END_TEST;
51 }
52
53 int UtcDaliCharacterComparissonOperators(void)
54 {
55   tet_infoline("UtcDaliCharacterComparissonOperators ");
56   TestApplication application;
57
58   Text text( std::string("12") );
59
60   Character c1 = text[0];
61   Character c2 = text[1];
62
63   Character c3( c1 );
64   Character c4 = c2;
65
66   DALI_TEST_CHECK( (c1==c3) && (c2==c4) && (c1!=c2) && (c1!=c4) );
67   END_TEST;
68 }
69
70 int UtcDaliCharacterAssignmentOperator(void)
71 {
72   tet_infoline("UtcDaliCharacterAssignmentOperator ");
73   TestApplication application;
74
75   Text text( std::string("12") );
76   Character c1 = text[0];
77   Character c2 = text[1];
78   c1 = c2; //assign
79   DALI_TEST_CHECK( c1 == c1);
80
81   // this should do nothing
82   c1 = c1;
83   DALI_TEST_CHECK(  c1 == c2);
84
85   END_TEST;
86 }
87
88 int UtcDaliCharacterIsLeftToRight(void)
89 {
90   tet_infoline("UtcDaliCharacterIsLeftToRight ");
91   TestApplication application;
92
93   Text text( std::string("12בא") );
94
95   Character c1 = text[0];
96   Character c2 = text[1];
97   Character c3 = text[2];
98   Character c4 = text[3];
99
100   DALI_TEST_CHECK( c1.GetCharacterDirection() != Character::RightToLeft &&
101                    c2.GetCharacterDirection() != Character::RightToLeft &&
102                    c3.GetCharacterDirection() == Character::RightToLeft &&
103                    c4.GetCharacterDirection() == Character::RightToLeft );
104   END_TEST;
105 }
106
107 int UtcDaliGetCharacterDirection(void)
108 {
109   tet_infoline("UtcDaliGetCharacterDirection ");
110   TestApplication application;
111
112   Text text( std::string("Aבא ") );
113
114   Character c1 = text[0];
115   Character c2 = text[1];
116   Character c3 = text[2];
117   Character c4 = text[3];
118
119   DALI_TEST_EQUALS( c1.GetCharacterDirection(), Character::LeftToRight, TEST_LOCATION );
120   DALI_TEST_EQUALS( c2.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
121   DALI_TEST_EQUALS( c3.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
122   DALI_TEST_EQUALS( c4.GetCharacterDirection(), Character::Neutral, TEST_LOCATION );
123   END_TEST;
124 }
125
126 int UtcDaliCharacterIsWhiteSpace(void)
127 {
128   tet_infoline("UtcDaliCharacterIsWhiteSpace ");
129   TestApplication application;
130
131   Text text( std::string("ab c\n\tdef") );
132
133   DALI_TEST_CHECK(!text[0].IsWhiteSpace()); // 'a'
134   DALI_TEST_CHECK(!text[1].IsWhiteSpace()); // 'b'
135   DALI_TEST_CHECK(text[2].IsWhiteSpace());  // ' '
136   DALI_TEST_CHECK(!text[3].IsWhiteSpace()); // 'c'
137   DALI_TEST_CHECK(text[4].IsWhiteSpace());  // '\n'
138   DALI_TEST_CHECK(text[5].IsWhiteSpace());  // '\t'
139   DALI_TEST_CHECK(!text[6].IsWhiteSpace()); // 'd'
140   DALI_TEST_CHECK(!text[7].IsWhiteSpace()); // 'e'
141   DALI_TEST_CHECK(!text[8].IsWhiteSpace()); // 'f'
142   END_TEST;
143 }
144
145 int UtcDaliCharacterIsNewLine(void)
146 {
147   tet_infoline("UtcDaliCharacterIsWhiteSpace ");
148   TestApplication application;
149
150   Text text( std::string("ab c\n\tdef") );
151
152   DALI_TEST_CHECK(!text[0].IsNewLine()); // 'a'
153   DALI_TEST_CHECK(!text[1].IsNewLine()); // 'b'
154   DALI_TEST_CHECK(!text[2].IsNewLine()); // ' '
155   DALI_TEST_CHECK(!text[3].IsNewLine()); // 'c'
156   DALI_TEST_CHECK( text[4].IsNewLine()); // '\n'
157   DALI_TEST_CHECK(!text[5].IsNewLine()); // '\t'
158   DALI_TEST_CHECK(!text[6].IsNewLine()); // 'd'
159   DALI_TEST_CHECK(!text[7].IsNewLine()); // 'e'
160   DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f'
161   END_TEST;
162 }