2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali/internal/event/text/character-impl.h>
24 #include <dali-test-suite-utils.h>
28 static void Startup();
29 static void Cleanup();
32 void (*tet_startup)() = Startup;
33 void (*tet_cleanup)() = Cleanup;
37 POSITIVE_TC_IDX = 0x01,
41 #define MAX_NUMBER_OF_TESTS 10000
43 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
46 // Add test functionality for all APIs in the class (Positive and Negative)
47 TEST_FUNCTION( UtcDaliCharacterCopyConstructor, POSITIVE_TC_IDX );
48 TEST_FUNCTION( UtcDaliCharacterComparissonOperators, POSITIVE_TC_IDX );
49 TEST_FUNCTION( UtcDaliCharacterAssignmentOperator, POSITIVE_TC_IDX );
50 TEST_FUNCTION( UtcDaliCharacterIsLeftToRight, POSITIVE_TC_IDX );
51 TEST_FUNCTION( UtcDaliGetCharacterDirection, POSITIVE_TC_IDX );
52 TEST_FUNCTION( UtcDaliCharacterIsWhiteSpace, POSITIVE_TC_IDX );
53 TEST_FUNCTION( UtcDaliCharacterIsNewLine, POSITIVE_TC_IDX );
54 TEST_FUNCTION( UtcDaliCharacterGetImplementation,POSITIVE_TC_IDX );
56 // Called only once before first test is run.
61 // Called only once after last test is run
66 static void UtcDaliCharacterCopyConstructor()
68 tet_infoline("UtcDaliCharacterCopyConstructor ");
69 TestApplication application;
71 Text text( std::string("12") );
73 Character c1 = text[0];
74 Character c2 = text[1];
79 DALI_TEST_CHECK( (c1==c3) && (c2==c4) );
82 static void UtcDaliCharacterComparissonOperators()
84 tet_infoline("UtcDaliCharacterComparissonOperators ");
85 TestApplication application;
87 Text text( std::string("12") );
89 Character c1 = text[0];
90 Character c2 = text[1];
95 DALI_TEST_CHECK( (c1==c3) && (c2==c4) && (c1!=c2) && (c1!=c4) );
98 static void UtcDaliCharacterAssignmentOperator()
100 tet_infoline("UtcDaliCharacterAssignmentOperator ");
101 TestApplication application;
103 Text text( std::string("12") );
104 Character c1 = text[0];
105 Character c2 = text[1];
107 DALI_TEST_CHECK( c1 == c1);
109 // this should do nothing
111 DALI_TEST_CHECK( c1 == c2);
115 static void UtcDaliCharacterIsLeftToRight()
117 tet_infoline("UtcDaliCharacterIsLeftToRight ");
118 TestApplication application;
120 Text text( std::string("12בא") );
122 Character c1 = text[0];
123 Character c2 = text[1];
124 Character c3 = text[2];
125 Character c4 = text[3];
127 DALI_TEST_CHECK( c1.GetCharacterDirection() != Character::RightToLeft &&
128 c2.GetCharacterDirection() != Character::RightToLeft &&
129 c3.GetCharacterDirection() == Character::RightToLeft &&
130 c4.GetCharacterDirection() == Character::RightToLeft );
133 static void UtcDaliGetCharacterDirection()
135 tet_infoline("UtcDaliGetCharacterDirection ");
136 TestApplication application;
138 Text text( std::string("Aבא ") );
140 Character c1 = text[0];
141 Character c2 = text[1];
142 Character c3 = text[2];
143 Character c4 = text[3];
145 DALI_TEST_EQUALS( c1.GetCharacterDirection(), Character::LeftToRight, TEST_LOCATION );
146 DALI_TEST_EQUALS( c2.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
147 DALI_TEST_EQUALS( c3.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
148 DALI_TEST_EQUALS( c4.GetCharacterDirection(), Character::Neutral, TEST_LOCATION );
151 static void UtcDaliCharacterIsWhiteSpace()
153 tet_infoline("UtcDaliCharacterIsWhiteSpace ");
154 TestApplication application;
156 Text text( std::string("ab c\n\tdef") );
158 DALI_TEST_CHECK(!text[0].IsWhiteSpace()); // 'a'
159 DALI_TEST_CHECK(!text[1].IsWhiteSpace()); // 'b'
160 DALI_TEST_CHECK(text[2].IsWhiteSpace()); // ' '
161 DALI_TEST_CHECK(!text[3].IsWhiteSpace()); // 'c'
162 DALI_TEST_CHECK(text[4].IsWhiteSpace()); // '\n'
163 DALI_TEST_CHECK(text[5].IsWhiteSpace()); // '\t'
164 DALI_TEST_CHECK(!text[6].IsWhiteSpace()); // 'd'
165 DALI_TEST_CHECK(!text[7].IsWhiteSpace()); // 'e'
166 DALI_TEST_CHECK(!text[8].IsWhiteSpace()); // 'f'
169 static void UtcDaliCharacterIsNewLine()
171 tet_infoline("UtcDaliCharacterIsWhiteSpace ");
172 TestApplication application;
174 Text text( std::string("ab c\n\tdef") );
176 DALI_TEST_CHECK(!text[0].IsNewLine()); // 'a'
177 DALI_TEST_CHECK(!text[1].IsNewLine()); // 'b'
178 DALI_TEST_CHECK(!text[2].IsNewLine()); // ' '
179 DALI_TEST_CHECK(!text[3].IsNewLine()); // 'c'
180 DALI_TEST_CHECK(text[4].IsNewLine()); // '\n'
181 DALI_TEST_CHECK(!text[5].IsNewLine()); // '\t'
182 DALI_TEST_CHECK(!text[6].IsNewLine()); // 'd'
183 DALI_TEST_CHECK(!text[7].IsNewLine()); // 'e'
184 DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f'
187 static void UtcDaliCharacterGetImplementation()
189 tet_infoline("UtcDaliCharacterIsWhiteSpace ");
190 TestApplication application;
192 Text text( std::string("a") );
193 Character c1 = text[0];
194 const Dali::Internal::Character& impl = c1.GetImplementation();
195 DALI_TEST_CHECK( impl.GetCharacter() == 'a' );