Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-test-suite / default-controls / utc-Dali-DefaultControls.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
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 #include <iostream>
18
19 #include <stdlib.h>
20 #include <tet_api.h>
21
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/public-api/controls/tool-bar/tool-bar.h>
24 #include <dali-toolkit/public-api/controls/view/view.h>
25 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
26 #include <dali-toolkit/public-api/controls/default-controls/push-button-factory.h>
27 #include <dali-toolkit/public-api/controls/default-controls/check-button-factory.h>
28
29 #include <dali-toolkit-test-suite-utils.h>
30
31 using namespace Dali;
32 using namespace Toolkit;
33
34 static void Startup();
35 static void Cleanup();
36
37 extern "C" {
38   void (*tet_startup)() = Startup;
39   void (*tet_cleanup)() = Cleanup;
40 }
41
42 enum {
43   POSITIVE_TC_IDX = 0x01,
44   NEGATIVE_TC_IDX,
45 };
46
47 #define MAX_NUMBER_OF_TESTS 10000
48 extern "C" {
49   struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
50 }
51
52 // Add test functionality for all APIs in the class (Positive and Negative)
53 TEST_FUNCTION( UtcDaliDefaultControlsCreateSolidColorActor, POSITIVE_TC_IDX );
54 TEST_FUNCTION( UtcDaliDefaultControlsCreatePushButton, POSITIVE_TC_IDX );
55 TEST_FUNCTION( UtcDaliDefaultControlsCreateCheckBoxButton, POSITIVE_TC_IDX );
56
57 // Called only once before first test is run.
58 static void Startup()
59 {
60 }
61
62 // Called only once after last test is run
63 static void Cleanup()
64 {
65 }
66
67 static void UtcDaliDefaultControlsCreateSolidColorActor()
68 {
69   ToolkitTestApplication application;
70
71   tet_infoline(" UtcDaliDefaultControlsCreateSolidColorActor");
72
73   ImageActor image1 = CreateSolidColorActor( Color::RED );
74   ImageActor image2 = CreateSolidColorActor( Color::RED, true, Color::BLUE, 2 );
75   ImageActor image3 = CreateSolidColorActor( Color::RED, true, Color::BLUE, 12 );
76
77   DALI_TEST_CHECK(image1);
78   DALI_TEST_CHECK(image2);
79   DALI_TEST_CHECK(!image3);
80 }
81
82 static void UtcDaliDefaultControlsCreatePushButton()
83 {
84   ToolkitTestApplication application;
85
86   tet_infoline(" UtcDaliDefaultControlsCreatePushButton");
87
88   const std::string imagePath( "Facke image path" );
89   const std::string voidImagePath( "" );
90
91   ImageActor image = CreateSolidColorActor( Color::RED );
92   ImageActor voidImage;
93
94   PushButton button0, button1, button2, button3, button4, button5, button6;
95
96   try
97   {
98     button0 = CreatePushButton( voidImagePath, voidImagePath, voidImagePath, voidImagePath, voidImagePath );
99     button1 = CreatePushButton( imagePath, voidImagePath, voidImagePath, voidImagePath, voidImagePath );
100     button2 = CreatePushButton( voidImagePath, imagePath, voidImagePath, voidImagePath, voidImagePath );
101     button3 = CreatePushButton( voidImagePath, voidImagePath, imagePath, voidImagePath, voidImagePath );
102     button4 = CreatePushButton( voidImagePath, voidImagePath, voidImagePath, imagePath, voidImagePath );
103     button5 = CreatePushButton( voidImagePath, voidImagePath, voidImagePath, voidImagePath, imagePath );
104     button6 = CreatePushButton( imagePath, imagePath, imagePath, imagePath, imagePath );
105   }
106   catch( ... )
107   {
108     tet_result( TET_FAIL );
109   }
110
111   DALI_TEST_CHECK( button0 );
112   DALI_TEST_CHECK( button1 );
113   DALI_TEST_CHECK( button2 );
114   DALI_TEST_CHECK( button3 );
115   DALI_TEST_CHECK( button4 );
116   DALI_TEST_CHECK( button5 );
117   DALI_TEST_CHECK( button6 );
118
119   try
120   {
121     button0 = CreatePushButton( voidImage, voidImage, voidImage, voidImage, voidImage );
122     button1 = CreatePushButton( image, voidImage, voidImage, voidImage, voidImage );
123     button2 = CreatePushButton( voidImage, image, voidImage, voidImage, voidImage );
124     button3 = CreatePushButton( voidImage, voidImage, image, voidImage, voidImage );
125     button4 = CreatePushButton( voidImage, voidImage, voidImage, image, voidImage );
126     button5 = CreatePushButton( voidImage, voidImage, voidImage, voidImage, image );
127     button6 = CreatePushButton( image, image, image, image, image );
128   }
129   catch( ... )
130   {
131     tet_result( TET_FAIL );
132   }
133
134   DALI_TEST_CHECK( button0 );
135   DALI_TEST_CHECK( button1 );
136   DALI_TEST_CHECK( button2 );
137   DALI_TEST_CHECK( button3 );
138   DALI_TEST_CHECK( button4 );
139   DALI_TEST_CHECK( button5 );
140   DALI_TEST_CHECK( button6 );
141
142   try
143   {
144     button0 = CreatePushButton( voidImagePath );
145     button1 = CreatePushButton( imagePath );
146   }
147   catch( ... )
148   {
149     tet_result( TET_FAIL );
150   }
151
152   DALI_TEST_CHECK( button0 );
153   DALI_TEST_CHECK( button1 );
154
155   try
156   {
157     button0 = CreatePushButton( voidImage );
158     button1 = CreatePushButton( image );
159   }
160   catch( ... )
161   {
162     tet_result( TET_FAIL );
163   }
164
165   DALI_TEST_CHECK( button0 );
166   DALI_TEST_CHECK( button1 );
167 }
168
169 static void UtcDaliDefaultControlsCreateCheckBoxButton()
170 {
171   ToolkitTestApplication application;
172
173   tet_infoline(" UtcDaliDefaultControlsCreateCheckBoxButton");
174
175   const std::string imagePath( "Facke image path" );
176   const std::string voidImagePath( "" );
177
178   ImageActor image = CreateSolidColorActor( Color::RED );
179   ImageActor voidImage;
180
181   CheckBoxButton button0, button1, button2, button3, button4, button5;
182
183   try
184   {
185     button0 = CreateCheckBoxButton( voidImagePath, voidImagePath, voidImagePath, voidImagePath );
186     button1 = CreateCheckBoxButton( imagePath, voidImagePath, voidImagePath, voidImagePath );
187     button2 = CreateCheckBoxButton( voidImagePath, imagePath, voidImagePath, voidImagePath );
188     button3 = CreateCheckBoxButton( voidImagePath, voidImagePath, imagePath, voidImagePath );
189     button4 = CreateCheckBoxButton( voidImagePath, voidImagePath, voidImagePath, imagePath );
190     button5 = CreateCheckBoxButton( imagePath, imagePath, imagePath, imagePath );
191   }
192   catch( ... )
193   {
194     tet_result( TET_FAIL );
195   }
196
197   DALI_TEST_CHECK( button0 );
198   DALI_TEST_CHECK( button1 );
199   DALI_TEST_CHECK( button2 );
200   DALI_TEST_CHECK( button3 );
201   DALI_TEST_CHECK( button4 );
202   DALI_TEST_CHECK( button5 );
203
204   try
205   {
206     button0 = CreateCheckBoxButton( voidImage, voidImage, voidImage, voidImage );
207     button1 = CreateCheckBoxButton( image, voidImage, voidImage, voidImage );
208     button2 = CreateCheckBoxButton( voidImage, image, voidImage, voidImage );
209     button3 = CreateCheckBoxButton( voidImage, voidImage, image, voidImage );
210     button4 = CreateCheckBoxButton( voidImage, voidImage, voidImage, image );
211     button5 = CreateCheckBoxButton( image, image, image, image );
212   }
213   catch( ... )
214   {
215     tet_result( TET_FAIL );
216   }
217
218   DALI_TEST_CHECK( button0 );
219   DALI_TEST_CHECK( button1 );
220   DALI_TEST_CHECK( button2 );
221   DALI_TEST_CHECK( button3 );
222   DALI_TEST_CHECK( button4 );
223   DALI_TEST_CHECK( button5 );
224
225   try
226   {
227     button0 = CreateCheckBoxButton( voidImagePath, voidImagePath );
228     button1 = CreateCheckBoxButton( voidImagePath, imagePath );
229     button2 = CreateCheckBoxButton( imagePath, voidImagePath );
230     button3 = CreateCheckBoxButton( imagePath, imagePath );
231   }
232   catch( ... )
233   {
234     tet_result( TET_FAIL );
235   }
236
237   DALI_TEST_CHECK( button0 );
238   DALI_TEST_CHECK( button1 );
239   DALI_TEST_CHECK( button2 );
240   DALI_TEST_CHECK( button3 );
241
242   try
243   {
244     button0 = CreateCheckBoxButton( voidImage, voidImage );
245     button2 = CreateCheckBoxButton( voidImage, image );
246     button3 = CreateCheckBoxButton( voidImage, image );
247     button4 = CreateCheckBoxButton( image, image );
248   }
249   catch( ... )
250   {
251     tet_result( TET_FAIL );
252   }
253
254   DALI_TEST_CHECK( button0 );
255   DALI_TEST_CHECK( button1 );
256   DALI_TEST_CHECK( button2 );
257   DALI_TEST_CHECK( button3 );
258 }