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