Dali 3D User Interface Engine
utc-Dali-Magnifier.cpp
Go to the documentation of this file.
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 #include <stdlib.h>
20 #include <sstream>
24 
25 using namespace Dali;
26 using namespace Toolkit;
27 
29 {
31 }
32 
34 {
36 }
37 
39 {
40  ToolkitTestApplication application;
41 
42  Magnifier magnifier;
43  DALI_TEST_CHECK( !magnifier );
44 
45  magnifier = Magnifier::New();
46  DALI_TEST_CHECK( magnifier );
47 
48  Stage::GetCurrent().Add( magnifier );
49 
50  application.SendNotification();
51  application.Render();
52 
53  END_TEST;
54 }
55 
57 {
58  ToolkitTestApplication application;
59 
60  Magnifier view = Magnifier::New();
61  DALI_TEST_CHECK( view );
62 
63  Magnifier copy( view );
64  DALI_TEST_CHECK( copy == view );
65 
66  Magnifier assign;
67  DALI_TEST_CHECK( !assign );
68  assign = view;
69  DALI_TEST_CHECK( assign == view );
70 
71  // Self assignment
72  assign = assign;
73  DALI_TEST_CHECK( assign );
74  DALI_TEST_CHECK( assign == view );
75 
76  END_TEST;
77 }
78 
80 {
81  ToolkitTestApplication application;
82 
83  BaseHandle view = Magnifier::New();
85 
86  BaseHandle empty;
88 
89  BaseHandle another = Actor::New();
90  DALI_TEST_CHECK( ! Magnifier::DownCast( another ) );
91 
92  END_TEST;
93 }
94 
96 {
97  ToolkitTestApplication application;
98 
99  TypeRegistry typeRegistry = TypeRegistry::Get();
100  DALI_TEST_CHECK( typeRegistry );
101 
102  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Magnifier" );
103  DALI_TEST_CHECK( typeInfo );
104 
105  BaseHandle handle = typeInfo.CreateInstance();
106  DALI_TEST_CHECK( handle );
107 
108  Magnifier view = Magnifier::DownCast( handle );
109  DALI_TEST_CHECK( view );
110 
111  END_TEST;
112 }
113 
115 {
116  ToolkitTestApplication application;
117 
118  Stage stage = Stage::GetCurrent();
119 
120  Magnifier view = Magnifier::New();
121  stage.Add( view );
122 
123  application.SendNotification();
124  application.Render();
125 
126  RenderTaskList renderTaskList = stage.GetRenderTaskList();
127  DALI_TEST_CHECK( renderTaskList.GetTaskCount() > 1 );
128 
129  Actor actor = Actor::New();
130  stage.Add( actor );
131  DALI_TEST_CHECK( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor() != actor );
132 
133  view.SetSourceActor( actor );
134 
135  application.SendNotification();
136  application.Render();
137 
139 
140  END_TEST;
141 }
142 
144 {
145  ToolkitTestApplication application;
146 
147  Magnifier view;
148 
149  try
150  {
151  view.SetSourceActor( Actor::New() );
152  DALI_TEST_CHECK( false ); // should not get here
153  }
154  catch( ... )
155  {
156  DALI_TEST_CHECK( true );
157  }
158 
159  END_TEST;
160 }
161 
163 {
164  ToolkitTestApplication application;
165 
166  Stage stage = Stage::GetCurrent();
167 
168  Magnifier view = Magnifier::New();
169  stage.Add( view );
170 
171  application.SendNotification();
172  application.Render();
173 
175 
178 
179  application.SendNotification();
180  application.Render();
181 
183 
186 
187  application.SendNotification();
188  application.Render();
189 
191 
192  END_TEST;
193 }
194 
196 {
197  ToolkitTestApplication application;
198 
199  Stage stage = Stage::GetCurrent();
200 
201  Magnifier view = Magnifier::New();
202  stage.Add( view );
203 
204  application.SendNotification();
205  application.Render();
206 
207  float magnificationFactor( 200.0f );
208 
209  DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >() != magnificationFactor );
210 
211  view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, magnificationFactor );
212  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
213 
214  application.SendNotification();
215  application.Render();
216 
217  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
218 
221 
222  application.SendNotification();
223  application.Render();
224 
226 
227  END_TEST;
228 }
229 
231 {
232  ToolkitTestApplication application;
233 
234  Stage stage = Stage::GetCurrent();
235 
236  Magnifier view = Magnifier::New();
237  stage.Add( view );
238 
239  application.SendNotification();
240  application.Render();
241 
242  Vector3 position( 100.0f, 200.0f, 300.0f );
243 
245 
247  application.SendNotification();
248  application.Render();
250 
252  application.SendNotification();
253  application.Render();
255 
256  END_TEST;
257 }
258 
260 {
261  ToolkitTestApplication application;
262 
263  Magnifier view = Magnifier::New();
264 
265  Stage::GetCurrent().Add( view );
266 
267  application.SendNotification();
268  application.Render();
269 
270  Vector3 size( 200.0f, 300.0f, 0.0f );
271  view.SetSize( size );
272 
273  application.SendNotification();
274  application.Render();
275 
277 
278  END_TEST;
279 }
Dali Docs Home
Read more about Dali