2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
24 #include <dali-toolkit/public-api/transition/transition-set.h>
25 #include <dali-toolkit/public-api/transition/transition-base.h>
26 #include <dali-toolkit/public-api/transition/transition.h>
29 using namespace Dali::Toolkit;
33 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
37 // Functor to test whether a Finish signal is emitted
38 struct TransitionFinishCheck
40 TransitionFinishCheck(bool& signalReceived)
41 : mSignalReceived(signalReceived)
45 void operator()(TransitionSet& transitionSet)
47 mSignalReceived = true;
52 mSignalReceived = false;
55 void CheckSignalReceived()
59 tet_printf("Expected Finish signal was not received\n");
68 void CheckSignalNotReceived()
72 tet_printf("Unexpected Finish signal was received\n");
81 bool& mSignalReceived; // owned by individual tests
84 int UtcDaliTransitionSetGetProperty01(void)
86 ToolkitTestApplication application;
87 tet_infoline(" UtcDaliTransitionSetGetProperty01");
89 Control control1 = Control::New();
90 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
91 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
92 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
93 Property::Map controlProperty1;
94 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
95 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
96 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 50.f);
97 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 50.f);
98 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
99 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, 1.f);
100 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
102 Control control2 = Control::New();
103 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
104 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
105 control2.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
106 Property::Map controlProperty2;
107 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
108 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
109 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 30.f);
110 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 30.f);
111 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
112 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, -1.f);
113 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
115 application.GetScene().Add(control1);
116 application.GetScene().Add(control2);
118 application.SendNotification();
119 application.Render(20);
121 Transition transition = Transition::New(control1, control2, true, TimePeriod(-0.1f, -0.1f));
122 TimePeriod timePeriod = transition.GetTimePeriod();
123 DALI_TEST_EQUALS(0.0f, timePeriod.durationSeconds, TEST_LOCATION);
124 DALI_TEST_EQUALS(0.0f, timePeriod.delaySeconds, TEST_LOCATION);
126 transition.SetTimePeriod(TimePeriod(0.5f, 1.0f));
127 timePeriod = transition.GetTimePeriod();
128 DALI_TEST_EQUALS(1.0f, timePeriod.durationSeconds, TEST_LOCATION);
129 DALI_TEST_EQUALS(0.5f, timePeriod.delaySeconds, TEST_LOCATION);
131 DALI_TEST_EQUALS(Dali::AlphaFunction::DEFAULT, transition.GetAlphaFunction().GetBuiltinFunction(), TEST_LOCATION);
132 transition.SetAlphaFunction(Dali::AlphaFunction::EASE_IN_OUT);
133 DALI_TEST_EQUALS(Dali::AlphaFunction::EASE_IN_OUT, transition.GetAlphaFunction().GetBuiltinFunction(), TEST_LOCATION);
135 TransitionSet transitionSet = TransitionSet::New();
136 transitionSet.AddTransition(transition);
138 DALI_TEST_EQUALS(1, transitionSet.GetTransitionCount(), TEST_LOCATION);
139 DALI_TEST_EQUALS(transition, transitionSet.GetTransitionAt(0), TEST_LOCATION);
144 int UtcDaliTransitionSetGetProperty02(void)
146 ToolkitTestApplication application;
147 tet_infoline(" UtcDaliTransitionSetGetProperty02");
149 Control control1 = Control::New();
150 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
151 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
152 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
153 Property::Map controlProperty1;
154 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
155 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
156 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, Vector4(50.0f, 30.0f, 40.0f, 20.0f));
157 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 50.f);
158 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
159 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, -1.f);
160 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
162 Control control2 = Control::New();
163 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
164 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
165 control2.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
166 Property::Map controlProperty2;
167 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
168 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
169 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, Vector4(32.f, 54.0f, 24.0f, 42.0f));
170 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 30.f);
171 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
172 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, -1.f);
173 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
175 application.GetScene().Add(control1);
176 application.GetScene().Add(control2);
178 application.SendNotification();
179 application.Render(20);
181 Transition transition = Transition::New(control1, control2, true, TimePeriod(-0.1f));
182 TimePeriod timePeriod = transition.GetTimePeriod();
183 DALI_TEST_EQUALS(0.0f, timePeriod.durationSeconds, TEST_LOCATION);
184 DALI_TEST_EQUALS(0.0f, timePeriod.delaySeconds, TEST_LOCATION);
186 transition.SetTimePeriod(TimePeriod(0.5f, 1.0f));
187 timePeriod = transition.GetTimePeriod();
188 DALI_TEST_EQUALS(1.0f, timePeriod.durationSeconds, TEST_LOCATION);
189 DALI_TEST_EQUALS(0.5f, timePeriod.delaySeconds, TEST_LOCATION);
191 DALI_TEST_EQUALS(Dali::AlphaFunction::DEFAULT, transition.GetAlphaFunction().GetBuiltinFunction(), TEST_LOCATION);
192 transition.SetAlphaFunction(Dali::AlphaFunction::EASE_IN_OUT);
193 DALI_TEST_EQUALS(Dali::AlphaFunction::EASE_IN_OUT, transition.GetAlphaFunction().GetBuiltinFunction(), TEST_LOCATION);
195 TransitionSet transitionSet = TransitionSet::New();
196 transitionSet.AddTransition(transition);
198 DALI_TEST_EQUALS(1, transitionSet.GetTransitionCount(), TEST_LOCATION);
199 DALI_TEST_EQUALS(transition, transitionSet.GetTransitionAt(0), TEST_LOCATION);
204 int UtcDaliTransitionBetweenControlPair(void)
206 ToolkitTestApplication application;
207 tet_infoline(" UtcDaliTransitionBetweenControlPair");
209 Vector3 destinationPosition(50, 50, 0);
210 Vector3 destinationSize(120, 120, 0);
211 Vector3 destinationScale(2, 1, 0);
212 Vector4 destinationColor(1.0f, 0.5f, 1.0f, 0.8f);
213 float destinationOpacity(0.8f);
214 float destinationRadius(50.f);
215 float destinationBorderlineWidth(80.0f);
216 Vector4 destinationBorderlineColor(0.5f, 1.0f, 0.5f, 0.3f);
217 float destinationBorderlineOffset(-1.0f);
218 Vector4 destinationRadiusV4 = Vector4(destinationRadius, destinationRadius, destinationRadius, destinationRadius);
220 Control control1 = Control::New();
221 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
222 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
223 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
224 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
225 control1.SetProperty(Actor::Property::SCALE, Vector3(1, 2, 0));
226 control1.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 1.0f, 1.0f, 0.5f));
227 control1.SetProperty(Actor::Property::OPACITY, 0.5f);
228 Property::Map controlProperty1;
229 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
230 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
231 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 30.f);
232 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 60.f);
233 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
234 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, 1.f);
235 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
237 Control control2 = Control::New();
238 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
239 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
240 control2.SetProperty(Actor::Property::POSITION, destinationPosition);
241 control2.SetProperty(Actor::Property::SIZE, destinationSize);
242 control2.SetProperty(Actor::Property::SCALE, destinationScale);
243 control2.SetProperty(Actor::Property::COLOR, destinationColor);
244 control2.SetProperty(Actor::Property::OPACITY, destinationOpacity);
245 Property::Map controlProperty2;
246 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
247 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
248 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, destinationRadius);
249 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, destinationBorderlineWidth);
250 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, destinationBorderlineColor);
251 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, destinationBorderlineOffset);
252 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
254 DALI_TEST_EQUALS(destinationPosition, control2.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
255 Property::Map backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
256 Vector4 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
257 DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
258 float borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
259 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
260 Vector4 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
261 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
262 float borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
263 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
265 application.GetScene().Add(control1);
266 application.GetScene().Add(control2);
268 application.SendNotification();
269 application.Render(20);
271 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
272 TransitionSet transitionSet = TransitionSet::New();
273 transitionSet.AddTransition(transition);
274 transitionSet.Play();
276 bool signalReceived(false);
277 TransitionFinishCheck finishCheck(signalReceived);
278 transitionSet.FinishedSignal().Connect(&application, finishCheck);
280 application.SendNotification();
281 application.Render(50);
283 // We didn't expect the animation to finish yet
284 application.SendNotification();
285 finishCheck.CheckSignalNotReceived();
287 DALI_TEST_NOT_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
288 DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
289 Dali::Renderer renderer = control2.GetRendererAt(0);
290 Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
291 cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
292 DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
293 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
294 borderlineWidth = renderer.GetCurrentProperty<float>(index);
295 DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
296 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
297 borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
298 DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
299 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
300 borderlineOffset = renderer.GetCurrentProperty<float>(index);
301 DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
303 application.SendNotification();
304 application.Render(700);
306 // We did expect the animation to finish
307 application.SendNotification();
308 finishCheck.CheckSignalReceived();
310 application.SendNotification();
311 application.Render(20);
313 DALI_TEST_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
314 DALI_TEST_EQUALS(destinationSize, control2.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
315 DALI_TEST_EQUALS(destinationScale, control2.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
316 DALI_TEST_EQUALS(destinationColor, control2.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
317 DALI_TEST_EQUALS(destinationOpacity, control2.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
318 DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
319 renderer = control2.GetRendererAt(0);
320 index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
321 cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
322 DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
323 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
324 borderlineWidth = renderer.GetCurrentProperty<float>(index);
325 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
326 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
327 borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
328 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
329 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
330 borderlineOffset = renderer.GetCurrentProperty<float>(index);
331 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
336 int UtcDaliTransitionBetweenControlPair2(void)
338 ToolkitTestApplication application;
339 tet_infoline(" UtcDaliTransitionBetweenControlPair2 - source target will be transitioned.");
341 Vector3 sourcePosition(100, 200, 0);
342 Vector3 sourceSize(150, 150, 0);
343 Vector3 sourceScale(1, 2, 0);
344 Vector4 sourceColor(1.0f, 1.0f, 1.0f, 0.5f);
345 float sourceOpacity(0.5f);
346 float sourceRadius(30.f);
347 float sourceBorderlineWidth(60.0f);
348 Vector4 sourceBorderlineColor(1.0f, 0.0f, 0.0f, 1.0f);
349 float sourceBorderlineOffset(1.f);
350 Vector4 sourceRadiusV4 = Vector4(sourceRadius, sourceRadius, sourceRadius, sourceRadius);
352 Vector3 destinationPosition(50, 50, 0);
353 Vector3 destinationSize(120, 120, 0);
354 Vector3 destinationScale(2, 1, 0);
355 Vector4 destinationColor(1.0f, 0.5f, 1.0f, 0.8f);
356 float destinationOpacity(0.8f);
357 float destinationRadius(50.f);
358 float destinationBorderlineWidth(80.0f);
359 Vector4 destinationBorderlineColor(0.5f, 1.0f, 0.5f, 0.3f);
360 float destinationBorderlineOffset(-1.0f);
361 Vector4 destinationRadiusV4 = Vector4(destinationRadius, destinationRadius, destinationRadius, destinationRadius);
363 Control control1 = Control::New();
364 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
365 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
366 control1.SetProperty(Actor::Property::POSITION, sourcePosition);
367 control1.SetProperty(Actor::Property::SIZE, sourceSize);
368 control1.SetProperty(Actor::Property::SCALE, sourceScale);
369 control1.SetProperty(Actor::Property::COLOR, sourceColor);
370 control1.SetProperty(Actor::Property::OPACITY, sourceOpacity);
371 Property::Map controlProperty1;
372 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
373 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
374 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, sourceRadius);
375 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, sourceBorderlineWidth);
376 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, sourceBorderlineColor);
377 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, sourceBorderlineOffset);
378 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
380 Control control2 = Control::New();
381 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
382 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER);
383 control2.SetProperty(Actor::Property::POSITION, destinationPosition);
384 control2.SetProperty(Actor::Property::SIZE, destinationSize);
385 control2.SetProperty(Actor::Property::SCALE, destinationScale);
386 control2.SetProperty(Actor::Property::COLOR, destinationColor);
387 control2.SetProperty(Actor::Property::OPACITY, destinationOpacity);
388 Property::Map controlProperty2;
389 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
390 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
391 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, destinationRadius);
392 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, destinationBorderlineWidth);
393 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, destinationBorderlineColor);
394 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, destinationBorderlineOffset);
395 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
397 DALI_TEST_EQUALS(destinationPosition, control2.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
398 Property::Map backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
399 Vector4 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
400 DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
401 float borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
402 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
403 Vector4 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
404 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
405 float borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
406 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
408 application.GetScene().Add(control1);
409 application.GetScene().Add(control2);
411 application.SendNotification();
412 application.Render(20);
414 Transition transition = Transition::New(control1, control2, false, TimePeriod(0.5f));
415 TransitionSet transitionSet = TransitionSet::New();
416 transitionSet.AddTransition(transition);
417 transitionSet.Play();
419 bool signalReceived(false);
420 TransitionFinishCheck finishCheck(signalReceived);
421 transitionSet.FinishedSignal().Connect(&application, finishCheck);
423 application.SendNotification();
424 application.Render(50);
426 // We didn't expect the animation to finish yet
427 application.SendNotification();
428 finishCheck.CheckSignalNotReceived();
430 DALI_TEST_NOT_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
431 DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
433 Dali::Renderer renderer = control1.GetRendererAt(0);
434 Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
435 cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
436 DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
438 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
439 borderlineWidth = renderer.GetCurrentProperty<float>(index);
440 DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
442 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
443 borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
444 DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
446 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
447 borderlineOffset = renderer.GetCurrentProperty<float>(index);
448 DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
450 application.SendNotification();
451 application.Render(700);
453 // We did expect the animation to finish
454 application.SendNotification();
455 finishCheck.CheckSignalReceived();
457 // After the transition is finished,
458 // every current and renderer propeties of control1 are equal to destination properties.
459 DALI_TEST_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
460 DALI_TEST_EQUALS(destinationSize, control1.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
461 DALI_TEST_EQUALS(destinationScale, control1.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
462 DALI_TEST_EQUALS(destinationColor, control1.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
463 DALI_TEST_EQUALS(destinationOpacity, control1.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
465 DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
466 renderer = control1.GetRendererAt(0);
467 index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
468 cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
469 DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
471 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
472 borderlineWidth = renderer.GetCurrentProperty<float>(index);
473 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
475 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
476 borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
477 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
479 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
480 borderlineOffset = renderer.GetCurrentProperty<float>(index);
481 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
483 // every actor properties of control1 are returned to the source properties.
484 DALI_TEST_EQUALS(sourcePosition, control1.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
485 DALI_TEST_EQUALS(sourceSize, control1.GetProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
486 DALI_TEST_EQUALS(sourceScale, control1.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
487 DALI_TEST_EQUALS(sourceColor, control1.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
488 DALI_TEST_EQUALS(sourceOpacity, control1.GetProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
490 application.SendNotification();
491 application.Render(20);
493 // after next update, renderer properties are returned to the source properties.
494 DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
495 renderer = control1.GetRendererAt(0);
496 index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
497 cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
498 DALI_TEST_EQUALS(sourceRadiusV4, cornerRadius, TEST_LOCATION);
500 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
501 borderlineWidth = renderer.GetCurrentProperty<float>(index);
502 DALI_TEST_EQUALS(sourceBorderlineWidth, borderlineWidth, TEST_LOCATION);
504 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
505 borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
506 DALI_TEST_EQUALS(sourceBorderlineColor, borderlineColor, TEST_LOCATION);
508 index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
509 borderlineOffset = renderer.GetCurrentProperty<float>(index);
510 DALI_TEST_EQUALS(sourceBorderlineOffset, borderlineOffset, TEST_LOCATION);
515 int UtcDaliTransitionBetweenControlPairWithoutEmptySourceBackground(void)
517 ToolkitTestApplication application;
518 tet_infoline(" UtcDaliTransitionBetweenControlPair");
520 Vector4 destinationRadius(50.f, 30.f, 40.f, 0.f);
521 float destinationBorderlineWidth(40.f);
522 Vector4 destinationBorderlineColor(1.0f, 0.5f, 0.2f, 0.8f);
523 float destinationBorderlineOffset(1.f);
525 Control control1 = Control::New();
526 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
527 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
528 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
530 Control control2 = Control::New();
531 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
532 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
533 control2.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
534 Property::Map controlProperty2;
535 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
536 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
537 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, destinationRadius);
538 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, destinationBorderlineWidth);
539 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, destinationBorderlineColor);
540 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, destinationBorderlineOffset);
541 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
543 Property::Map backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
544 Vector4 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
545 DALI_TEST_EQUALS(destinationRadius, cornerRadius, TEST_LOCATION);
546 float borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
547 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
548 Vector4 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
549 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
550 float borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
551 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
553 application.GetScene().Add(control1);
554 application.GetScene().Add(control2);
556 application.SendNotification();
557 application.Render(20);
559 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
560 TransitionSet transitionSet = TransitionSet::New();
561 transitionSet.AddTransition(transition);
562 transitionSet.Play();
564 bool signalReceived(false);
565 TransitionFinishCheck finishCheck(signalReceived);
566 transitionSet.FinishedSignal().Connect(&application, finishCheck);
568 application.SendNotification();
569 application.Render(50);
571 // We didn't expect the animation to finish yet
572 application.SendNotification();
573 finishCheck.CheckSignalNotReceived();
575 backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
576 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
577 DALI_TEST_EQUALS(destinationRadius, cornerRadius, TEST_LOCATION);
578 borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
579 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
580 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
581 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
582 borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
583 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
585 application.SendNotification();
586 application.Render(700);
588 // We did expect the animation to finish
589 application.SendNotification();
590 finishCheck.CheckSignalReceived();
592 application.SendNotification();
593 application.Render(20);
595 backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
596 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
597 DALI_TEST_EQUALS(destinationRadius, cornerRadius, TEST_LOCATION);
598 borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
599 DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
600 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
601 DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
602 borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
603 DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
608 int UtcDaliTransitionBetweenImageViewPair(void)
610 ToolkitTestApplication application;
611 tet_infoline(" UtcDaliTransitionBetweenControlPair");
613 Vector3 destinationPosition(50, 50, 0);
615 ImageView control1 = ImageView::New();
616 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
617 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
618 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
619 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
620 Property::Map controlProperty1;
621 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
622 controlProperty1.Insert(Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
623 controlProperty1.Insert(Toolkit::Visual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.5f, 0.5f));
624 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 50.f);
625 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 50.f);
626 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
627 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, 1.f);
628 control1.SetProperty(Toolkit::ImageView::Property::IMAGE, controlProperty1);
630 ImageView control2 = ImageView::New();
631 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
632 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
633 control2.SetProperty(Actor::Property::POSITION, destinationPosition);
634 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
635 Property::Map controlProperty2;
636 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
637 controlProperty2.Insert(Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
638 controlProperty2.Insert(Toolkit::Visual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
639 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 30.f);
640 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 30.f);
641 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(0.0f, 1.0f, 1.0f, 0.5f));
642 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, -1.f);
643 control2.SetProperty(Toolkit::ImageView::Property::IMAGE, controlProperty2);
645 DALI_TEST_EQUALS(destinationPosition, control2.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
647 application.GetScene().Add(control1);
648 application.GetScene().Add(control2);
650 application.SendNotification();
651 application.Render(20);
653 Vector3 startWorldPosition = control1.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
654 Vector3 finishWorldPosition = control2.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
656 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
657 TransitionSet transitionSet = TransitionSet::New();
658 transitionSet.AddTransition(transition);
659 transitionSet.Play();
661 bool signalReceived(false);
662 TransitionFinishCheck finishCheck(signalReceived);
663 transitionSet.FinishedSignal().Connect(&application, finishCheck);
665 application.SendNotification();
666 application.Render(400);
668 // We didn't expect the animation to finish yet
669 application.SendNotification();
670 finishCheck.CheckSignalNotReceived();
672 // control2 moved about 80%
673 Vector3 currentPosition = control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
674 Vector3 expectedPosition_0_7 = startWorldPosition + (finishWorldPosition - startWorldPosition) * 0.7;
675 Vector3 expectedPosition_0_9 = startWorldPosition + (finishWorldPosition - startWorldPosition) * 0.9;
676 DALI_TEST_CHECK(currentPosition.x <= expectedPosition_0_7.x && currentPosition.x >= expectedPosition_0_9.x);
677 DALI_TEST_CHECK(currentPosition.y <= expectedPosition_0_7.y && currentPosition.y >= expectedPosition_0_9.y);
679 application.SendNotification();
680 application.Render(200);
682 // We did expect the animation to finish
683 application.SendNotification();
684 finishCheck.CheckSignalReceived();
686 DALI_TEST_NOT_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
688 application.SendNotification();
689 application.Render(20);
691 DALI_TEST_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
696 int UtcDaliTransitionBetweenImageViewPairWithDelay(void)
698 ToolkitTestApplication application;
699 tet_infoline(" UtcDaliTransitionBetweenControlPair");
701 Vector3 destinationPosition(50, 50, 0);
703 ImageView control1 = ImageView::New();
704 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
705 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
706 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
707 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
708 Property::Map controlProperty1;
709 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
710 controlProperty1.Insert(Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
711 controlProperty1.Insert(Toolkit::Visual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.5f, 0.5f));
712 controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 50.f);
713 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 50.f);
714 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
715 controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, 1.f);
716 control1.SetProperty(Toolkit::ImageView::Property::IMAGE, controlProperty1);
718 ImageView control2 = ImageView::New();
719 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
720 control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_LEFT);
721 control2.SetProperty(Actor::Property::POSITION, destinationPosition);
722 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
723 Property::Map controlProperty2;
724 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
725 controlProperty2.Insert(Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
726 controlProperty2.Insert(Toolkit::Visual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
727 controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, 30.f);
728 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, 30.f);
729 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, Vector4(0.0f, 1.0f, 1.0f, 0.5f));
730 controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, -1.f);
731 control2.SetProperty(Toolkit::ImageView::Property::IMAGE, controlProperty2);
733 DALI_TEST_EQUALS(destinationPosition, control2.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
735 application.GetScene().Add(control1);
736 application.GetScene().Add(control2);
738 application.SendNotification();
739 application.Render(20);
741 Vector3 startWorldPosition = control1.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
742 Vector3 finishWorldPosition = control2.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
744 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f, 0.5f));
745 TransitionSet transitionSet = TransitionSet::New();
746 transitionSet.AddTransition(transition);
747 transitionSet.Play();
749 bool signalReceived(false);
750 TransitionFinishCheck finishCheck(signalReceived);
751 transitionSet.FinishedSignal().Connect(&application, finishCheck);
753 application.SendNotification();
754 application.Render(400);
756 // We didn't expect the animation to finish yet
757 application.SendNotification();
758 finishCheck.CheckSignalNotReceived();
760 DALI_TEST_EQUALS(startWorldPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
762 application.SendNotification();
763 application.Render(400);
765 // We didn't expect the animation to finish yet
766 application.SendNotification();
767 finishCheck.CheckSignalNotReceived();
769 // control2 moved about 60% (800ms)
770 Vector3 currentPosition = control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION);
771 Vector3 expectedPosition_0_5 = startWorldPosition + (finishWorldPosition - startWorldPosition) * 0.5;
772 Vector3 expectedPosition_0_7 = startWorldPosition + (finishWorldPosition - startWorldPosition) * 0.7;
773 DALI_TEST_CHECK(currentPosition.x <= expectedPosition_0_5.x && currentPosition.x >= expectedPosition_0_7.x);
774 DALI_TEST_CHECK(currentPosition.y <= expectedPosition_0_5.y && currentPosition.y >= expectedPosition_0_7.y);
776 application.SendNotification();
777 application.Render(400);
779 // We did expect the animation to finish
780 application.SendNotification();
781 finishCheck.CheckSignalReceived();
783 DALI_TEST_NOT_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
785 application.SendNotification();
786 application.Render(20);
788 DALI_TEST_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
793 int UtcDaliTransitionBetweenControlPairWithTree(void)
795 ToolkitTestApplication application;
796 tet_infoline(" UtcDaliTransitionBetweenControlPairWithTree");
798 Vector3 destinationPosition(50, 50, 0);
799 Vector3 destinationWorldPosition(-130, -290, 0);
801 Control control1 = Control::New();
802 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
803 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
804 Property::Map controlProperty1;
805 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
806 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
807 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
809 Control control2 = Control::New();
810 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
811 control2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
812 control2.SetProperty(Actor::Property::POSITION, destinationPosition);
813 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
814 Property::Map controlProperty2;
815 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
816 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
817 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
819 Control control3 = Control::New();
820 control3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
821 control3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
822 control3.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
823 control3.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
824 Property::Map controlProperty3;
825 controlProperty3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
826 controlProperty3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
827 control3.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty3);
829 application.GetScene().Add(control1);
830 application.GetScene().Add(control2);
831 control2.Add(control3);
833 application.SendNotification();
834 application.Render(20);
836 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
837 TransitionSet transitionSet = TransitionSet::New();
838 transitionSet.AddTransition(transition);
839 transitionSet.Play();
841 bool signalReceived(false);
842 TransitionFinishCheck finishCheck(signalReceived);
843 transitionSet.FinishedSignal().Connect(&application, finishCheck);
845 application.SendNotification();
846 application.Render(600);
848 // We didn't expect the animation to finish yet
849 application.SendNotification();
850 finishCheck.CheckSignalReceived();
852 application.SendNotification();
853 application.Render(20);
855 DALI_TEST_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
856 DALI_TEST_EQUALS(destinationWorldPosition, control2.GetProperty<Vector3>(Actor::Property::WORLD_POSITION), TEST_LOCATION);
861 int UtcDaliTransitionBetweenControlPairWithTreeWithChild(void)
863 ToolkitTestApplication application;
864 tet_infoline(" UtcDaliTransitionBetweenControlPairWithTreeWithChild");
866 Vector3 destinationWorldPosition(-80, -240, 0);
868 Control control1 = Control::New();
869 control1.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
870 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
871 Property::Map controlProperty1;
872 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
873 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
874 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
876 Control control2 = Control::New();
877 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
878 control2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
879 control2.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
880 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
881 Property::Map controlProperty2;
882 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
883 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
884 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
886 Control control3 = Control::New();
887 control3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
888 control3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
889 control3.SetProperty(Actor::Property::POSITION, Vector3(50, 50, 0));
890 control3.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
891 Property::Map controlProperty3;
892 controlProperty3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
893 controlProperty3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
894 control3.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty3);
896 application.GetScene().Add(control1);
897 application.GetScene().Add(control2);
898 control2.Add(control3);
900 application.SendNotification();
901 application.Render(20);
903 Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
904 transition.TransitionWithChild(true);
905 TransitionSet transitionSet = TransitionSet::New();
906 transitionSet.AddTransition(transition);
907 transitionSet.Play();
909 bool signalReceived(false);
910 TransitionFinishCheck finishCheck(signalReceived);
911 transitionSet.FinishedSignal().Connect(&application, finishCheck);
913 application.SendNotification();
914 application.Render(600);
916 // We didn't expect the animation to finish yet
917 application.SendNotification();
918 finishCheck.CheckSignalReceived();
920 application.SendNotification();
921 application.Render(20);
923 DALI_TEST_EQUALS(destinationWorldPosition, control3.GetProperty<Vector3>(Actor::Property::WORLD_POSITION), TEST_LOCATION);
928 int UtcDaliTransitionBetweenControlPairWithTreeWithoutPositionInheritance(void)
930 ToolkitTestApplication application;
931 tet_infoline(" UtcDaliTransitionBetweenControlPairWithTreeWithoutPositionInheritance");
933 Vector3 sourcePosition(50, 50, 0);
934 Vector3 destinationPosition(100, 100, 0);
936 Control control1 = Control::New();
937 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
938 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
939 control1.SetProperty(Actor::Property::POSITION, sourcePosition);
940 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
941 Property::Map controlProperty1;
942 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
943 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
944 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
946 Control control2 = Control::New();
947 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
948 control2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
949 control2.SetProperty(Actor::Property::POSITION, Vector3(150, 150, 0));
950 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
951 Property::Map controlProperty2;
952 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
953 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
954 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
956 Control control3 = Control::New();
957 control3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
958 control3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
959 control3.SetProperty(Actor::Property::POSITION, destinationPosition);
960 control3.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
961 Property::Map controlProperty3;
962 controlProperty3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
963 controlProperty3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
964 control3.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty3);
966 application.GetScene().Add(control1);
967 application.GetScene().Add(control2);
968 control2.Add(control3);
970 application.SendNotification();
971 application.Render(20);
973 Transition transition;
974 TransitionSet transitionSet;
975 bool signalReceived(false);
976 TransitionFinishCheck finishCheck(signalReceived);
978 // not inherit Position.
979 control3.SetProperty(Actor::Property::INHERIT_POSITION, false);
980 control3.SetProperty(Actor::Property::INHERIT_ORIENTATION, true);
981 control3.SetProperty(Actor::Property::INHERIT_SCALE, true);
983 transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
984 transitionSet = TransitionSet::New();
985 transitionSet.AddTransition(transition);
986 transitionSet.Play();
987 transitionSet.FinishedSignal().Connect(&application, finishCheck);
989 application.SendNotification();
990 application.Render(300);
992 Vector3 currentPosition = control3.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
993 DALI_TEST_CHECK(currentPosition.x <= destinationPosition.x && currentPosition.x >= sourcePosition.x);
994 DALI_TEST_CHECK(currentPosition.y <= destinationPosition.y && currentPosition.y >= sourcePosition.y);
995 DALI_TEST_CHECK(currentPosition.z <= destinationPosition.z && currentPosition.z >= sourcePosition.z);
997 application.SendNotification();
998 application.Render(300);
1000 // We didn't expect the animation to finish yet
1001 application.SendNotification();
1002 finishCheck.CheckSignalReceived();
1004 application.SendNotification();
1005 application.Render(20);
1007 DALI_TEST_EQUALS(destinationPosition, control3.GetProperty<Vector3>(Actor::Property::WORLD_POSITION), TEST_LOCATION);
1011 int UtcDaliTransitionBetweenControlPairWithTreeWithoutOrientationInheritance(void)
1013 ToolkitTestApplication application;
1014 tet_infoline(" UtcDaliTransitionBetweenControlPairWithTreeWithoutOrientationInheritance");
1016 Radian sourceAngle(1.0f);
1017 Radian destinationAngle(2.0f);
1018 Quaternion sourceOrientation(sourceAngle, Vector3::XAXIS);
1019 Quaternion destinationOrientation(destinationAngle, Vector3::XAXIS);
1021 Control control1 = Control::New();
1022 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1023 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1024 control1.SetProperty(Actor::Property::ORIENTATION, sourceOrientation);
1025 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
1026 Property::Map controlProperty1;
1027 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1028 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1029 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
1031 Control control2 = Control::New();
1032 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1033 control2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1034 control2.SetProperty(Actor::Property::ORIENTATION, Quaternion(Radian(2.0f), Vector3::XAXIS));
1035 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
1036 Property::Map controlProperty2;
1037 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1038 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1039 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
1041 Control control3 = Control::New();
1042 control3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1043 control3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1044 control3.SetProperty(Actor::Property::ORIENTATION, destinationOrientation);
1045 control3.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
1046 Property::Map controlProperty3;
1047 controlProperty3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1048 controlProperty3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1049 control3.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty3);
1051 // not inherit Orientation.
1052 control3.SetProperty(Actor::Property::INHERIT_POSITION, true);
1053 control3.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1054 control3.SetProperty(Actor::Property::INHERIT_SCALE, true);
1056 Vector3 currentAxis;
1057 Radian currentRadian;
1059 application.GetScene().Add(control1);
1060 application.GetScene().Add(control2);
1061 control2.Add(control3);
1063 application.SendNotification();
1064 application.Render(20);
1066 Quaternion currentOrientation = control3.GetProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION);
1067 DALI_TEST_EQUALS(currentOrientation, destinationOrientation, 0.0001f, TEST_LOCATION);
1069 Transition transition;
1070 TransitionSet transitionSet;
1071 bool signalReceived(false);
1072 TransitionFinishCheck finishCheck(signalReceived);
1074 transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
1075 transitionSet = TransitionSet::New();
1076 transitionSet.AddTransition(transition);
1077 transitionSet.Play();
1078 transitionSet.FinishedSignal().Connect(&application, finishCheck);
1080 application.SendNotification();
1081 application.Render(300);
1083 currentOrientation = control3.GetProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION);
1084 DALI_TEST_NOT_EQUALS(currentOrientation, destinationOrientation, 0.0001f, TEST_LOCATION);
1086 application.SendNotification();
1087 application.Render(300);
1089 // We didn't expect the animation to finish yet
1090 application.SendNotification();
1091 finishCheck.CheckSignalReceived();
1093 application.SendNotification();
1094 application.Render(20);
1096 currentOrientation = control3.GetProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION);
1097 DALI_TEST_EQUALS(currentOrientation, destinationOrientation, 0.0001f, TEST_LOCATION);
1102 int UtcDaliTransitionBetweenControlPairWithTreeWithoutScaleInheritance(void)
1104 ToolkitTestApplication application;
1105 tet_infoline(" UtcDaliTransitionBetweenControlPairWithTreeWithoutOrientationInheritance");
1107 Vector3 sourceScale(1, 1, 1);
1108 Vector3 destinationScale(2, 2, 1);
1110 Control control1 = Control::New();
1111 control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1112 control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1113 control1.SetProperty(Actor::Property::SCALE, sourceScale);
1114 control1.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
1115 Property::Map controlProperty1;
1116 controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1117 controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1118 control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
1120 Control control2 = Control::New();
1121 control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1122 control2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1123 control2.SetProperty(Actor::Property::SCALE, Vector3(3, 3, 1));
1124 control2.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
1125 Property::Map controlProperty2;
1126 controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1127 controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1128 control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
1130 Control control3 = Control::New();
1131 control3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1132 control3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1133 control3.SetProperty(Actor::Property::SCALE, destinationScale);
1134 control3.SetProperty(Actor::Property::SIZE, Vector3(120, 120, 0));
1135 Property::Map controlProperty3;
1136 controlProperty3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
1137 controlProperty3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1138 control3.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty3);
1140 // not inherit Orientation.
1141 control3.SetProperty(Actor::Property::INHERIT_POSITION, true);
1142 control3.SetProperty(Actor::Property::INHERIT_ORIENTATION, true);
1143 control3.SetProperty(Actor::Property::INHERIT_SCALE, false);
1145 application.GetScene().Add(control1);
1146 application.GetScene().Add(control2);
1147 control2.Add(control3);
1149 application.SendNotification();
1150 application.Render(20);
1152 Vector3 currentScale = control3.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
1153 DALI_TEST_EQUALS(currentScale, destinationScale, 0.0001f, TEST_LOCATION);
1155 Transition transition;
1156 TransitionSet transitionSet;
1157 bool signalReceived(false);
1158 TransitionFinishCheck finishCheck(signalReceived);
1160 transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
1161 transitionSet = TransitionSet::New();
1162 transitionSet.AddTransition(transition);
1163 transitionSet.Play();
1164 transitionSet.FinishedSignal().Connect(&application, finishCheck);
1166 application.SendNotification();
1167 application.Render(300);
1169 currentScale = control3.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
1170 DALI_TEST_CHECK(currentScale.x <= destinationScale.x && currentScale.x >= sourceScale.x);
1171 DALI_TEST_CHECK(currentScale.y <= destinationScale.y && currentScale.y >= sourceScale.y);
1172 DALI_TEST_CHECK(currentScale.z <= destinationScale.z && currentScale.z >= sourceScale.z);
1174 application.SendNotification();
1175 application.Render(300);
1177 // We didn't expect the animation to finish yet
1178 application.SendNotification();
1179 finishCheck.CheckSignalReceived();
1181 application.SendNotification();
1182 application.Render(20);
1184 currentScale = control3.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
1185 DALI_TEST_EQUALS(currentScale, destinationScale, 0.0001f, TEST_LOCATION);