Merge "Added api function to specify speed factor of an animation" into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Actor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "assert.h"
19 #include <dali/public-api/dali-core.h>
20 #include <string>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali-test-suite-utils.h>
23
24 //& set: DaliActor
25
26 using std::string;
27 using namespace Dali;
28
29
30 void utc_dali_actor_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_actor_cleanup(void)
36 {
37   test_return_value = TET_PASS;
38 }
39
40 namespace
41 {
42
43 bool gTouchCallBackCalled=false;
44 bool gTouchCallBack2Called=false;
45
46 /**
47  * Simulates a Down Touch at 25.0, 25.0.
48  * @param[in] app Test Application instance.
49  */
50 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
51 {
52   app.SendNotification();
53   app.Render(1);
54   app.SendNotification();
55   app.Render(1);
56
57   gTouchCallBackCalled = false;
58   gTouchCallBack2Called = false;
59
60   // simulate a touch event
61   Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
62   Dali::Integration::TouchEvent event;
63   event.AddPoint( point );
64   app.ProcessEvent( event );
65
66   app.SendNotification();
67   app.Render(1);
68   app.SendNotification();
69   app.Render(1);
70   END_TEST;
71 }
72
73
74 static bool gTestConstraintCalled;
75
76 struct TestConstraint
77 {
78   Vector4 operator()(const Vector4&    color)
79   {
80     gTestConstraintCalled = true;
81     return Vector4(color.x, color.y, color.z, 0.1f);
82   }
83 };
84
85 /**
86  * TestConstraint reference.
87  * When constraint is called, the resultRef is updated
88  * with the value supplied.
89  */
90 template<typename T>
91 struct TestConstraintRef
92 {
93   TestConstraintRef(unsigned int& resultRef, unsigned int value)
94   : mResultRef(resultRef),
95     mValue(value)
96   {
97   }
98
99   T operator()(const T&    current)
100   {
101     mResultRef = mValue;
102     return current;
103   }
104
105   unsigned int& mResultRef;
106   unsigned int mValue;
107 };
108
109 bool wasConstraintCallbackCalled1 = false;
110 void TestConstraintCallback1( ActiveConstraint& constraint )
111 {
112   wasConstraintCallbackCalled1 = true;
113 }
114
115 bool wasConstraintCallbackCalled2 = false;
116 void TestConstraintCallback2( ActiveConstraint& constraint )
117 {
118   wasConstraintCallbackCalled2 = true;
119 }
120
121 bool wasConstraintCallbackCalled3 = false;
122 void TestConstraintCallback3( ActiveConstraint& constraint )
123 {
124   wasConstraintCallbackCalled3 = true;
125 }
126
127 static bool TestCallback(Actor actor, const TouchEvent& event)
128 {
129   gTouchCallBackCalled = true;
130   return false;
131   END_TEST;
132 }
133
134 static bool TestCallback2(Actor actor, const TouchEvent& event)
135 {
136   gTouchCallBack2Called = true;
137   return false;
138   END_TEST;
139 }
140
141 static Vector3 gSetSize;
142 static bool gSetSizeCallBackCalled;
143 void SetSizeCallback( Actor actor, const Vector3& size )
144 {
145   gSetSizeCallBackCalled = true;
146   gSetSize = size;
147 }
148 // validation stuff for onstage & offstage signals
149 static std::vector< std::string > gActorNamesOnOffStage;
150 static int gOnStageCallBackCalled;
151 void OnStageCallback( Actor actor )
152 {
153   ++gOnStageCallBackCalled;
154   gActorNamesOnOffStage.push_back( actor.GetName() );
155   DALI_TEST_CHECK( actor.OnStage() == true );
156 }
157 static int gOffStageCallBackCalled;
158 void OffStageCallback( Actor actor )
159 {
160   ++gOffStageCallBackCalled;
161   gActorNamesOnOffStage.push_back( actor.GetName() );
162   DALI_TEST_CHECK( actor.OnStage() == false );
163 }
164
165 struct PositionComponentConstraint
166 {
167   PositionComponentConstraint(){}
168
169   Vector3 operator()(const Vector3& current, const PropertyInput& property)
170   {
171     const Matrix& m = property.GetMatrix();
172     Vector3 pos;
173     Vector3 scale;
174     Quaternion rot;
175     m.GetTransformComponents(pos, rot, scale);
176     return pos;
177   }
178 };
179
180
181
182 } // anonymous namespace
183
184
185 //& purpose: Testing New API
186 int UtcDaliActorNew(void)
187 {
188   TestApplication application;
189
190   Actor actor = Actor::New();
191
192   DALI_TEST_CHECK(actor);
193   END_TEST;
194 }
195
196 //& purpose: Testing Dali::Actor::DownCast()
197 int UtcDaliActorDownCast(void)
198 {
199   TestApplication application;
200   tet_infoline("Testing Dali::Actor::DownCast()");
201
202   Actor actor = Actor::New();
203   BaseHandle object(actor);
204   Actor actor2 = Actor::DownCast(object);
205   DALI_TEST_CHECK(actor2);
206   END_TEST;
207 }
208
209 //& purpose: Testing Dali::Actor::DownCast()
210 int UtcDaliActorDownCast2(void)
211 {
212   TestApplication application;
213   tet_infoline("Testing Dali::Actor::DownCast()");
214
215   BaseHandle unInitializedObject;
216   Actor actor = Actor::DownCast(unInitializedObject);
217   DALI_TEST_CHECK(!actor);
218   END_TEST;
219 }
220
221 //& purpose: Testing Dali::Actor::GetName()
222 int UtcDaliActorGetName(void)
223 {
224   TestApplication application;
225
226   Actor actor = Actor::New();
227
228   DALI_TEST_CHECK(actor.GetName().empty());
229   END_TEST;
230 }
231
232 //& purpose: Testing Dali::Actor::SetName()
233 int UtcDaliActorSetName(void)
234 {
235   TestApplication application;
236
237   string str("ActorName");
238   Actor actor = Actor::New();
239
240   actor.SetName(str);
241   DALI_TEST_CHECK(actor.GetName() == str);
242   END_TEST;
243 }
244
245 int UtcDaliActorGetId(void)
246 {
247   tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
248   TestApplication application;
249
250   Actor first = Actor::New();
251   Actor second = Actor::New();
252   Actor third = Actor::New();
253
254   DALI_TEST_CHECK(first.GetId() != second.GetId());
255   DALI_TEST_CHECK(second.GetId() != third.GetId());
256   END_TEST;
257 }
258
259 int UtcDaliActorIsRoot(void)
260 {
261   TestApplication application;
262
263   Actor actor = Actor::New();
264   DALI_TEST_CHECK(!actor.IsRoot());
265
266   // get the root layer
267   actor = Stage::GetCurrent().GetLayer( 0 );
268   DALI_TEST_CHECK( actor.IsRoot() );
269   END_TEST;
270 }
271
272 int UtcDaliActorOnStage(void)
273 {
274   TestApplication application;
275
276   Actor actor = Actor::New();
277   DALI_TEST_CHECK( !actor.OnStage() );
278
279   // get the root layer
280   actor = Stage::GetCurrent().GetLayer( 0 );
281   DALI_TEST_CHECK( actor.OnStage() );
282   END_TEST;
283 }
284
285 int UtcDaliActorIsLayer(void)
286 {
287   TestApplication application;
288
289   Actor actor = Actor::New();
290   DALI_TEST_CHECK( !actor.IsLayer() );
291
292   // get the root layer
293   actor = Stage::GetCurrent().GetLayer( 0 );
294   DALI_TEST_CHECK( actor.IsLayer() );
295   END_TEST;
296 }
297
298 int UtcDaliActorGetLayer(void)
299 {
300   TestApplication application;
301
302   Actor actor = Actor::New();
303   Stage::GetCurrent().Add(actor);
304   Layer layer = actor.GetLayer();
305
306   DALI_TEST_CHECK(layer);
307
308   // get the root layers layer
309   actor = Stage::GetCurrent().GetLayer( 0 );
310   DALI_TEST_CHECK( actor.GetLayer() );
311   END_TEST;
312 }
313
314 int UtcDaliActorAdd(void)
315 {
316   tet_infoline("Testing Actor::Add");
317   TestApplication application;
318
319   Actor parent = Actor::New();
320   Actor child = Actor::New();
321
322   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
323
324   parent.Add(child);
325
326   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
327
328   Actor parent2 = Actor::New();
329   parent2.Add( child );
330
331   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
332   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
333
334   // try Adding to same parent again, works
335   parent2.Add( child );
336   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
337
338   // try reparenting an orphaned child
339   {
340     Actor temporaryParent = Actor::New();
341     temporaryParent.Add( child );
342     DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
343   }
344   // temporaryParent has now died, reparent the orphaned child
345   parent2.Add( child );
346   DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
347
348   // try illegal Add
349   try
350   {
351     parent2.Add( parent2 );
352     tet_printf("Assertion test failed - no Exception\n" );
353     tet_result(TET_FAIL);
354   }
355   catch(Dali::DaliException& e)
356   {
357     tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
358     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
359     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
360   }
361   catch(...)
362   {
363     tet_printf("Assertion test failed - wrong Exception\n" );
364     tet_result(TET_FAIL);
365   }
366
367   // try reparenting root
368   try
369   {
370     parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
371     tet_printf("Assertion test failed - no Exception\n" );
372     tet_result(TET_FAIL);
373   }
374   catch(Dali::DaliException& e)
375   {
376     tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
377     DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
378     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
379   }
380   catch(...)
381   {
382     tet_printf("Assertion test failed - wrong Exception\n" );
383     tet_result(TET_FAIL);
384   }
385
386   // try Add empty
387   try
388   {
389     Actor empty;
390     parent2.Add( empty );
391     tet_printf("Assertion test failed - no Exception\n" );
392     tet_result(TET_FAIL);
393   }
394   catch(Dali::DaliException& e)
395   {
396     tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
397     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
398     DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
399   }
400   catch(...)
401   {
402     tet_printf("Assertion test failed - wrong Exception\n" );
403     tet_result(TET_FAIL);
404   }
405   END_TEST;
406 }
407
408 int UtcDaliActorInsert(void)
409 {
410   tet_infoline("Testing Actor::Insert");
411   TestApplication application;
412
413   Actor parent = Actor::New();
414   Stage::GetCurrent().Add( parent );
415   Actor first = Actor::New();
416   Actor second = Actor::New();
417   Actor third = Actor::New();
418
419   parent.Insert(1, first); // test insert beyond range
420   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
421   parent.Insert(0, second);
422   DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
423   parent.Insert(1, third);
424
425   DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
426
427   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
428   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
429   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
430
431   END_TEST;
432 }
433
434
435 int UtcDaliActorRemove01(void)
436 {
437   tet_infoline("Testing Actor::Remove");
438   TestApplication application;
439
440   Actor parent = Actor::New();
441   Actor child = Actor::New();
442   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
443
444   parent.Add(child);
445   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
446
447   parent.Remove(child);
448   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
449
450   // remove again, no problem
451   parent.Remove(child);
452   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
453
454   // add child back
455   parent.Add(child);
456   // try illegal Remove
457   try
458   {
459     parent.Remove( parent );
460     tet_printf("Assertion test failed - no Exception\n" );
461     tet_result(TET_FAIL);
462   }
463   catch(Dali::DaliException& e)
464   {
465     tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
466     DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
467     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
468   }
469   catch(...)
470   {
471     tet_printf("Assertion test failed - wrong Exception\n" );
472     tet_result(TET_FAIL);
473   }
474
475   // try Remove empty
476   try
477   {
478     Actor empty;
479     parent.Remove( empty );
480     tet_printf("Assertion test failed - no Exception\n" );
481     tet_result(TET_FAIL);
482   }
483   catch(Dali::DaliException& e)
484   {
485     tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
486     DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
487     DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
488   }
489   catch(...)
490   {
491     tet_printf("Assertion test failed - wrong Exception\n" );
492     tet_result(TET_FAIL);
493   }
494   END_TEST;
495 }
496
497 int UtcDaliActorRemove02(void)
498 {
499   TestApplication application;
500
501   Actor parent = Actor::New();
502   Actor child = Actor::New();
503   Actor random = Actor::New();
504
505   Stage::GetCurrent().Add( parent );
506
507   DALI_TEST_CHECK(parent.GetChildCount() == 0);
508
509   parent.Add(child);
510
511   DALI_TEST_CHECK(parent.GetChildCount() == 1);
512
513   parent.Remove(random);
514
515   DALI_TEST_CHECK(parent.GetChildCount() == 1);
516
517   Stage::GetCurrent().Remove( parent );
518
519   DALI_TEST_CHECK(parent.GetChildCount() == 1);
520   END_TEST;
521 }
522
523 int UtcDaliActorGetChildCount(void)
524 {
525   TestApplication application;
526
527   Actor parent = Actor::New();
528   Actor child = Actor::New();
529
530   DALI_TEST_CHECK(parent.GetChildCount() == 0);
531
532   parent.Add(child);
533
534   DALI_TEST_CHECK(parent.GetChildCount() == 1);
535   END_TEST;
536 }
537
538 int UtcDaliActorGetChildren01(void)
539 {
540   TestApplication application;
541
542   Actor parent = Actor::New();
543   Actor first  = Actor::New();
544   Actor second = Actor::New();
545   Actor third  = Actor::New();
546
547   parent.Add(first);
548   parent.Add(second);
549   parent.Add(third);
550
551   DALI_TEST_CHECK(parent.GetChildAt(0) == first);
552   DALI_TEST_CHECK(parent.GetChildAt(1) == second);
553   DALI_TEST_CHECK(parent.GetChildAt(2) == third);
554   END_TEST;
555 }
556
557 int UtcDaliActorGetChildren02(void)
558 {
559   TestApplication application;
560
561   Actor parent = Actor::New();
562   Actor first  = Actor::New();
563   Actor second = Actor::New();
564   Actor third  = Actor::New();
565
566   parent.Add(first);
567   parent.Add(second);
568   parent.Add(third);
569
570   const Actor& constParent = parent;
571
572   DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
573   DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
574   DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
575   END_TEST;
576 }
577
578 int UtcDaliActorGetParent01(void)
579 {
580   TestApplication application;
581
582   Actor parent = Actor::New();
583   Actor child = Actor::New();
584
585   parent.Add(child);
586
587   DALI_TEST_CHECK(child.GetParent() == parent);
588   END_TEST;
589 }
590
591 int UtcDaliActorGetParent02(void)
592 {
593   TestApplication application;
594
595   Actor actor = Actor::New();
596
597   DALI_TEST_CHECK(!actor.GetParent());
598   END_TEST;
599 }
600
601 int UtcDaliActorSetParentOrigin(void)
602 {
603   TestApplication application;
604
605   Actor actor = Actor::New();
606
607   Vector3 vector(0.7f, 0.8f, 0.9f);
608   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
609
610   actor.SetParentOrigin(vector);
611
612   // flush the queue and render once
613   application.SendNotification();
614   application.Render();
615
616   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
617
618   Stage::GetCurrent().Add( actor );
619
620   actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
621
622   // flush the queue and render once
623   application.SendNotification();
624   application.Render();
625
626   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
627
628   Stage::GetCurrent().Remove( actor );
629   END_TEST;
630 }
631
632 int UtcDaliActorGetCurrentParentOrigin(void)
633 {
634   TestApplication application;
635
636   Actor actor = Actor::New();
637
638   Vector3 vector(0.7f, 0.8f, 0.9f);
639   DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
640
641   actor.SetParentOrigin(vector);
642
643   // flush the queue and render once
644   application.SendNotification();
645   application.Render();
646
647   DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
648   END_TEST;
649 }
650
651 int UtcDaliActorSetAnchorPoint(void)
652 {
653   TestApplication application;
654
655   Actor actor = Actor::New();
656
657   Vector3 vector(0.7f, 0.8f, 0.9f);
658   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
659
660   actor.SetAnchorPoint(vector);
661
662   // flush the queue and render once
663   application.SendNotification();
664   application.Render();
665
666   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
667
668   Stage::GetCurrent().Add( actor );
669
670   actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
671   // flush the queue and render once
672   application.SendNotification();
673   application.Render();
674
675   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
676
677   Stage::GetCurrent().Remove( actor );
678   END_TEST;
679 }
680
681 int UtcDaliActorGetCurrentAnchorPoint(void)
682 {
683   TestApplication application;
684
685   Actor actor = Actor::New();
686
687   Vector3 vector(0.7f, 0.8f, 0.9f);
688   DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
689
690   actor.SetAnchorPoint(vector);
691
692   // flush the queue and render once
693   application.SendNotification();
694   application.Render();
695
696   DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
697   END_TEST;
698 }
699
700 // SetSize(float width, float height)
701 int UtcDaliActorSetSize01(void)
702 {
703   TestApplication application;
704
705   Actor actor = Actor::New();
706   Vector3 vector(100.0f, 100.0f, 100.0f);
707
708   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
709
710   actor.SetSize(vector.x, vector.y);
711
712   // flush the queue and render once
713   application.SendNotification();
714   application.Render();
715
716   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
717   END_TEST;
718 }
719
720 // SetSize(float width, float height, float depth)
721 int UtcDaliActorSetSize02(void)
722 {
723   TestApplication application;
724
725   Actor actor = Actor::New();
726   Vector3 vector(100.0f, 100.0f, 100.0f);
727
728   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
729
730   actor.SetSize(vector.x, vector.y, vector.z);
731
732   // flush the queue and render once
733   application.SendNotification();
734   application.Render();
735
736   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
737   END_TEST;
738 }
739
740 // SetSize(Vector2 size)
741 int UtcDaliActorSetSize03(void)
742 {
743   TestApplication application;
744
745   Actor actor = Actor::New();
746   Vector3 vector(100.0f, 100.0f, 100.0f);
747
748   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
749
750   actor.SetSize(Vector2(vector.x, vector.y));
751
752   // flush the queue and render once
753   application.SendNotification();
754   application.Render();
755
756   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
757   END_TEST;
758 }
759
760 // SetSize(Vector3 size)
761 int UtcDaliActorSetSize04(void)
762 {
763   TestApplication application;
764
765   Actor actor = Actor::New();
766   Vector3 vector(100.0f, 100.0f, 100.0f);
767
768   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
769
770   actor.SetSize(vector);
771
772   // flush the queue and render once
773   application.SendNotification();
774   application.Render();
775
776   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
777
778   Stage::GetCurrent().Add( actor );
779   actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
780
781   // flush the queue and render once
782   application.SendNotification();
783   application.Render();
784
785   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
786   Stage::GetCurrent().Remove( actor );
787   END_TEST;
788 }
789
790 int UtcDaliActorGetCurrentSize(void)
791 {
792   TestApplication application;
793
794   Actor actor = Actor::New();
795   Vector3 vector(100.0f, 100.0f, 20.0f);
796
797   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
798
799   actor.SetSize(vector);
800
801   // flush the queue and render once
802   application.SendNotification();
803   application.Render();
804
805   DALI_TEST_CHECK(vector == actor.GetCurrentSize());
806   END_TEST;
807 }
808
809 // SetPosition(float x, float y)
810 int UtcDaliActorSetPosition01(void)
811 {
812   TestApplication application;
813
814   Actor actor = Actor::New();
815
816   // Set to random to start off with
817   actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
818
819   Vector3 vector(100.0f, 100.0f, 0.0f);
820
821   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
822
823   actor.SetPosition(vector.x, vector.y);
824   // flush the queue and render once
825   application.SendNotification();
826   application.Render();
827   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
828
829   Stage::GetCurrent().Add( actor );
830   actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
831   // flush the queue and render once
832   application.SendNotification();
833   application.Render();
834   DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
835
836   actor.SetX( 1.0f );
837   actor.SetY( 1.1f );
838   actor.SetZ( 1.2f );
839   // flush the queue and render once
840   application.SendNotification();
841   application.Render();
842   DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
843
844   actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
845   // flush the queue and render once
846   application.SendNotification();
847   application.Render();
848   DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
849
850   Stage::GetCurrent().Remove( actor );
851   END_TEST;
852 }
853
854 // SetPosition(float x, float y, float z)
855 int UtcDaliActorSetPosition02(void)
856 {
857   TestApplication application;
858
859   Actor actor = Actor::New();
860
861   // Set to random to start off with
862   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
863
864   Vector3 vector(100.0f, 100.0f, 100.0f);
865
866   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
867
868   actor.SetPosition(vector.x, vector.y, vector.z);
869
870   // flush the queue and render once
871   application.SendNotification();
872   application.Render();
873
874   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
875   END_TEST;
876 }
877
878 // SetPosition(Vector3 position)
879 int UtcDaliActorSetPosition03(void)
880 {
881   TestApplication application;
882
883   Actor actor = Actor::New();
884
885   // Set to random to start off with
886   actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
887
888   Vector3 vector(100.0f, 100.0f, 100.0f);
889
890   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
891
892   actor.SetPosition(vector);
893
894   // flush the queue and render once
895   application.SendNotification();
896   application.Render();
897
898   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
899   END_TEST;
900 }
901
902 int UtcDaliActorSetX(void)
903 {
904   TestApplication application;
905
906   Actor actor = Actor::New();
907
908   Vector3 vector(100.0f, 0.0f, 0.0f);
909
910   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
911
912   actor.SetX(100.0f);
913
914   // flush the queue and render once
915   application.SendNotification();
916   application.Render();
917
918   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
919   END_TEST;
920 }
921
922 int UtcDaliActorSetY(void)
923 {
924   TestApplication application;
925
926   Actor actor = Actor::New();
927
928   Vector3 vector(0.0f, 100.0f, 0.0f);
929
930   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
931
932   actor.SetY(100.0f);
933
934   // flush the queue and render once
935   application.SendNotification();
936   application.Render();
937
938   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
939   END_TEST;
940 }
941
942 int UtcDaliActorSetZ(void)
943 {
944   TestApplication application;
945
946   Actor actor = Actor::New();
947
948   Vector3 vector(0.0f, 0.0f, 100.0f);
949
950   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
951
952   actor.SetZ(100.0f);
953
954   // flush the queue and render once
955   application.SendNotification();
956   application.Render();
957
958   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
959   END_TEST;
960 }
961
962 int UtcDaliActorMoveBy(void)
963 {
964   TestApplication application;
965
966   Actor actor = Actor::New();
967   Vector3 vector(100.0f, 100.0f, 100.0f);
968
969   DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
970
971   actor.SetPosition(vector);
972
973   // flush the queue and render once
974   application.SendNotification();
975   application.Render();
976
977   DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
978
979   actor.MoveBy(vector);
980
981   // flush the queue and render once
982   application.SendNotification();
983   application.Render();
984
985   DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
986   END_TEST;
987 }
988
989 int UtcDaliActorGetCurrentPosition(void)
990 {
991   TestApplication application;
992
993   Actor actor = Actor::New();
994   Vector3 setVector(100.0f, 100.0f, 0.0f);
995   actor.SetPosition(setVector);
996
997   // flush the queue and render once
998   application.SendNotification();
999   application.Render();
1000
1001   DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1002   END_TEST;
1003 }
1004
1005 int UtcDaliActorGetCurrentWorldPosition(void)
1006 {
1007   TestApplication application;
1008
1009   Actor parent = Actor::New();
1010   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1011   parent.SetPosition( parentPosition );
1012   parent.SetParentOrigin( ParentOrigin::CENTER );
1013   parent.SetAnchorPoint( AnchorPoint::CENTER );
1014   Stage::GetCurrent().Add( parent );
1015
1016   Actor child = Actor::New();
1017   child.SetParentOrigin( ParentOrigin::CENTER );
1018   child.SetAnchorPoint( AnchorPoint::CENTER );
1019   Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1020   child.SetPosition( childPosition );
1021   parent.Add( child );
1022
1023   // The actors should not have a world position yet
1024   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1025   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1026
1027   application.SendNotification();
1028   application.Render(0);
1029
1030   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1031   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1032
1033   // The actors should have a world position now
1034   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1035   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1036   END_TEST;
1037 }
1038
1039 int UtcDaliActorInheritPosition(void)
1040 {
1041   tet_infoline("Testing Actor::SetPositionInheritanceMode");
1042   TestApplication application;
1043
1044   Actor parent = Actor::New();
1045   Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1046   parent.SetPosition( parentPosition );
1047   parent.SetParentOrigin( ParentOrigin::CENTER );
1048   parent.SetAnchorPoint( AnchorPoint::CENTER );
1049   Stage::GetCurrent().Add( parent );
1050
1051   Actor child = Actor::New();
1052   child.SetParentOrigin( ParentOrigin::CENTER );
1053   child.SetAnchorPoint( AnchorPoint::CENTER );
1054   Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1055   child.SetPosition( childPosition );
1056   parent.Add( child );
1057
1058   // The actors should not have a world position yet
1059   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1060   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1061
1062   // first test default, which is INHERIT_PARENT_POSITION
1063   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1064   application.SendNotification();
1065   application.Render(0); // should only really call Update as Render is not required to update scene
1066   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1067   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1068   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1069   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1070
1071   // Change inheritance mode to use parent
1072   child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1073   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1074   application.SendNotification();
1075   application.Render(0); // should only really call Update as Render is not required to update scene
1076   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1077   DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1078   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1079   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1080
1081   // Change inheritance mode to use parent + offset
1082   child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1083   Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1084   child.SetPosition( childOffset );
1085   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1086   application.SendNotification();
1087   application.Render(0); // should only really call Update as Render is not required to update scene
1088   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1089   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1090   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1091   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1092
1093   // Change inheritance mode to not inherit
1094   child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1095   DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1096   application.SendNotification();
1097   application.Render(0); // should only really call Update as Render is not required to update scene
1098   DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1099   DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1100   DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1101   DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1102   END_TEST;
1103 }
1104
1105 // SetRotation(float angleRadians, Vector3 axis)
1106 int UtcDaliActorSetRotation01(void)
1107 {
1108   TestApplication application;
1109
1110   Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1111   Actor actor = Actor::New();
1112
1113   actor.SetRotation(rotation);
1114
1115   // flush the queue and render once
1116   application.SendNotification();
1117   application.Render();
1118
1119   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1120   END_TEST;
1121 }
1122
1123 int UtcDaliActorSetRotation02(void)
1124 {
1125   TestApplication application;
1126
1127   Actor actor = Actor::New();
1128
1129   float angle = 0.785f;
1130   Vector3 axis(1.0f, 1.0f, 0.0f);
1131
1132   actor.SetRotation(Radian( angle ), axis);
1133   Quaternion rotation( angle, axis );
1134   // flush the queue and render once
1135   application.SendNotification();
1136   application.Render();
1137   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1138
1139   Stage::GetCurrent().Add( actor );
1140   actor.RotateBy( Degree( 360 ), axis);
1141   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1142
1143   actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1144   Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1145   // flush the queue and render once
1146   application.SendNotification();
1147   application.Render();
1148   DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1149
1150   actor.SetRotation(Radian( angle ), axis);
1151   // flush the queue and render once
1152   application.SendNotification();
1153   application.Render();
1154   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1155
1156   Stage::GetCurrent().Remove( actor );
1157   END_TEST;
1158 }
1159
1160 // RotateBy(float angleRadians, Vector3 axis)
1161 int UtcDaliActorRotateBy01(void)
1162 {
1163   TestApplication application;
1164
1165   Actor actor = Actor::New();
1166
1167   float angle = M_PI * 0.25f;
1168   actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1169   // flush the queue and render once
1170   application.SendNotification();
1171   application.Render();
1172   DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1173
1174   Stage::GetCurrent().Add( actor );
1175
1176   actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1177   // flush the queue and render once
1178   application.SendNotification();
1179   application.Render();
1180   DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1181
1182   Stage::GetCurrent().Remove( actor );
1183   END_TEST;
1184 }
1185
1186 // RotateBy(Quaternion relativeRotation)
1187 int UtcDaliActorRotateBy02(void)
1188 {
1189   TestApplication application;
1190
1191   Actor actor = Actor::New();
1192
1193   Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1194   actor.RotateBy(rotation);
1195   // flush the queue and render once
1196   application.SendNotification();
1197   application.Render();
1198   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1199
1200   actor.RotateBy(rotation);
1201   // flush the queue and render once
1202   application.SendNotification();
1203   application.Render();
1204   DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1205   END_TEST;
1206 }
1207
1208 int UtcDaliActorGetCurrentRotation(void)
1209 {
1210   TestApplication application;
1211   Actor actor = Actor::New();
1212
1213   Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1214   actor.SetRotation(rotation);
1215   // flush the queue and render once
1216   application.SendNotification();
1217   application.Render();
1218   DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1219   END_TEST;
1220 }
1221
1222 int UtcDaliActorGetCurrentWorldRotation(void)
1223 {
1224   tet_infoline("Testing Actor::GetCurrentWorldRotation");
1225   TestApplication application;
1226
1227   Actor parent = Actor::New();
1228   Radian rotationAngle( Degree(90.0f) );
1229   Quaternion rotation( rotationAngle, Vector3::YAXIS );
1230   parent.SetRotation( rotation );
1231   Stage::GetCurrent().Add( parent );
1232
1233   Actor child = Actor::New();
1234   child.SetRotation( rotation );
1235   parent.Add( child );
1236
1237   // The actors should not have a world rotation yet
1238   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1239   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1240
1241   application.SendNotification();
1242   application.Render(0);
1243
1244   DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1245   DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1246
1247   // The actors should have a world rotation now
1248   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1249   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1250
1251   // turn off child rotation inheritance
1252   child.SetInheritRotation( false );
1253   DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1254   application.SendNotification();
1255   application.Render(0);
1256
1257   // The actors should have a world rotation now
1258   DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1259   DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1260   END_TEST;
1261 }
1262
1263 // SetScale(float scale)
1264 int UtcDaliActorSetScale01(void)
1265 {
1266   TestApplication application;
1267
1268   Actor actor = Actor::New();
1269
1270   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1271   actor.SetScale(0.25f);
1272
1273   Vector3 scale(10.0f, 10.0f, 10.0f);
1274   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1275
1276   actor.SetScale(scale.x);
1277
1278   // flush the queue and render once
1279   application.SendNotification();
1280   application.Render();
1281
1282   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1283   END_TEST;
1284 }
1285
1286 // SetScale(float scaleX, float scaleY, float scaleZ)
1287 int UtcDaliActorSetScale02(void)
1288 {
1289   TestApplication application;
1290   Vector3 scale(10.0f, 10.0f, 10.0f);
1291
1292   Actor actor = Actor::New();
1293
1294   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1295   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1296
1297   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1298
1299   actor.SetScale(scale.x, scale.y, scale.z);
1300   // flush the queue and render once
1301   application.SendNotification();
1302   application.Render();
1303   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1304
1305   // add to stage and test
1306   Stage::GetCurrent().Add( actor );
1307   actor.SetScale( 2.0f, 2.0f, 2.0f );
1308   // flush the queue and render once
1309   application.SendNotification();
1310   application.Render();
1311   DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1312
1313   Stage::GetCurrent().Remove( actor );
1314
1315   END_TEST;
1316 }
1317
1318 // SetScale(Vector3 scale)
1319 int UtcDaliActorSetScale03(void)
1320 {
1321   TestApplication application;
1322   Vector3 scale(10.0f, 10.0f, 10.0f);
1323
1324   Actor actor = Actor::New();
1325
1326   // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1327   actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1328
1329   DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1330
1331   actor.SetScale(scale);
1332
1333   // flush the queue and render once
1334   application.SendNotification();
1335   application.Render();
1336
1337   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1338   END_TEST;
1339 }
1340
1341 int UtcDaliActorScaleBy(void)
1342 {
1343   TestApplication application;
1344   Actor actor = Actor::New();
1345   Vector3 vector(100.0f, 100.0f, 100.0f);
1346
1347   DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1348
1349   actor.SetScale(vector);
1350
1351   // flush the queue and render once
1352   application.SendNotification();
1353   application.Render();
1354
1355   DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1356
1357   actor.ScaleBy(vector);
1358
1359   // flush the queue and render once
1360   application.SendNotification();
1361   application.Render();
1362
1363   DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1364   END_TEST;
1365 }
1366
1367 int UtcDaliActorGetCurrentScale(void)
1368 {
1369   TestApplication application;
1370   Vector3 scale(12.0f, 1.0f, 2.0f);
1371
1372   Actor actor = Actor::New();
1373
1374   actor.SetScale(scale);
1375
1376   // flush the queue and render once
1377   application.SendNotification();
1378   application.Render();
1379
1380   DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1381   END_TEST;
1382 }
1383
1384 int UtcDaliActorGetCurrentWorldScale(void)
1385 {
1386   TestApplication application;
1387
1388   Actor parent = Actor::New();
1389   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1390   parent.SetScale( parentScale );
1391   Stage::GetCurrent().Add( parent );
1392
1393   Actor child = Actor::New();
1394   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1395   child.SetScale( childScale );
1396   parent.Add( child );
1397
1398   // The actors should not have a scale yet
1399   DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1400   DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1401
1402   // The actors should not have a world scale yet
1403   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1404   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1405
1406   application.SendNotification();
1407   application.Render(0);
1408
1409   DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1410   DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1411
1412   // The actors should have a world scale now
1413   DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1414   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1415   END_TEST;
1416 }
1417
1418 int UtcDaliActorInheritScale(void)
1419 {
1420   tet_infoline("Testing Actor::SetInheritScale");
1421   TestApplication application;
1422
1423   Actor parent = Actor::New();
1424   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1425   parent.SetScale( parentScale );
1426   Stage::GetCurrent().Add( parent );
1427
1428   Actor child = Actor::New();
1429   Vector3 childScale( 2.0f, 2.0f, 2.0f );
1430   child.SetScale( childScale );
1431   parent.Add( child );
1432
1433   application.SendNotification();
1434   application.Render(0);
1435
1436   DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1437   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1438
1439   child.SetInheritScale( false );
1440   DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1441
1442   application.SendNotification();
1443   application.Render(0);
1444
1445   DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1446   END_TEST;
1447 }
1448
1449 int UtcDaliActorSetVisible(void)
1450 {
1451   TestApplication application;
1452
1453   Actor actor = Actor::New();
1454   actor.SetVisible(false);
1455   // flush the queue and render once
1456   application.SendNotification();
1457   application.Render();
1458   DALI_TEST_CHECK(actor.IsVisible() == false);
1459
1460   actor.SetVisible(true);
1461   // flush the queue and render once
1462   application.SendNotification();
1463   application.Render();
1464   DALI_TEST_CHECK(actor.IsVisible() == true);
1465
1466   // put actor on stage
1467   Stage::GetCurrent().Add( actor );
1468   actor.SetVisible(false);
1469   // flush the queue and render once
1470   application.SendNotification();
1471   application.Render();
1472   DALI_TEST_CHECK(actor.IsVisible() == false);
1473   END_TEST;
1474 }
1475
1476 int UtcDaliActorIsVisible(void)
1477 {
1478   TestApplication application;
1479
1480   Actor actor = Actor::New();
1481
1482   DALI_TEST_CHECK(actor.IsVisible() == true);
1483   END_TEST;
1484 }
1485
1486 int UtcDaliActorSetOpacity(void)
1487 {
1488   TestApplication application;
1489
1490   Actor actor = Actor::New();
1491   // initial opacity is 1
1492   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1493
1494   actor.SetOpacity( 0.4f);
1495   // flush the queue and render once
1496   application.SendNotification();
1497   application.Render();
1498   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1499
1500   // change opacity, actor is on stage to change is not immediate
1501   actor.OpacityBy( 0.1f );
1502   // flush the queue and render once
1503   application.SendNotification();
1504   application.Render();
1505   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1506
1507   // put actor on stage
1508   Stage::GetCurrent().Add( actor );
1509
1510   // change opacity, actor is on stage to change is not immediate
1511   actor.SetOpacity( 0.9f );
1512   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1513   // flush the queue and render once
1514   application.SendNotification();
1515   application.Render();
1516   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1517
1518   // change opacity, actor is on stage to change is not immediate
1519   actor.OpacityBy( -0.9f );
1520   // flush the queue and render once
1521   application.SendNotification();
1522   application.Render();
1523   DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1524   END_TEST;
1525 }
1526
1527 int UtcDaliActorGetCurrentOpacity(void)
1528 {
1529   TestApplication application;
1530
1531   Actor actor = Actor::New();
1532   DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1533
1534   actor.SetOpacity(0.5f);
1535   // flush the queue and render once
1536   application.SendNotification();
1537   application.Render();
1538   DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1539   END_TEST;
1540 }
1541
1542 int UtcDaliActorSetSensitive(void)
1543 {
1544   TestApplication application;
1545   Actor actor = Actor::New();
1546
1547   bool sensitive = !actor.IsSensitive();
1548
1549   actor.SetSensitive(sensitive);
1550
1551   DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1552   END_TEST;
1553 }
1554
1555 int UtcDaliActorIsSensitive(void)
1556 {
1557   TestApplication application;
1558   Actor actor = Actor::New();
1559   actor.SetSensitive(false);
1560
1561   DALI_TEST_CHECK(false == actor.IsSensitive());
1562   END_TEST;
1563 }
1564
1565 int UtcDaliActorSetColor(void)
1566 {
1567   TestApplication application;
1568   Actor actor = Actor::New();
1569   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1570
1571   DALI_TEST_CHECK(color != actor.GetCurrentColor());
1572
1573   actor.SetColor(color);
1574   // flush the queue and render once
1575   application.SendNotification();
1576   application.Render();
1577   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1578
1579   actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1580   // flush the queue and render once
1581   application.SendNotification();
1582   application.Render();
1583   DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(),  TEST_LOCATION );
1584
1585   Stage::GetCurrent().Add( actor );
1586   actor.SetColor( color );
1587   // flush the queue and render once
1588   application.SendNotification();
1589   application.Render();
1590   DALI_TEST_EQUALS( color, actor.GetCurrentColor(),  TEST_LOCATION );
1591
1592   actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1593   // flush the queue and render once
1594   application.SendNotification();
1595   application.Render();
1596   // Actor color is not clamped
1597   DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(),  TEST_LOCATION );
1598   // world color is clamped
1599   DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(),  TEST_LOCATION );
1600
1601   Stage::GetCurrent().Remove( actor );
1602   END_TEST;
1603 }
1604
1605 int UtcDaliActorGetCurrentColor(void)
1606 {
1607   TestApplication application;
1608   Actor actor = Actor::New();
1609   Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1610
1611   actor.SetColor(color);
1612   // flush the queue and render once
1613   application.SendNotification();
1614   application.Render();
1615   DALI_TEST_CHECK(color == actor.GetCurrentColor());
1616   END_TEST;
1617 }
1618
1619 int UtcDaliActorGetCurrentWorldColor(void)
1620 {
1621   tet_infoline("Actor::GetCurrentWorldColor");
1622   TestApplication application;
1623
1624   Actor parent = Actor::New();
1625   Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1626   parent.SetColor( parentColor );
1627   Stage::GetCurrent().Add( parent );
1628
1629   Actor child = Actor::New();
1630   Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1631   child.SetColor( childColor );
1632   parent.Add( child );
1633
1634   DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1635   DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1636
1637   // verify the default color mode
1638   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1639
1640   // The actors should not have a world color yet
1641   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1642   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1643
1644   application.SendNotification();
1645   application.Render(0);
1646
1647   DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1648   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1649
1650   // The actors should have a world color now
1651   DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1652   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1653
1654   // use own color
1655   child.SetColorMode( USE_OWN_COLOR );
1656   application.SendNotification();
1657   application.Render(0);
1658   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1659
1660   // use parent color
1661   child.SetColorMode( USE_PARENT_COLOR );
1662   application.SendNotification();
1663   application.Render(0);
1664   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1665   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1666
1667   // use parent alpha
1668   child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1669   application.SendNotification();
1670   application.Render(0);
1671   Vector4 expectedColor( childColor );
1672   expectedColor.a *= parentColor.a;
1673   DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1674   DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1675   END_TEST;
1676 }
1677
1678 int UtcDaliActorSetColorMode(void)
1679 {
1680   tet_infoline("Actor::SetColorMode");
1681   TestApplication application;
1682   Actor actor = Actor::New();
1683   Actor child = Actor::New();
1684   actor.Add( child );
1685
1686   actor.SetColorMode( USE_OWN_COLOR );
1687   DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1688
1689   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1690   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1691
1692   actor.SetColorMode( USE_PARENT_COLOR );
1693   DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1694
1695   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1696   DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1697   END_TEST;
1698 }
1699
1700 int UtcDaliActorScreenToLocal(void)
1701 {
1702   TestApplication application;
1703   Actor actor = Actor::New();
1704   actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1705   actor.SetSize(100.0f, 100.0f);
1706   actor.SetPosition(10.0f, 10.0f);
1707   Stage::GetCurrent().Add(actor);
1708
1709   // flush the queue and render once
1710   application.SendNotification();
1711   application.Render();
1712
1713   float localX;
1714   float localY;
1715
1716   DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1717
1718   DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1719   DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1720   END_TEST;
1721 }
1722
1723 int UtcDaliActorSetLeaveRequired(void)
1724 {
1725   TestApplication application;
1726
1727   Actor actor = Actor::New();
1728
1729   actor.SetLeaveRequired(false);
1730   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1731
1732   actor.SetLeaveRequired(true);
1733   DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1734   END_TEST;
1735 }
1736
1737 int UtcDaliActorGetLeaveRequired(void)
1738 {
1739   TestApplication application;
1740
1741   Actor actor = Actor::New();
1742
1743   DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1744   END_TEST;
1745 }
1746
1747 int UtcDaliActorSetKeyboardFocusable(void)
1748 {
1749   TestApplication application;
1750
1751   Actor actor = Actor::New();
1752
1753   actor.SetKeyboardFocusable(true);
1754   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1755
1756   actor.SetKeyboardFocusable(false);
1757   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1758   END_TEST;
1759 }
1760
1761 int UtcDaliActorIsKeyboardFocusable(void)
1762 {
1763   TestApplication application;
1764
1765   Actor actor = Actor::New();
1766
1767   DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1768   END_TEST;
1769 }
1770
1771
1772 int UtcDaliActorApplyConstraint(void)
1773 {
1774   TestApplication application;
1775
1776   gTestConstraintCalled = false;
1777
1778   Actor actor = Actor::New();
1779
1780   Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1781   actor.ApplyConstraint(constraint);
1782
1783   DALI_TEST_CHECK( gTestConstraintCalled == false );
1784   // add to stage
1785   Stage::GetCurrent().Add( actor );
1786
1787   // flush the queue and render once
1788   application.SendNotification();
1789   application.Render();
1790
1791   DALI_TEST_CHECK( gTestConstraintCalled == true );
1792   END_TEST;
1793 }
1794
1795
1796 int UtcDaliActorApplyConstraintAppliedCallback(void)
1797 {
1798   TestApplication application;
1799
1800   // Build a reusable constraint
1801
1802   Actor parent = Actor::New();
1803   Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1804   parent.SetSize( parentSize );
1805   Stage::GetCurrent().Add( parent );
1806
1807   Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1808                                                     Source( parent, Actor::SIZE ),
1809                                                     EqualToConstraint() );
1810
1811   // Create some child actors
1812
1813   Actor child1 = Actor::New();
1814   parent.Add( child1 );
1815
1816   Actor child2 = Actor::New();
1817   parent.Add( child2 );
1818
1819   Actor child3 = Actor::New();
1820   parent.Add( child3 );
1821
1822   // Apply constraint with different timings - everything should be finished after 10 seconds
1823
1824   wasConstraintCallbackCalled1 = false;
1825   wasConstraintCallbackCalled2 = false;
1826   wasConstraintCallbackCalled3 = false;
1827
1828   constraint.SetApplyTime( 5.0f );
1829   ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1830   activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1831
1832   constraint.SetApplyTime( 10.0f );
1833   ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1834   activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1835
1836   constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1837   ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1838   activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1839
1840   DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1841   DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1842   DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1843
1844   application.SendNotification();
1845
1846   application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1847   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 /  5 * 100 = 20%
1848   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1849   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1850
1851   // Check signals have not fired
1852   application.SendNotification();
1853   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1854   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1855   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1856
1857   application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1858   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 /  5 * 100 = 40%
1859   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1860   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1861
1862   // Check signals have not fired
1863   application.SendNotification();
1864   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1865   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1866   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1867
1868   application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1869   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 /  5 * 100 = 60%
1870   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1871   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1872
1873   // Check signals have not fired
1874   application.SendNotification();
1875   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1876   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1877   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1878
1879   application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1880   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 /  5 * 100 = 80%
1881   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1882   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1883
1884   // Check signals have not fired
1885   application.SendNotification();
1886   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1887   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1888   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1889
1890   application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1891   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // 5 /  5 * 100 = 100%
1892   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1893   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1894
1895   // Check signals have not fired
1896   application.SendNotification();
1897   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1898   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1899   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1900
1901   application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1902   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100% (signal 1 should fire)
1903   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1904   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1905
1906   // 1st signal should have fired
1907   application.SendNotification();
1908   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1909   wasConstraintCallbackCalled1 = false;
1910   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1911   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1912
1913   application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1914   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1915   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1916   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize,       TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1917
1918   // Check signals have not fired
1919   application.SendNotification();
1920   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1921   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1922   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1923
1924   application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1925   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1926   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1927   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100% (signal 3 should fire)
1928
1929   // 3rd signal should have fired
1930   application.SendNotification();
1931
1932   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1933   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1934   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
1935   wasConstraintCallbackCalled3 = false;
1936
1937   application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
1938   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1939   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
1940   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1941
1942   // Check signals have not fired
1943   application.SendNotification();
1944   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1945   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1946   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1947
1948   application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
1949   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1950   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100% (signal 2 should fire)
1951   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize,       TEST_LOCATION ); // Past 100%
1952
1953   // 2nd signal should have fired
1954   application.SendNotification();
1955   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1956   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
1957   wasConstraintCallbackCalled2 = false;
1958   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1959
1960   // Check that nothing has changed after a couple of buffer swaps
1961
1962   application.Render(0);
1963   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
1964   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
1965   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
1966
1967   application.SendNotification();
1968   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1969   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1970   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1971
1972   application.Render(0);
1973   DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
1974   DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
1975   DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
1976
1977   application.SendNotification();
1978   DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1979   DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1980   DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1981   END_TEST;
1982 }
1983
1984 int UtcDaliActorRemoveConstraints(void)
1985 {
1986   tet_infoline(" UtcDaliActorRemoveConstraints");
1987   TestApplication application;
1988
1989   gTestConstraintCalled = false;
1990
1991   Actor actor = Actor::New();
1992
1993   Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1994   actor.ApplyConstraint(constraint);
1995   actor.RemoveConstraints();
1996
1997   DALI_TEST_CHECK( gTestConstraintCalled == false );
1998
1999   Stage::GetCurrent().Add( actor );
2000   actor.ApplyConstraint(constraint);
2001
2002   // flush the queue and render once
2003   application.SendNotification();
2004   application.Render();
2005
2006   actor.RemoveConstraints();
2007
2008   DALI_TEST_CHECK( gTestConstraintCalled == true );
2009   END_TEST;
2010 }
2011
2012 int UtcDaliActorRemoveConstraint(void)
2013 {
2014   tet_infoline(" UtcDaliActorRemoveConstraint");
2015   TestApplication application;
2016
2017   Actor actor = Actor::New();
2018
2019   // 1. Apply Constraint1 and Constraint2, and test...
2020   unsigned int result1 = 0u;
2021   unsigned int result2 = 0u;
2022   ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2023   ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2024
2025   Stage::GetCurrent().Add( actor );
2026   // flush the queue and render once
2027   application.SendNotification();
2028   application.Render();
2029
2030   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2031   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2032
2033   // 2. Remove Constraint1 and test...
2034   result1 = 0;
2035   result2 = 0;
2036   actor.RemoveConstraint(activeConstraint1);
2037   // make color property dirty, which will trigger constraints to be reapplied.
2038   actor.SetColor( Color::WHITE );
2039   // flush the queue and render once
2040   application.SendNotification();
2041   application.Render();
2042
2043   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2044   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2045
2046   // 3. Re-Apply Constraint1 and test...
2047   result1 = 0;
2048   result2 = 0;
2049   activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2050   // make color property dirty, which will trigger constraints to be reapplied.
2051   actor.SetColor( Color::WHITE );
2052   // flush the queue and render once
2053   application.SendNotification();
2054   application.Render();
2055
2056   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2057   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2058
2059   // 2. Remove Constraint2 and test...
2060   result1 = 0;
2061   result2 = 0;
2062   actor.RemoveConstraint(activeConstraint2);
2063   // make color property dirty, which will trigger constraints to be reapplied.
2064   actor.SetColor( Color::WHITE );
2065   // flush the queue and render once
2066   application.SendNotification();
2067   application.Render();
2068
2069   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2070   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2071
2072   // 2. Remove Constraint1 as well and test...
2073   result1 = 0;
2074   result2 = 0;
2075   actor.RemoveConstraint(activeConstraint1);
2076   // make color property dirty, which will trigger constraints to be reapplied.
2077   actor.SetColor( Color::WHITE );
2078   // flush the queue and render once
2079   application.SendNotification();
2080   application.Render();
2081
2082   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2083   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2084   END_TEST;
2085 }
2086
2087 int UtcDaliActorRemoveConstraintTag(void)
2088 {
2089   tet_infoline(" UtcDaliActorRemoveConstraintTag");
2090   TestApplication application;
2091
2092   Actor actor = Actor::New();
2093
2094   // 1. Apply Constraint1 and Constraint2, and test...
2095   unsigned int result1 = 0u;
2096   unsigned int result2 = 0u;
2097
2098   unsigned constraint1Tag = 1u;
2099   Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2100   constraint1.SetTag( constraint1Tag );
2101   actor.ApplyConstraint( constraint1 );
2102
2103   unsigned constraint2Tag = 2u;
2104   Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2105   constraint2.SetTag( constraint2Tag );
2106   actor.ApplyConstraint( constraint2 );
2107
2108   Stage::GetCurrent().Add( actor );
2109   // flush the queue and render once
2110   application.SendNotification();
2111   application.Render();
2112
2113   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2114   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2115
2116   // 2. Remove Constraint1 and test...
2117   result1 = 0;
2118   result2 = 0;
2119   actor.RemoveConstraints(constraint1Tag);
2120   // make color property dirty, which will trigger constraints to be reapplied.
2121   actor.SetColor( Color::WHITE );
2122   // flush the queue and render once
2123   application.SendNotification();
2124   application.Render();
2125
2126   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION );  ///< constraint 1 should not apply now.
2127   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2128
2129   // 3. Re-Apply Constraint1 and test...
2130   result1 = 0;
2131   result2 = 0;
2132   actor.ApplyConstraint( constraint1 );
2133   // make color property dirty, which will trigger constraints to be reapplied.
2134   actor.SetColor( Color::WHITE );
2135   // flush the queue and render once
2136   application.SendNotification();
2137   application.Render();
2138
2139   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2140   DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2141
2142   // 2. Remove Constraint2 and test...
2143   result1 = 0;
2144   result2 = 0;
2145   actor.RemoveConstraints(constraint2Tag);
2146   // make color property dirty, which will trigger constraints to be reapplied.
2147   actor.SetColor( Color::WHITE );
2148   // flush the queue and render once
2149   application.SendNotification();
2150   application.Render();
2151
2152   DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2153   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2154
2155   // 2. Remove Constraint1 as well and test...
2156   result1 = 0;
2157   result2 = 0;
2158   actor.RemoveConstraints(constraint1Tag);
2159   // make color property dirty, which will trigger constraints to be reapplied.
2160   actor.SetColor( Color::WHITE );
2161   // flush the queue and render once
2162   application.SendNotification();
2163   application.Render();
2164
2165   DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2166   DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2167   END_TEST;
2168 }
2169
2170 int UtcDaliActorTouchedSignal(void)
2171 {
2172   TestApplication application;
2173
2174   gTouchCallBackCalled = false;
2175
2176   // get the root layer
2177   Actor actor = Stage::GetCurrent().GetRootLayer();
2178   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2179
2180   application.SendNotification();
2181   application.Render();
2182
2183   // connect to its touch signal
2184   actor.TouchedSignal().Connect( TestCallback );
2185
2186   // simulate a touch event in the middle of the screen
2187   Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2188   Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2189   Dali::Integration::TouchEvent event;
2190   event.AddPoint( point );
2191   application.ProcessEvent( event );
2192
2193   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2194   END_TEST;
2195 }
2196
2197
2198 int UtcDaliActorSetSizeSignal(void)
2199 {
2200   TestApplication application;
2201
2202   Actor actor = Actor::New();
2203   actor.SetSizeSignal().Connect( SetSizeCallback );
2204
2205   gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2206   gSetSizeCallBackCalled = false;
2207   Vector2 size2d( 1.0f, 2.0f );
2208   actor.SetSize( size2d );
2209   DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2210   // SetSize with Vector2 sets depth to be the minimum of width & height
2211   DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize,  TEST_LOCATION );
2212
2213   gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2214   gSetSizeCallBackCalled = false;
2215   actor.SetSize( 22.0f, 11.0f );
2216   DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2217   // SetSize with Vector2 sets depth to be the minimum of width & height
2218   DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize,  TEST_LOCATION );
2219
2220   gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2221   gSetSizeCallBackCalled = false;
2222   Vector3 size( 3.0f, 4.0f, 5.0f );
2223   actor.SetSize( size );
2224   DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2225   DALI_TEST_EQUALS( size, gSetSize,  TEST_LOCATION );
2226
2227   // add actor to stage to see that signal still works
2228   Stage::GetCurrent().Add( actor );
2229
2230   gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2231   gSetSizeCallBackCalled = false;
2232   actor.SetSize( -1.0f, -2.0f, -3.0f );
2233   DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2234   DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize,  TEST_LOCATION );
2235   END_TEST;
2236 }
2237
2238 int UtcDaliActorOnOffStageSignal(void)
2239 {
2240   tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2241
2242   TestApplication application;
2243
2244   // clean test data
2245   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2246   gActorNamesOnOffStage.clear();
2247
2248   Actor parent = Actor::New();
2249   parent.SetName( "parent" );
2250   parent.OnStageSignal().Connect( OnStageCallback );
2251   parent.OffStageSignal().Connect( OffStageCallback );
2252   // sanity check
2253   DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2254   DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2255
2256   // add parent to stage
2257   Stage::GetCurrent().Add( parent );
2258   // onstage emitted, offstage not
2259   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2260   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2261   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2262
2263   // test adding a child, should get onstage emitted
2264   // clean test data
2265   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2266   gActorNamesOnOffStage.clear();
2267
2268   Actor child = Actor::New();
2269   child.SetName( "child" );
2270   child.OnStageSignal().Connect( OnStageCallback );
2271   child.OffStageSignal().Connect( OffStageCallback );
2272   parent.Add( child ); // add child
2273   // onstage emitted, offstage not
2274   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 1, TEST_LOCATION );
2275   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2276   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2277
2278   // test removing parent from stage
2279   // clean test data
2280   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2281   gActorNamesOnOffStage.clear();
2282
2283   Stage::GetCurrent().Remove( parent );
2284   // onstage not emitted, offstage is
2285   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2286   DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2287   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2288   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2289
2290   // test adding parent back to stage
2291   // clean test data
2292   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2293   gActorNamesOnOffStage.clear();
2294
2295   Stage::GetCurrent().Add( parent );
2296   // onstage emitted, offstage not
2297   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 2, TEST_LOCATION );
2298   DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2299   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2300   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2301
2302   // test removing child
2303   // clean test data
2304   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2305   gActorNamesOnOffStage.clear();
2306
2307   parent.Remove( child );
2308   // onstage not emitted, offstage is
2309   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2310   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2311   DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2312
2313   // test removing parent
2314   // clean test data
2315   gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2316   gActorNamesOnOffStage.clear();
2317
2318   Stage::GetCurrent().Remove( parent );
2319   // onstage not emitted, offstage is
2320   DALI_TEST_EQUALS(  gOnStageCallBackCalled, 0, TEST_LOCATION );
2321   DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2322   DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2323   END_TEST;
2324 }
2325
2326 int UtcDaliActorFindChildByName(void)
2327 {
2328   tet_infoline("Testing Dali::Actor::FindChildByName()");
2329   TestApplication application;
2330
2331   Actor parent = Actor::New();
2332   parent.SetName( "parent" );
2333   Actor first  = Actor::New();
2334   first .SetName( "first" );
2335   Actor second = Actor::New();
2336   second.SetName( "second" );
2337
2338   parent.Add(first);
2339   first.Add(second);
2340
2341   Actor found = parent.FindChildByName( "foo" );
2342   DALI_TEST_CHECK( !found );
2343
2344   found = parent.FindChildByName( "parent" );
2345   DALI_TEST_CHECK( found == parent );
2346
2347   found = parent.FindChildByName( "first" );
2348   DALI_TEST_CHECK( found == first );
2349
2350   found = parent.FindChildByName( "second" );
2351   DALI_TEST_CHECK( found == second );
2352   END_TEST;
2353 }
2354
2355 int UtcDaliActorFindChildByAlias(void)
2356 {
2357   tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2358   TestApplication application;
2359
2360   Actor parent = Actor::New();
2361   parent.SetName( "parent" );
2362   Actor first  = Actor::New();
2363   first .SetName( "first" );
2364   Actor second = Actor::New();
2365   second.SetName( "second" );
2366
2367   parent.Add(first);
2368   first.Add(second);
2369
2370   Actor found = parent.FindChildByAlias( "foo" );
2371   DALI_TEST_CHECK( !found );
2372
2373   found = parent.FindChildByAlias( "parent" );
2374   DALI_TEST_CHECK( found == parent );
2375
2376   found = parent.FindChildByAlias( "first" );
2377   DALI_TEST_CHECK( found == first );
2378
2379   found = parent.FindChildByAlias( "second" );
2380   DALI_TEST_CHECK( found == second );
2381   END_TEST;
2382 }
2383
2384 int UtcDaliActorFindChildById(void)
2385 {
2386   tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2387   TestApplication application;
2388
2389   Actor parent = Actor::New();
2390   Actor first  = Actor::New();
2391   Actor second = Actor::New();
2392
2393   parent.Add(first);
2394   first.Add(second);
2395
2396   Actor found = parent.FindChildById( 100000 );
2397   DALI_TEST_CHECK( !found );
2398
2399   found = parent.FindChildById( parent.GetId() );
2400   DALI_TEST_CHECK( found == parent );
2401
2402   found = parent.FindChildById( first.GetId() );
2403   DALI_TEST_CHECK( found == first );
2404
2405   found = parent.FindChildById( second.GetId() );
2406   DALI_TEST_CHECK( found == second );
2407   END_TEST;
2408 }
2409
2410 int UtcDaliActorHitTest(void)
2411 {
2412   struct HitTestData
2413   {
2414   public:
2415     HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2416     : mScale( scale ),
2417       mTouchPoint( touchPoint ),
2418       mResult( result )
2419     {}
2420
2421     Vector3 mScale;
2422     Vector2 mTouchPoint;
2423     bool mResult;
2424   };
2425
2426   TestApplication application;
2427   tet_infoline(" UtcDaliActorHitTest");
2428
2429   // Fill a vector with different hit tests.
2430   struct HitTestData* hitTestData[] = {
2431     //                    scale                     touch point           result
2432     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ),  // touch point close to the right edge (inside)
2433     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2434     new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ),  // same point as above with a wider scale. Should be inside.
2435     new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2436     new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ),  // same point as above with a wider scale. Should be inside.
2437     NULL,
2438   };
2439
2440   // get the root layer
2441   Actor actor = Actor::New();
2442   actor.SetAnchorPoint( AnchorPoint::CENTER );
2443   actor.SetParentOrigin( ParentOrigin::CENTER );
2444
2445   Stage::GetCurrent().Add( actor );
2446
2447   gTouchCallBackCalled = false;
2448
2449   unsigned int index = 0;
2450   while( NULL != hitTestData[index] )
2451   {
2452     actor.SetSize( 1.f, 1.f );
2453     actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2454
2455     // flush the queue and render once
2456     application.SendNotification();
2457     application.Render();
2458
2459     DALI_TEST_CHECK( !gTouchCallBackCalled );
2460
2461     // connect to its touch signal
2462     actor.TouchedSignal().Connect(TestCallback);
2463
2464     Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2465     Dali::Integration::TouchEvent event;
2466     event.AddPoint( point );
2467
2468     // flush the queue and render once
2469     application.SendNotification();
2470     application.Render();
2471     application.ProcessEvent( event );
2472
2473     DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2474
2475     if( gTouchCallBackCalled != hitTestData[index]->mResult )
2476       tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2477                  hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2478                  hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2479                  hitTestData[index]->mResult );
2480
2481     gTouchCallBackCalled = false;
2482     ++index;
2483   }
2484   END_TEST;
2485 }
2486
2487 int UtcDaliActorSetDrawMode(void)
2488 {
2489   TestApplication app;
2490   tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2491
2492   Actor a = Actor::New();
2493
2494   Stage::GetCurrent().Add(a);
2495   app.SendNotification();
2496   app.Render(0);
2497   app.SendNotification();
2498   app.Render(1);
2499
2500   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2501
2502   a.SetDrawMode( DrawMode::OVERLAY );
2503   app.SendNotification();
2504   app.Render(1);
2505
2506   DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2507
2508   a.SetDrawMode( DrawMode::STENCIL );
2509   app.SendNotification();
2510   app.Render(1);
2511
2512   DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2513
2514   a.SetDrawMode( DrawMode::NORMAL );
2515   app.SendNotification();
2516   app.Render(1);
2517
2518   DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2519   END_TEST;
2520 }
2521
2522 int UtcDaliActorSetDrawModeOverlayRender(void)
2523 {
2524   TestApplication app;
2525   tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2526
2527   app.SendNotification();
2528   app.Render(1);
2529
2530   std::vector<GLuint> ids;
2531   ids.push_back( 8 );   // first rendered actor
2532   ids.push_back( 9 );   // second rendered actor
2533   ids.push_back( 10 );  // third rendered actor
2534   app.GetGlAbstraction().SetNextTextureIds( ids );
2535
2536   BitmapImage imageA = BitmapImage::New(16, 16);
2537   BitmapImage imageB = BitmapImage::New(16, 16);
2538   BitmapImage imageC = BitmapImage::New(16, 16);
2539   ImageActor a = ImageActor::New( imageA );
2540   ImageActor b = ImageActor::New( imageB );
2541   ImageActor c = ImageActor::New( imageC );
2542
2543   // Render a,b,c as regular non-overlays. so order will be:
2544   // a (8)
2545   // b (9)
2546   // c (10)
2547   Stage::GetCurrent().Add(a);
2548   Stage::GetCurrent().Add(b);
2549   Stage::GetCurrent().Add(c);
2550
2551   app.SendNotification();
2552   app.Render(1);
2553
2554   // Should be 3 textures changes.
2555   const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2556   typedef std::vector<GLuint>::size_type TextureSize;
2557   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2558   if( boundTextures.size() == 3 )
2559   {
2560     DALI_TEST_CHECK( boundTextures[0] == 8u );
2561     DALI_TEST_CHECK( boundTextures[1] == 9u );
2562     DALI_TEST_CHECK( boundTextures[2] == 10u );
2563   }
2564
2565   // Now texture ids have been set, we can monitor their render order.
2566   // render a as an overlay (last), so order will be:
2567   // b (9)
2568   // c (10)
2569   // a (8)
2570   a.SetDrawMode( DrawMode::OVERLAY );
2571   app.GetGlAbstraction().ClearBoundTextures();
2572
2573   app.SendNotification();
2574   app.Render(1);
2575
2576   // Should be 3 texture changes.
2577   DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2578   if( boundTextures.size() == 3 )
2579   {
2580     DALI_TEST_CHECK( boundTextures[0] == 9u );
2581     DALI_TEST_CHECK( boundTextures[1] == 10u );
2582     DALI_TEST_CHECK( boundTextures[2] == 8u );
2583   }
2584   END_TEST;
2585 }
2586
2587
2588 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2589 {
2590   TestApplication app;
2591   tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2592
2593   BitmapImage imageA = BitmapImage::New(16, 16);
2594   BitmapImage imageB = BitmapImage::New(16, 16);
2595   ImageActor a = ImageActor::New( imageA );
2596   ImageActor b = ImageActor::New( imageB );
2597
2598   // Render a,b as regular non-overlays. so order will be:
2599   Stage::GetCurrent().Add(a);
2600   Stage::GetCurrent().Add(b);
2601
2602   a.SetSize(Vector2(100.0f, 100.0f));
2603   b.SetSize(Vector2(100.0f, 100.0f));
2604
2605   // position b overlapping a. (regular non-overlays)
2606   // hit test at point 'x'
2607   // --------
2608   // |      |
2609   // | a    |
2610   // |   --------
2611   // |   |x     |
2612   // |   |      |
2613   // ----|      |
2614   //     |   b  |
2615   //     |      |
2616   //     --------
2617   // note: b is on top, because it's Z position is higher.
2618   a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2619   b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2620
2621   // connect to their touch signals
2622   a.TouchedSignal().Connect(TestCallback);
2623   b.TouchedSignal().Connect(TestCallback2);
2624
2625   a.SetDrawMode( DrawMode::NORMAL );
2626   b.SetDrawMode( DrawMode::NORMAL );
2627   SimulateTouchForSetOverlayHitTest(app);
2628
2629   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2630   DALI_TEST_CHECK( gTouchCallBack2Called == true );
2631   // Make Actor a an overlay.
2632   // --------
2633   // |      |
2634   // | a    |
2635   // |      |----
2636   // |    x |   |
2637   // |      |   |
2638   // --------   |
2639   //     |   b  |
2640   //     |      |
2641   //     --------
2642   // note: a is on top, because it is an overlay.
2643   a.SetDrawMode( DrawMode::OVERLAY );
2644   b.SetDrawMode( DrawMode::NORMAL );
2645   SimulateTouchForSetOverlayHitTest(app);
2646
2647   DALI_TEST_CHECK( gTouchCallBackCalled == true );
2648   DALI_TEST_CHECK( gTouchCallBack2Called == false );
2649   // Make both Actors as overlays
2650   // --------
2651   // |      |
2652   // | a    |
2653   // |   --------
2654   // |   |x     |
2655   // |   |      |
2656   // ----|      |
2657   //     |   b  |
2658   //     |      |
2659   //     --------
2660   // note: b is on top, because it is the 2nd child in the hierarchy.
2661   a.SetDrawMode( DrawMode::OVERLAY );
2662   b.SetDrawMode( DrawMode::OVERLAY );
2663   SimulateTouchForSetOverlayHitTest(app);
2664
2665   DALI_TEST_CHECK( gTouchCallBackCalled == false );
2666   DALI_TEST_CHECK( gTouchCallBack2Called == true );
2667   END_TEST;
2668 }
2669
2670 int UtcDaliActorGetCurrentWorldMatrix(void)
2671 {
2672   TestApplication app;
2673   tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2674
2675   Actor parent = Actor::New();
2676   parent.SetParentOrigin(ParentOrigin::CENTER);
2677   parent.SetAnchorPoint(AnchorPoint::CENTER);
2678   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2679   Radian rotationAngle(Degree(85.0f));
2680   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2681   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2682   parent.SetPosition( parentPosition );
2683   parent.SetRotation( parentRotation );
2684   parent.SetScale( parentScale );
2685   Stage::GetCurrent().Add( parent );
2686
2687   Actor child = Actor::New();
2688   child.SetParentOrigin(ParentOrigin::CENTER);
2689   Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2690   Radian childRotationAngle(Degree(23.0f));
2691   Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2692   Vector3 childScale( 2.0f, 2.0f, 2.0f );
2693   child.SetPosition( childPosition );
2694   child.SetRotation( childRotation );
2695   child.SetScale( childScale );
2696   parent.Add( child );
2697
2698   // The actors should not have a world matrix yet
2699   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2700   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2701
2702   app.SendNotification();
2703   app.Render(0);
2704   app.Render();
2705   app.SendNotification();
2706
2707   Matrix parentMatrix(false);
2708   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2709
2710   Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2711   Quaternion childWorldRotation = parentRotation * childRotation;
2712   Vector3 childWorldScale = parentScale * childScale;
2713
2714   Matrix childWorldMatrix(false);
2715   childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2716
2717   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2718   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2719   END_TEST;
2720 }
2721
2722
2723
2724 int UtcDaliActorConstrainedToWorldMatrix(void)
2725 {
2726   TestApplication app;
2727   tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2728
2729   Actor parent = Actor::New();
2730   parent.SetParentOrigin(ParentOrigin::CENTER);
2731   parent.SetAnchorPoint(AnchorPoint::CENTER);
2732   Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2733   Radian rotationAngle(Degree(85.0f));
2734   Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2735   Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2736   parent.SetPosition( parentPosition );
2737   parent.SetRotation( parentRotation );
2738   parent.SetScale( parentScale );
2739   Stage::GetCurrent().Add( parent );
2740
2741   Actor child = Actor::New();
2742   child.SetParentOrigin(ParentOrigin::CENTER);
2743   Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2744   child.ApplyConstraint(posConstraint);
2745
2746   Stage::GetCurrent().Add( child );
2747
2748   // The actors should not have a world matrix yet
2749   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2750   DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2751
2752   app.SendNotification();
2753   app.Render(0);
2754   app.Render();
2755   app.SendNotification();
2756
2757   Matrix parentMatrix(false);
2758   parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2759
2760   DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2761   DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2762   END_TEST;
2763 }
2764
2765 int UtcDaliActorUnparent(void)
2766 {
2767   TestApplication app;
2768   tet_infoline(" UtcDaliActorUnparent");
2769
2770   Actor parent = Actor::New();
2771   Stage::GetCurrent().Add( parent );
2772
2773   Actor child = Actor::New();
2774
2775   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2776   DALI_TEST_CHECK( !child.GetParent() );
2777
2778   // Test that calling Unparent with no parent is a NOOP
2779   child.Unparent();
2780
2781   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2782   DALI_TEST_CHECK( !child.GetParent() );
2783
2784   // Test that Unparent works
2785   parent.Add( child );
2786
2787   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2788   DALI_TEST_CHECK( parent == child.GetParent() );
2789
2790   child.Unparent();
2791
2792   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2793   DALI_TEST_CHECK( !child.GetParent() );
2794
2795   // Test that UnparentAndReset works
2796   parent.Add( child );
2797
2798   DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2799   DALI_TEST_CHECK( parent == child.GetParent() );
2800
2801   UnparentAndReset( child );
2802
2803   DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2804   DALI_TEST_CHECK( !child );
2805
2806   // Test that UnparentAndReset is a NOOP with empty handle
2807   UnparentAndReset( child );
2808
2809   DALI_TEST_CHECK( !child );
2810   END_TEST;
2811 }
2812
2813 int UtcDaliActorGetChildAt(void)
2814 {
2815   TestApplication app;
2816   tet_infoline(" UtcDaliActorGetChildAt");
2817
2818   Actor parent = Actor::New();
2819   Stage::GetCurrent().Add( parent );
2820
2821   Actor child0 = Actor::New();
2822   parent.Add( child0 );
2823
2824   Actor child1 = Actor::New();
2825   parent.Add( child1 );
2826
2827   Actor child2 = Actor::New();
2828   parent.Add( child2 );
2829
2830   DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2831   DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2832   DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2833   END_TEST;
2834 }
2835
2836 int UtcDaliActorSetGetOverlay(void)
2837 {
2838   TestApplication app;
2839   tet_infoline(" UtcDaliActorSetGetOverlay");
2840
2841   Actor parent = Actor::New();
2842   parent.SetDrawMode(DrawMode::OVERLAY );
2843   DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2844   END_TEST;
2845 }
2846
2847
2848 // Current Dynamics functions are crashing, so testing these sections are futile
2849
2850 int UtcDaliActorDynamics(void)
2851 {
2852   DALI_TEST_CHECK( true );
2853   END_TEST;
2854 }
2855
2856 int UtcDaliActorCreateDestroy(void)
2857 {
2858   Actor* actor = new Actor;
2859   DALI_TEST_CHECK( actor );
2860   delete actor;
2861   END_TEST;
2862 }
2863
2864 namespace
2865 {
2866 struct PropertyStringIndex
2867 {
2868   const char * const name;
2869   const Property::Index index;
2870   const Property::Type type;
2871 };
2872
2873 const PropertyStringIndex PROPERTY_TABLE[] =
2874 {
2875   { "parent-origin",            Actor::PARENT_ORIGIN,           Property::VECTOR3     },
2876   { "parent-origin-x",          Actor::PARENT_ORIGIN_X,         Property::FLOAT       },
2877   { "parent-origin-y",          Actor::PARENT_ORIGIN_Y,         Property::FLOAT       },
2878   { "parent-origin-z",          Actor::PARENT_ORIGIN_Z,         Property::FLOAT       },
2879   { "anchor-point",             Actor::ANCHOR_POINT,            Property::VECTOR3     },
2880   { "anchor-point-x",           Actor::ANCHOR_POINT_X,          Property::FLOAT       },
2881   { "anchor-point-y",           Actor::ANCHOR_POINT_Y,          Property::FLOAT       },
2882   { "anchor-point-z",           Actor::ANCHOR_POINT_Z,          Property::FLOAT       },
2883   { "size",                     Actor::SIZE,                    Property::VECTOR3     },
2884   { "size-width",               Actor::SIZE_WIDTH,              Property::FLOAT       },
2885   { "size-height",              Actor::SIZE_HEIGHT,             Property::FLOAT       },
2886   { "size-depth",               Actor::SIZE_DEPTH,              Property::FLOAT       },
2887   { "position",                 Actor::POSITION,                Property::VECTOR3     },
2888   { "position-x",               Actor::POSITION_X,              Property::FLOAT       },
2889   { "position-y",               Actor::POSITION_Y,              Property::FLOAT       },
2890   { "position-z",               Actor::POSITION_Z,              Property::FLOAT       },
2891   { "world-position",           Actor::WORLD_POSITION,          Property::VECTOR3     },
2892   { "world-position-x",         Actor::WORLD_POSITION_X,        Property::FLOAT       },
2893   { "world-position-y",         Actor::WORLD_POSITION_Y,        Property::FLOAT       },
2894   { "world-position-z",         Actor::WORLD_POSITION_Z,        Property::FLOAT       },
2895   { "rotation",                 Actor::ROTATION,                Property::ROTATION    },
2896   { "world-rotation",           Actor::WORLD_ROTATION,          Property::ROTATION    },
2897   { "scale",                    Actor::SCALE,                   Property::VECTOR3     },
2898   { "scale-x",                  Actor::SCALE_X,                 Property::FLOAT       },
2899   { "scale-y",                  Actor::SCALE_Y,                 Property::FLOAT       },
2900   { "scale-z",                  Actor::SCALE_Z,                 Property::FLOAT       },
2901   { "world-scale",              Actor::WORLD_SCALE,             Property::VECTOR3     },
2902   { "visible",                  Actor::VISIBLE,                 Property::BOOLEAN     },
2903   { "color",                    Actor::COLOR,                   Property::VECTOR4     },
2904   { "color-red",                Actor::COLOR_RED,               Property::FLOAT       },
2905   { "color-green",              Actor::COLOR_GREEN,             Property::FLOAT       },
2906   { "color-blue",               Actor::COLOR_BLUE,              Property::FLOAT       },
2907   { "color-alpha",              Actor::COLOR_ALPHA,             Property::FLOAT       },
2908   { "world-color",              Actor::WORLD_COLOR,             Property::VECTOR4     },
2909   { "world-matrix",             Actor::WORLD_MATRIX,            Property::MATRIX      },
2910   { "name",                     Actor::NAME,                    Property::STRING      },
2911   { "sensitive",                Actor::SENSITIVE,               Property::BOOLEAN     },
2912   { "leave-required",           Actor::LEAVE_REQUIRED,          Property::BOOLEAN     },
2913   { "inherit-rotation",         Actor::INHERIT_ROTATION,        Property::BOOLEAN     },
2914   { "inherit-scale",            Actor::INHERIT_SCALE,           Property::BOOLEAN     },
2915   { "color-mode",               Actor::COLOR_MODE,              Property::STRING      },
2916   { "position-inheritance",     Actor::POSITION_INHERITANCE,    Property::STRING      },
2917   { "draw-mode",                Actor::DRAW_MODE,               Property::STRING      },
2918 };
2919 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2920 } // unnamed namespace
2921
2922 int UtcDaliActorProperties(void)
2923 {
2924   TestApplication app;
2925
2926   Actor actor = Actor::New();
2927
2928   for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2929   {
2930     tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2931     DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2932     DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2933     DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2934   }
2935   END_TEST;
2936 }