2 * Copyright (c) 2017 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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/animation/path-constrainer.h>
23 #include <dali-test-suite-utils.h>
26 using namespace Dali::Internal;
31 static void SetupPath( Dali::Path& path)
33 path.AddPoint(Vector3( 30.0, 80.0, 0.0));
34 path.AddPoint(Vector3( 70.0, 120.0, 0.0));
35 path.AddPoint(Vector3(100.0, 100.0, 0.0));
37 //Control points for first segment
38 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
39 path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
41 //Control points for second segment
42 path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) );
43 path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) );
46 static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer)
48 PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
50 Dali::Property::Array points;
52 points[0] = Vector3( 30.0, 80.0, 0.0);
53 points[1] = Vector3( 70.0, 120.0, 0.0);
54 points[2] = Vector3(100.0, 100.0, 0.0);
55 PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
58 points[0] = Vector3( 39.0, 90.0, 0.0);
59 points[1] = Vector3( 56.0, 119.0, 0.0);
60 points[2] = Vector3( 78.0, 120.0, 0.0);
61 points[3] = Vector3( 93.0, 104.0, 0.0);
62 PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
65 static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
67 Dali::Property::Array points;
72 linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
75 static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
77 Dali::Property::Array points;
82 linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
87 linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
90 } // anonymous namespace
92 //PathConstrainer test cases
93 int UtcPathConstrainerApply(void)
95 TestApplication application;
97 Dali::Actor actor = Dali::Actor::New();
99 // Register a float property
100 Property::Index index = actor.RegisterProperty( "t", 0.0f );
102 Dali::Stage::GetCurrent().Add(actor);
105 Dali::Path path = Dali::Path::New();
108 //Create a PathConstrainer
109 Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
110 SetupPathConstrainer( pathConstrainer );
112 //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
113 Vector2 range( 0.0f, 1.0f );
114 pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
116 //Create an animation to animate the custom property
117 float durationSeconds(1.0f);
118 Dali::Animation animation = Dali::Animation::New(durationSeconds);
119 animation.AnimateTo(Dali::Property(actor,index),1.0f);
122 application.SendNotification();
123 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
125 Vector3 position, tangent;
126 path.Sample(0.2f, position, tangent );
127 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
129 application.SendNotification();
130 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
131 path.Sample(0.4f, position, tangent );
132 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
134 application.SendNotification();
135 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
136 path.Sample(0.6f, position, tangent );
137 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
139 application.SendNotification();
140 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
141 path.Sample(0.8f, position, tangent );
142 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
144 application.SendNotification();
145 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
146 path.Sample(1.0f, position, tangent );
147 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
149 application.SendNotification();
150 application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* beyond the animation duration*/);
151 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
156 int UtcPathConstrainerApplyRange(void)
158 TestApplication application;
160 Dali::Actor actor = Dali::Actor::New();
162 // Register a float property
163 Property::Index index = actor.RegisterProperty( "t", 0.0f );
164 Dali::Stage::GetCurrent().Add(actor);
167 Dali::Path path = Dali::Path::New();
170 //Create a PathConstrainer
171 Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
172 SetupPathConstrainer( pathConstrainer );
174 //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
175 Vector2 range( 100.0f, 300.0f );
176 pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
179 //Create an animation to animate the custom property
180 float durationSeconds(1.0f);
181 Dali::Animation animation = Dali::Animation::New(durationSeconds);
182 animation.AnimateTo(Dali::Property(actor,index),400.0f);
185 application.SendNotification();
186 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
189 Vector3 position, tangent;
191 actor.GetCurrentProperty( index ).Get(tValue);
192 float currentCursor = ( tValue - range.x ) / (range.y-range.x);
193 path.Sample(currentCursor, position, tangent );
194 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
196 application.SendNotification();
197 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
198 actor.GetCurrentProperty( index ).Get(tValue);
199 currentCursor = ( tValue - range.x ) / (range.y-range.x);
200 path.Sample(currentCursor, position, tangent );
201 path.Sample(0.5, position, tangent );
202 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
204 application.SendNotification();
205 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
206 actor.GetCurrentProperty( index ).Get( tValue );
207 currentCursor = ( tValue - range.x ) / (range.y-range.x);
208 path.Sample(currentCursor, position, tangent );
209 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
211 application.SendNotification();
212 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
213 actor.GetCurrentProperty( index ).Get( tValue );
214 currentCursor = ( tValue - range.x ) / (range.y-range.x);
215 path.Sample(currentCursor, position, tangent );
216 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
218 application.SendNotification();
219 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
220 actor.GetCurrentProperty( index ).Get( tValue );
221 currentCursor = ( tValue - range.x ) / (range.y-range.x);
222 path.Sample(currentCursor, position, tangent );
223 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
225 // Ensure GetProperty also returns the final result
226 actor.GetProperty( index ).Get( tValue );
227 currentCursor = ( tValue - range.x ) / (range.y-range.x);
228 path.Sample(currentCursor, position, tangent );
229 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
234 int UtcPathConstrainerDestroy(void)
236 TestApplication application;
238 Dali::Actor actor = Dali::Actor::New();
240 // Register a float property
241 Property::Index index = actor.RegisterProperty( "t", 0.0f );
242 Dali::Stage::GetCurrent().Add(actor);
246 Dali::Path path = Dali::Path::New();
249 //Create a PathConstrainer
250 Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
251 SetupPathConstrainer( pathConstrainer );
253 //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
254 Vector2 range( 0.0f, 1.0f );
255 pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
257 //Test that the constraint is correctly applied
258 actor.SetProperty(index,0.5f);
259 application.SendNotification();
260 application.Render(static_cast<unsigned int>(1.0f));
262 Vector3 position, tangent;
263 path.Sample(0.5f, position, tangent );
264 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
268 //PathConstrainer has been destroyed. Constraint in the actor should have been removed
269 actor.SetProperty(index,0.75f);
270 application.SendNotification();
271 application.Render(static_cast<unsigned int>(1.0f));
273 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
278 int UtcPathConstrainerRemove(void)
280 TestApplication application;
282 Dali::Actor actor = Dali::Actor::New();
284 // Register a float property
285 Property::Index index = actor.RegisterProperty( "t", 0.0f );
286 Dali::Stage::GetCurrent().Add(actor);
289 Dali::Path path = Dali::Path::New();
292 //Create a PathConstrainer
293 Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
294 SetupPathConstrainer( pathConstrainer );
296 //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
297 Vector2 range( 0.0f, 1.0f );
298 pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
300 //Test that the constraint is correctly applied
301 actor.SetProperty(index,0.5f);
302 application.SendNotification();
303 application.Render(static_cast<unsigned int>(1.0f));
305 Vector3 position, tangent;
306 path.Sample(0.5f, position, tangent );
307 DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
310 pathConstrainer.Remove( actor );
311 actor.SetProperty(index,0.75f);
312 application.SendNotification();
313 application.Render(static_cast<unsigned int>(1.0f));
315 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
320 int UtcPathConstrainerProperties(void)
322 TestApplication application;
323 Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
325 pathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3( 1.0f,0.0f,0.0f ) );
326 DALI_TEST_EQUALS( pathConstrainer.GetProperty< Vector3 >( Dali::PathConstrainer::Property::FORWARD ), Vector3( 1.0f, 0.0f, 0.0f ), TEST_LOCATION );
327 DALI_TEST_EQUALS( pathConstrainer.GetCurrentProperty< Vector3 >( Dali::PathConstrainer::Property::FORWARD ), Vector3( 1.0f, 0.0f, 0.0f ), TEST_LOCATION );
329 Dali::Property::Array points;
331 points[0] = Vector3( 30.0, 80.0, 0.0);
332 points[1] = Vector3( 70.0, 120.0, 0.0);
333 points[2] = Vector3(100.0, 100.0, 0.0);
334 pathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
337 Property::Value value = pathConstrainer.GetProperty( Dali::PathConstrainer::Property::POINTS );
338 Property::Array* array = value.GetArray();
339 DALI_TEST_CHECK( array );
341 const unsigned int noOfPoints = points.Size();
342 for( unsigned int i = 0; i < noOfPoints; ++i )
344 DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION );
349 Property::Value value = pathConstrainer.GetCurrentProperty( Dali::PathConstrainer::Property::POINTS );
350 Property::Array* array = value.GetArray();
351 DALI_TEST_CHECK( array );
353 const unsigned int noOfPoints = points.Size();
354 for( unsigned int i = 0; i < noOfPoints; ++i )
356 DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION );
361 points[0] = Vector3( 39.0, 90.0, 0.0);
362 points[1] = Vector3( 56.0, 119.0, 0.0);
363 points[2] = Vector3( 78.0, 120.0, 0.0);
364 points[3] = Vector3( 93.0, 104.0, 0.0);
365 pathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
368 Property::Value value = pathConstrainer.GetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS );
369 Property::Array* array = value.GetArray();
370 DALI_TEST_CHECK( array );
372 const unsigned int noOfPoints = points.Size();
373 for( unsigned int i = 0; i < noOfPoints; ++i )
375 DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION );
380 Property::Value value = pathConstrainer.GetCurrentProperty( Dali::PathConstrainer::Property::CONTROL_POINTS );
381 Property::Array* array = value.GetArray();
382 DALI_TEST_CHECK( array );
384 const unsigned int noOfPoints = points.Size();
385 for( unsigned int i = 0; i < noOfPoints; ++i )
387 DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION );
394 //LinearConstrainer test cases
395 int UtcLinearConstrainerDownCast(void)
397 TestApplication application;
398 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
400 BaseHandle handle( linearConstrainer );
401 Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle );
402 DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
405 Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 );
406 DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION );
411 int UtcLinearConstrainerCopyConstructor(void)
413 TestApplication application;
414 Dali::LinearConstrainer linearConstrainer;
415 DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION );
417 linearConstrainer = Dali::LinearConstrainer::New();
418 DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION );
420 // call the copy constructor
421 Dali::LinearConstrainer linearConstrainer2( linearConstrainer );
422 DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
427 int UtcLinearConstrainerApply(void)
429 TestApplication application;
431 Dali::Actor actor = Dali::Actor::New();
433 // Register a float property
434 Property::Index index = actor.RegisterProperty( "t", 0.0f );
436 Dali::Stage::GetCurrent().Add(actor);
439 //Create a LinearConstrainer without specifying progress for values
440 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
441 SetupLinearConstrainerUniformProgress( linearConstrainer );
443 //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
444 Vector2 range( 0.0f, 1.0f );
445 linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
447 //Create an animation to animate the custom property
448 float durationSeconds(1.0f);
449 Dali::Animation animation = Dali::Animation::New(durationSeconds);
450 animation.AnimateTo(Dali::Property(actor,index),1.0f);
453 application.SendNotification();
454 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
456 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
458 application.SendNotification();
459 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
460 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
462 application.SendNotification();
463 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
464 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
466 application.SendNotification();
467 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
468 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
470 application.SendNotification();
471 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
472 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
474 //Setup a LinearConstrainer specifying the progress for each value
475 linearConstrainer.Remove(actor);
476 SetupLinearConstrainerNonUniformProgress( linearConstrainer );
477 linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
479 actor.SetProperty(index,0.0f);
481 application.SendNotification();
482 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
484 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
486 application.SendNotification();
487 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
488 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
490 application.SendNotification();
491 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
492 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
494 application.SendNotification();
495 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
496 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
498 application.SendNotification();
499 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
500 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
505 int UtcLinearConstrainerApplyRange(void)
507 TestApplication application;
509 Dali::Actor actor = Dali::Actor::New();
511 // Register a float property
512 Property::Index index = actor.RegisterProperty( "t", 100.0f );
513 Dali::Stage::GetCurrent().Add(actor);
515 //Create a LinearConstrainer
516 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
517 SetupLinearConstrainerUniformProgress( linearConstrainer );
519 //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
520 Vector2 range( 100.0f, 300.0f );
521 linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
524 //Create an animation to animate the custom property
525 float durationSeconds(1.0f);
526 Dali::Animation animation = Dali::Animation::New(durationSeconds);
527 animation.AnimateTo(Dali::Property(actor,index),300.0f);
530 application.SendNotification();
531 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
533 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
535 application.SendNotification();
536 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
537 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
539 application.SendNotification();
540 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
541 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
543 application.SendNotification();
544 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
545 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
547 application.SendNotification();
548 application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
549 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
554 int UtcLinearConstrainerDestroy(void)
556 TestApplication application;
558 Dali::Actor actor = Dali::Actor::New();
560 // Register a float property
561 Property::Index index = actor.RegisterProperty( "t", 0.0f );
562 Dali::Stage::GetCurrent().Add(actor);
565 //Create a LinearConstrainer
566 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
567 SetupLinearConstrainerUniformProgress( linearConstrainer );
569 //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
570 Vector2 range( 0.0f, 1.0f );
571 linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
573 //Test that the constraint is correctly applied
574 actor.SetProperty(index,0.5f);
575 application.SendNotification();
576 application.Render(static_cast<unsigned int>(1.0f));
578 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
582 //LinearConstrainer has been destroyed. Constraint in the actor should have been removed
583 actor.SetProperty(index,0.75f);
584 application.SendNotification();
585 application.Render(static_cast<unsigned int>(1.0f));
587 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
592 int UtcLinearConstrainerRemove(void)
594 TestApplication application;
596 Dali::Actor actor = Dali::Actor::New();
598 // Register a float property
599 Property::Index index = actor.RegisterProperty( "t", 0.0f );
600 Dali::Stage::GetCurrent().Add(actor);
602 //Create a LinearConstrainer
603 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
604 SetupLinearConstrainerUniformProgress( linearConstrainer );
606 //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
607 Vector2 range( 0.0f, 1.0f );
608 linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
610 //Test that the constraint is correctly applied
611 actor.SetProperty(index,0.5f);
612 application.SendNotification();
613 application.Render(static_cast<unsigned int>(1.0f));
615 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
618 linearConstrainer.Remove( actor );
619 actor.SetProperty(index,0.75f);
620 application.SendNotification();
621 application.Render(static_cast<unsigned int>(1.0f));
623 DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
628 int UtcLinearConstrainerProperties(void)
630 TestApplication application;
632 Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
634 Dali::Property::Array points;
639 linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
642 Property::Value value = linearConstrainer.GetProperty( Dali::LinearConstrainer::Property::VALUE );
643 Property::Array* array = value.GetArray();
644 DALI_TEST_CHECK( array );
646 const unsigned int noOfPoints = points.Size();
647 for( unsigned int i = 0; i < noOfPoints; ++i )
649 DALI_TEST_EQUALS( ( *array )[i].Get< float >(), points[i].Get< float >(), TEST_LOCATION );
654 Property::Value value = linearConstrainer.GetCurrentProperty( Dali::LinearConstrainer::Property::VALUE );
655 Property::Array* array = value.GetArray();
656 DALI_TEST_CHECK( array );
658 const unsigned int noOfPoints = points.Size();
659 for( unsigned int i = 0; i < noOfPoints; ++i )
661 DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION );
668 linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
671 Property::Value value = linearConstrainer.GetProperty( Dali::LinearConstrainer::Property::PROGRESS );
672 Property::Array* array = value.GetArray();
673 DALI_TEST_CHECK( array );
675 const unsigned int noOfPoints = points.Size();
676 for( unsigned int i = 0; i < noOfPoints; ++i )
678 DALI_TEST_EQUALS( ( *array )[i].Get< float >(), points[i].Get< float >(), TEST_LOCATION );
683 Property::Value value = linearConstrainer.GetCurrentProperty( Dali::LinearConstrainer::Property::PROGRESS );
684 Property::Array* array = value.GetArray();
685 DALI_TEST_CHECK( array );
687 const unsigned int noOfPoints = points.Size();
688 for( unsigned int i = 0; i < noOfPoints; ++i )
690 DALI_TEST_EQUALS( ( *array )[i].Get< float >(), points[i].Get< float >(), TEST_LOCATION );
697 int UtcDaliLinearConstrainerDetectorRegisterProperty(void)
699 TestApplication application;
701 Dali::LinearConstrainer constrainer = Dali::LinearConstrainer::New();
703 Property::Index index = constrainer.RegisterProperty( "sceneProperty", 0 );
704 DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
705 DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
707 constrainer.SetProperty( index, -123 );
708 DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
710 using Dali::Animation;
711 Animation animation = Animation::New( 1.0f );
712 animation.AnimateTo( Property( constrainer, index ), 99 );
714 DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
715 // Start the animation
718 application.SendNotification();
719 application.Render( 1000 /* 100% progress */);
720 DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), 99, TEST_LOCATION );
725 int UtcDaliPathConstrainerDetectorRegisterProperty(void)
727 TestApplication application;
729 Dali::PathConstrainer constrainer = Dali::PathConstrainer::New();
731 Property::Index index = constrainer.RegisterProperty( "pathProperty", Vector2() );
732 DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
733 DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(), TEST_LOCATION );
735 constrainer.SetProperty( index, Vector2(1,2) );
736 DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(1,2), TEST_LOCATION );
738 using Dali::Animation;
739 Animation animation = Animation::New( 1.0f );
740 animation.AnimateTo( Property( constrainer, index ), Vector2(3,4) );
742 DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(1,2), TEST_LOCATION );
743 // Start the animation
746 application.SendNotification();
747 application.Render( 1000 /* 100% progress */);
748 DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(3,4), TEST_LOCATION );