Merge branch 'tizen' into new_text
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-internal / utc-Dali-Internal-Text.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/integration-api/glyph-set.h>
23 #include <dali-test-suite-utils.h>
24
25 // Internal headers are allowed here
26
27 #include <dali/internal/event/text/text-impl.h>
28
29 using namespace Dali;
30
31 void utc_dali_internal_text_startup()
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void utc_dali_internal_text_cleanup()
37 {
38   test_return_value = TET_PASS;
39 }
40
41 int UtcDaliTextGetImplementation01(void)
42 {
43   TestApplication application;
44
45   Text text( std::string( "Hello world" ) );
46
47   const Internal::Text& textImpl1 = text.GetImplementation();
48
49   DALI_TEST_CHECK( NULL != &textImpl1 );
50
51   Internal::Text& textImpl2 = text.GetImplementation();
52
53   DALI_TEST_CHECK( NULL != &textImpl2 );
54
55   END_TEST;
56 }
57
58 int UtcDaliTextGetImplementation02(void)
59 {
60   TestApplication application;
61
62   Text text;
63
64   bool assert1 = false;
65   bool assert2 = false;
66
67   try  // const GetImpl
68   {
69     const Internal::Text& impl = text.GetImplementation();
70     (void)impl; // Avoid unused variable warning
71   }
72   catch( DaliException& e )
73   {
74     tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
75     DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::GetImplementation: Text is uninitialized\"", TEST_LOCATION );
76
77     assert1 = true;
78   }
79
80   try   // non const getImp
81   {
82     Internal::Text& impl = text.GetImplementation();
83     (void)impl; // Avoid unused variable warning
84   }
85   catch( DaliException& e )
86   {
87     tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
88     DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::GetImplementation: Text is uninitialized\"", TEST_LOCATION );
89
90     assert2 = true;
91   }
92
93   if( assert1 && assert2 )
94   {
95     tet_result( TET_PASS );
96   }
97   else
98   {
99     tet_result( TET_FAIL );
100   }
101   END_TEST;
102 }
103
104 int UtcDaliTextGetTextArray(void)
105 {
106   TestApplication application;
107
108   Text text( std::string( "Hello world" ) );
109
110   DALI_TEST_EQUALS( text.GetImplementation().GetTextArray().Count(), 11u, TEST_LOCATION );
111
112   END_TEST;
113 }