2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali-test-suite-utils.h>
30 static void Startup();
31 static void Cleanup();
34 void (*tet_startup)() = Startup;
35 void (*tet_cleanup)() = Cleanup;
39 POSITIVE_TC_IDX = 0x01,
43 #define MAX_NUMBER_OF_TESTS 10000
45 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
48 // Add test functionality for all APIs in the class (Positive and Negative)
49 TEST_FUNCTION( UtcDaliActorNew, POSITIVE_TC_IDX );
50 TEST_FUNCTION( UtcDaliActorDownCast, POSITIVE_TC_IDX );
51 TEST_FUNCTION( UtcDaliActorDownCast2, NEGATIVE_TC_IDX );
52 TEST_FUNCTION( UtcDaliActorGetName, POSITIVE_TC_IDX );
53 TEST_FUNCTION( UtcDaliActorSetName, POSITIVE_TC_IDX );
54 TEST_FUNCTION( UtcDaliActorGetId, POSITIVE_TC_IDX );
56 TEST_FUNCTION( UtcDaliActorIsRoot, POSITIVE_TC_IDX );
57 TEST_FUNCTION( UtcDaliActorOnStage, POSITIVE_TC_IDX );
58 TEST_FUNCTION( UtcDaliActorIsLayer, POSITIVE_TC_IDX );
59 TEST_FUNCTION( UtcDaliActorGetLayer, POSITIVE_TC_IDX ); // 10
61 TEST_FUNCTION( UtcDaliActorAdd, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliActorRemove01, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliActorRemove02, NEGATIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliActorGetChildCount, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliActorGetChildren01, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliActorGetChildren02, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliActorGetParent01, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliActorGetParent02, NEGATIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliActorSetParentOrigin, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliActorGetCurrentParentOrigin, POSITIVE_TC_IDX ); // 20
72 TEST_FUNCTION( UtcDaliActorSetAnchorPoint, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliActorGetCurrentAnchorPoint, POSITIVE_TC_IDX );
75 TEST_FUNCTION( UtcDaliActorSetSize01, POSITIVE_TC_IDX );
76 TEST_FUNCTION( UtcDaliActorSetSize02, POSITIVE_TC_IDX );
77 TEST_FUNCTION( UtcDaliActorSetSize03, POSITIVE_TC_IDX );
78 TEST_FUNCTION( UtcDaliActorSetSize04, POSITIVE_TC_IDX );
79 TEST_FUNCTION( UtcDaliActorGetCurrentSize, POSITIVE_TC_IDX );
81 TEST_FUNCTION( UtcDaliActorSetPosition01, POSITIVE_TC_IDX );
82 TEST_FUNCTION( UtcDaliActorSetPosition02, POSITIVE_TC_IDX );
83 TEST_FUNCTION( UtcDaliActorSetPosition03, POSITIVE_TC_IDX ); // 30
84 TEST_FUNCTION( UtcDaliActorSetX, POSITIVE_TC_IDX );
85 TEST_FUNCTION( UtcDaliActorSetY, POSITIVE_TC_IDX );
86 TEST_FUNCTION( UtcDaliActorSetZ, POSITIVE_TC_IDX );
87 TEST_FUNCTION( UtcDaliActorMoveBy, POSITIVE_TC_IDX );
88 TEST_FUNCTION( UtcDaliActorGetCurrentPosition, POSITIVE_TC_IDX );
89 TEST_FUNCTION( UtcDaliActorGetCurrentWorldPosition, POSITIVE_TC_IDX );
90 TEST_FUNCTION( UtcDaliActorInheritPosition, POSITIVE_TC_IDX );
92 TEST_FUNCTION( UtcDaliActorSetRotation01, POSITIVE_TC_IDX );
93 TEST_FUNCTION( UtcDaliActorSetRotation02, POSITIVE_TC_IDX );
94 TEST_FUNCTION( UtcDaliActorRotateBy01, POSITIVE_TC_IDX ); // 40
95 TEST_FUNCTION( UtcDaliActorRotateBy02, POSITIVE_TC_IDX );
96 TEST_FUNCTION( UtcDaliActorGetCurrentRotation, POSITIVE_TC_IDX );
97 TEST_FUNCTION( UtcDaliActorGetCurrentWorldRotation, POSITIVE_TC_IDX );
99 TEST_FUNCTION( UtcDaliActorSetScale01, POSITIVE_TC_IDX );
100 TEST_FUNCTION( UtcDaliActorSetScale02, POSITIVE_TC_IDX );
101 TEST_FUNCTION( UtcDaliActorSetScale03, POSITIVE_TC_IDX );
102 TEST_FUNCTION( UtcDaliActorScaleBy, POSITIVE_TC_IDX );
103 TEST_FUNCTION( UtcDaliActorGetCurrentScale, POSITIVE_TC_IDX );
104 TEST_FUNCTION( UtcDaliActorGetCurrentWorldScale, POSITIVE_TC_IDX );
105 TEST_FUNCTION( UtcDaliActorInheritScale, POSITIVE_TC_IDX ); // 50
107 TEST_FUNCTION( UtcDaliActorSetVisible, POSITIVE_TC_IDX );
108 TEST_FUNCTION( UtcDaliActorIsVisible, POSITIVE_TC_IDX );
109 TEST_FUNCTION( UtcDaliActorSetOpacity, POSITIVE_TC_IDX );
110 TEST_FUNCTION( UtcDaliActorGetCurrentOpacity, POSITIVE_TC_IDX );
112 TEST_FUNCTION( UtcDaliActorSetSensitive, POSITIVE_TC_IDX );
113 TEST_FUNCTION( UtcDaliActorIsSensitive, POSITIVE_TC_IDX );
115 TEST_FUNCTION( UtcDaliActorSetInheritShaderEffect, POSITIVE_TC_IDX );
116 TEST_FUNCTION( UtcDaliActorGetInheritShaderEffect, POSITIVE_TC_IDX );
118 TEST_FUNCTION( UtcDaliActorSetShaderEffect, POSITIVE_TC_IDX );
119 TEST_FUNCTION( UtcDaliActorGetShaderEffect, POSITIVE_TC_IDX ); // 60
120 TEST_FUNCTION( UtcDaliActorRemoveShaderEffect01, POSITIVE_TC_IDX );
121 TEST_FUNCTION( UtcDaliActorRemoveShaderEffect02, NEGATIVE_TC_IDX );
123 TEST_FUNCTION( UtcDaliActorSetColor, POSITIVE_TC_IDX );
124 TEST_FUNCTION( UtcDaliActorGetCurrentColor, POSITIVE_TC_IDX );
125 TEST_FUNCTION( UtcDaliActorSetColorMode, POSITIVE_TC_IDX );
126 TEST_FUNCTION( UtcDaliActorGetCurrentWorldColor, POSITIVE_TC_IDX );
128 TEST_FUNCTION( UtcDaliActorScreenToLocal, POSITIVE_TC_IDX );
129 TEST_FUNCTION( UtcDaliActorSetLeaveRequired, POSITIVE_TC_IDX );
130 TEST_FUNCTION( UtcDaliActorGetLeaveRequired, POSITIVE_TC_IDX );
132 TEST_FUNCTION( UtcDaliActorSetKeyboardFocusable, POSITIVE_TC_IDX ); // 70
133 TEST_FUNCTION( UtcDaliActorIsKeyboardFocusable, POSITIVE_TC_IDX );
135 TEST_FUNCTION( UtcDaliActorApplyConstraint, POSITIVE_TC_IDX );
136 TEST_FUNCTION( UtcDaliActorApplyConstraintAppliedCallback, POSITIVE_TC_IDX );
137 TEST_FUNCTION( UtcDaliActorRemoveConstraints, POSITIVE_TC_IDX );
138 TEST_FUNCTION( UtcDaliActorRemoveConstraint, POSITIVE_TC_IDX );
140 TEST_FUNCTION( UtcDaliActorTouchedSignal, POSITIVE_TC_IDX );
141 TEST_FUNCTION( UtcDaliActorSetSizeSignal, POSITIVE_TC_IDX );
142 TEST_FUNCTION( UtcDaliActorOnOffStageSignal, POSITIVE_TC_IDX );
144 TEST_FUNCTION( UtcDaliActorFindChildByName, POSITIVE_TC_IDX );
145 TEST_FUNCTION( UtcDaliActorFindChildByAlias, POSITIVE_TC_IDX ); // 80
146 TEST_FUNCTION( UtcDaliActorFindChildById, POSITIVE_TC_IDX );
148 TEST_FUNCTION( UtcDaliActorHitTest, POSITIVE_TC_IDX );
150 TEST_FUNCTION( UtcDaliActorSetDrawMode, POSITIVE_TC_IDX );
151 TEST_FUNCTION( UtcDaliActorSetDrawModeOverlayRender, POSITIVE_TC_IDX );
152 TEST_FUNCTION( UtcDaliActorSetDrawModeOverlayHitTest, POSITIVE_TC_IDX );
154 TEST_FUNCTION( UtcDaliActorGetCurrentWorldMatrix, POSITIVE_TC_IDX );
155 TEST_FUNCTION( UtcDaliActorConstrainedToWorldMatrix, POSITIVE_TC_IDX );
157 TEST_FUNCTION( UtcDaliActorUnparent, POSITIVE_TC_IDX );
159 TEST_FUNCTION( UtcDaliActorGetChildAt, POSITIVE_TC_IDX );
161 TEST_FUNCTION( UtcDaliActorSetGetOverlay, POSITIVE_TC_IDX );
163 TEST_FUNCTION( UtcDaliActorDynamics, POSITIVE_TC_IDX );
164 TEST_FUNCTION( UtcDaliActorCreateDestroy, POSITIVE_TC_IDX );
166 const char* vertexSource =
169 " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
170 " vTexCoord = aTexCoord;\n"
173 const char* fragmentSource =
176 " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
179 // Called only once before first test is run.
180 static void Startup()
182 // THERE IS NO MAINLOOP IN THE TEST APPLICATION
185 // Called only once after last test is run
186 static void Cleanup()
190 static void UtcDaliActorNew()
192 TestApplication application;
194 Actor actor = Actor::New();
196 DALI_TEST_CHECK(actor);
199 static void UtcDaliActorDownCast()
201 TestApplication application;
202 tet_infoline("Testing Dali::Actor::DownCast()");
204 Actor actor = Actor::New();
205 BaseHandle object(actor);
206 Actor actor2 = Actor::DownCast(object);
207 DALI_TEST_CHECK(actor2);
210 static void UtcDaliActorDownCast2()
212 TestApplication application;
213 tet_infoline("Testing Dali::Actor::DownCast()");
215 BaseHandle unInitializedObject;
216 Actor actor = Actor::DownCast(unInitializedObject);
217 DALI_TEST_CHECK(!actor);
220 static void UtcDaliActorGetName()
222 TestApplication application;
224 Actor actor = Actor::New();
226 DALI_TEST_CHECK(actor.GetName().empty());
229 static void UtcDaliActorSetName()
231 TestApplication application;
233 string str("ActorName");
234 Actor actor = Actor::New();
237 DALI_TEST_CHECK(actor.GetName() == str);
240 static void UtcDaliActorGetId()
242 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
243 TestApplication application;
245 Actor first = Actor::New();
246 Actor second = Actor::New();
247 Actor third = Actor::New();
249 DALI_TEST_CHECK(first.GetId() != second.GetId());
250 DALI_TEST_CHECK(second.GetId() != third.GetId());
253 static void UtcDaliActorIsRoot()
255 TestApplication application;
257 Actor actor = Actor::New();
258 DALI_TEST_CHECK(!actor.IsRoot());
260 // get the root layer
261 actor = Stage::GetCurrent().GetLayer( 0 );
262 DALI_TEST_CHECK( actor.IsRoot() );
265 static void UtcDaliActorOnStage()
267 TestApplication application;
269 Actor actor = Actor::New();
270 DALI_TEST_CHECK( !actor.OnStage() );
272 // get the root layer
273 actor = Stage::GetCurrent().GetLayer( 0 );
274 DALI_TEST_CHECK( actor.OnStage() );
277 static void UtcDaliActorIsLayer()
279 TestApplication application;
281 Actor actor = Actor::New();
282 DALI_TEST_CHECK( !actor.IsLayer() );
284 // get the root layer
285 actor = Stage::GetCurrent().GetLayer( 0 );
286 DALI_TEST_CHECK( actor.IsLayer() );
289 static void UtcDaliActorGetLayer()
291 TestApplication application;
293 Actor actor = Actor::New();
294 Stage::GetCurrent().Add(actor);
295 Layer layer = actor.GetLayer();
297 DALI_TEST_CHECK(layer);
299 // get the root layers layer
300 actor = Stage::GetCurrent().GetLayer( 0 );
301 DALI_TEST_CHECK( actor.GetLayer() );
304 static void UtcDaliActorAdd()
306 tet_infoline("Testing Actor::Add");
307 TestApplication application;
309 Actor parent = Actor::New();
310 Actor child = Actor::New();
312 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
316 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
318 Actor parent2 = Actor::New();
319 parent2.Add( child );
321 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
322 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
324 // try Adding to same parent again, works
325 parent2.Add( child );
326 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
328 // try reparenting an orphaned child
330 Actor temporaryParent = Actor::New();
331 temporaryParent.Add( child );
332 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
334 // temporaryParent has now died, reparent the orphaned child
335 parent2.Add( child );
336 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
341 parent2.Add( parent2 );
342 tet_printf("Assertion test failed - no Exception\n" );
343 tet_result(TET_FAIL);
345 catch(Dali::DaliException& e)
347 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
348 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
349 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
353 tet_printf("Assertion test failed - wrong Exception\n" );
354 tet_result(TET_FAIL);
357 // try reparenting root
360 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
361 tet_printf("Assertion test failed - no Exception\n" );
362 tet_result(TET_FAIL);
364 catch(Dali::DaliException& e)
366 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
367 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
368 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
372 tet_printf("Assertion test failed - wrong Exception\n" );
373 tet_result(TET_FAIL);
380 parent2.Add( empty );
381 tet_printf("Assertion test failed - no Exception\n" );
382 tet_result(TET_FAIL);
384 catch(Dali::DaliException& e)
386 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
387 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
388 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
392 tet_printf("Assertion test failed - wrong Exception\n" );
393 tet_result(TET_FAIL);
397 static void UtcDaliActorRemove01()
399 tet_infoline("Testing Actor::Remove");
400 TestApplication application;
402 Actor parent = Actor::New();
403 Actor child = Actor::New();
404 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
407 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
409 parent.Remove(child);
410 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
412 // remove again, no problem
413 parent.Remove(child);
414 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
418 // try illegal Remove
421 parent.Remove( parent );
422 tet_printf("Assertion test failed - no Exception\n" );
423 tet_result(TET_FAIL);
425 catch(Dali::DaliException& e)
427 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
428 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
429 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 tet_printf("Assertion test failed - wrong Exception\n" );
434 tet_result(TET_FAIL);
441 parent.Remove( empty );
442 tet_printf("Assertion test failed - no Exception\n" );
443 tet_result(TET_FAIL);
445 catch(Dali::DaliException& e)
447 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
448 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
449 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
453 tet_printf("Assertion test failed - wrong Exception\n" );
454 tet_result(TET_FAIL);
458 static void UtcDaliActorRemove02()
460 TestApplication application;
462 Actor parent = Actor::New();
463 Actor child = Actor::New();
464 Actor random = Actor::New();
466 Stage::GetCurrent().Add( parent );
468 DALI_TEST_CHECK(parent.GetChildCount() == 0);
472 DALI_TEST_CHECK(parent.GetChildCount() == 1);
474 parent.Remove(random);
476 DALI_TEST_CHECK(parent.GetChildCount() == 1);
478 Stage::GetCurrent().Remove( parent );
480 DALI_TEST_CHECK(parent.GetChildCount() == 1);
483 static void UtcDaliActorGetChildCount()
485 TestApplication application;
487 Actor parent = Actor::New();
488 Actor child = Actor::New();
490 DALI_TEST_CHECK(parent.GetChildCount() == 0);
494 DALI_TEST_CHECK(parent.GetChildCount() == 1);
497 static void UtcDaliActorGetChildren01()
499 TestApplication application;
501 Actor parent = Actor::New();
502 Actor first = Actor::New();
503 Actor second = Actor::New();
504 Actor third = Actor::New();
510 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
511 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
512 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
515 static void UtcDaliActorGetChildren02()
517 TestApplication application;
519 Actor parent = Actor::New();
520 Actor first = Actor::New();
521 Actor second = Actor::New();
522 Actor third = Actor::New();
528 const Actor& constParent = parent;
530 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
531 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
532 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
535 static void UtcDaliActorGetParent01()
537 TestApplication application;
539 Actor parent = Actor::New();
540 Actor child = Actor::New();
544 DALI_TEST_CHECK(child.GetParent() == parent);
547 static void UtcDaliActorGetParent02()
549 TestApplication application;
551 Actor actor = Actor::New();
553 DALI_TEST_CHECK(!actor.GetParent());
556 static void UtcDaliActorSetParentOrigin()
558 TestApplication application;
560 Actor actor = Actor::New();
562 Vector3 vector(0.7f, 0.8f, 0.9f);
563 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
565 actor.SetParentOrigin(vector);
567 // flush the queue and render once
568 application.SendNotification();
569 application.Render();
571 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
573 Stage::GetCurrent().Add( actor );
575 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
577 // flush the queue and render once
578 application.SendNotification();
579 application.Render();
581 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
583 Stage::GetCurrent().Remove( actor );
586 static void UtcDaliActorGetCurrentParentOrigin()
588 TestApplication application;
590 Actor actor = Actor::New();
592 Vector3 vector(0.7f, 0.8f, 0.9f);
593 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
595 actor.SetParentOrigin(vector);
597 // flush the queue and render once
598 application.SendNotification();
599 application.Render();
601 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
604 static void UtcDaliActorSetAnchorPoint()
606 TestApplication application;
608 Actor actor = Actor::New();
610 Vector3 vector(0.7f, 0.8f, 0.9f);
611 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
613 actor.SetAnchorPoint(vector);
615 // flush the queue and render once
616 application.SendNotification();
617 application.Render();
619 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
621 Stage::GetCurrent().Add( actor );
623 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
624 // flush the queue and render once
625 application.SendNotification();
626 application.Render();
628 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
630 Stage::GetCurrent().Remove( actor );
633 static void UtcDaliActorGetCurrentAnchorPoint()
635 TestApplication application;
637 Actor actor = Actor::New();
639 Vector3 vector(0.7f, 0.8f, 0.9f);
640 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
642 actor.SetAnchorPoint(vector);
644 // flush the queue and render once
645 application.SendNotification();
646 application.Render();
648 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
651 // SetSize(float width, float height)
652 static void UtcDaliActorSetSize01()
654 TestApplication application;
656 Actor actor = Actor::New();
657 Vector3 vector(100.0f, 100.0f, 100.0f);
659 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
661 actor.SetSize(vector.x, vector.y);
663 // flush the queue and render once
664 application.SendNotification();
665 application.Render();
667 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
670 // SetSize(float width, float height, float depth)
671 static void UtcDaliActorSetSize02()
673 TestApplication application;
675 Actor actor = Actor::New();
676 Vector3 vector(100.0f, 100.0f, 100.0f);
678 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
680 actor.SetSize(vector.x, vector.y, vector.z);
682 // flush the queue and render once
683 application.SendNotification();
684 application.Render();
686 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
689 // SetSize(Vector2 size)
690 static void UtcDaliActorSetSize03()
692 TestApplication application;
694 Actor actor = Actor::New();
695 Vector3 vector(100.0f, 100.0f, 100.0f);
697 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
699 actor.SetSize(Vector2(vector.x, vector.y));
701 // flush the queue and render once
702 application.SendNotification();
703 application.Render();
705 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
708 // SetSize(Vector3 size)
709 static void UtcDaliActorSetSize04()
711 TestApplication application;
713 Actor actor = Actor::New();
714 Vector3 vector(100.0f, 100.0f, 100.0f);
716 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
718 actor.SetSize(vector);
720 // flush the queue and render once
721 application.SendNotification();
722 application.Render();
724 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
726 Stage::GetCurrent().Add( actor );
727 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
729 // flush the queue and render once
730 application.SendNotification();
731 application.Render();
733 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
734 Stage::GetCurrent().Remove( actor );
737 static void UtcDaliActorGetCurrentSize()
739 TestApplication application;
741 Actor actor = Actor::New();
742 Vector3 vector(100.0f, 100.0f, 20.0f);
744 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
746 actor.SetSize(vector);
748 // flush the queue and render once
749 application.SendNotification();
750 application.Render();
752 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
755 // SetPosition(float x, float y)
756 static void UtcDaliActorSetPosition01()
758 TestApplication application;
760 Actor actor = Actor::New();
762 // Set to random to start off with
763 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
765 Vector3 vector(100.0f, 100.0f, 0.0f);
767 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
769 actor.SetPosition(vector.x, vector.y);
770 // flush the queue and render once
771 application.SendNotification();
772 application.Render();
773 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
775 Stage::GetCurrent().Add( actor );
776 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
777 // flush the queue and render once
778 application.SendNotification();
779 application.Render();
780 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
785 // flush the queue and render once
786 application.SendNotification();
787 application.Render();
788 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
790 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
791 // flush the queue and render once
792 application.SendNotification();
793 application.Render();
794 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
796 Stage::GetCurrent().Remove( actor );
799 // SetPosition(float x, float y, float z)
800 static void UtcDaliActorSetPosition02()
802 TestApplication application;
804 Actor actor = Actor::New();
806 // Set to random to start off with
807 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
809 Vector3 vector(100.0f, 100.0f, 100.0f);
811 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
813 actor.SetPosition(vector.x, vector.y, vector.z);
815 // flush the queue and render once
816 application.SendNotification();
817 application.Render();
819 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
822 // SetPosition(Vector3 position)
823 static void UtcDaliActorSetPosition03()
825 TestApplication application;
827 Actor actor = Actor::New();
829 // Set to random to start off with
830 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
832 Vector3 vector(100.0f, 100.0f, 100.0f);
834 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
836 actor.SetPosition(vector);
838 // flush the queue and render once
839 application.SendNotification();
840 application.Render();
842 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
845 static void UtcDaliActorSetX()
847 TestApplication application;
849 Actor actor = Actor::New();
851 Vector3 vector(100.0f, 0.0f, 0.0f);
853 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
857 // flush the queue and render once
858 application.SendNotification();
859 application.Render();
861 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
864 static void UtcDaliActorSetY()
866 TestApplication application;
868 Actor actor = Actor::New();
870 Vector3 vector(0.0f, 100.0f, 0.0f);
872 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
876 // flush the queue and render once
877 application.SendNotification();
878 application.Render();
880 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
883 static void UtcDaliActorSetZ()
885 TestApplication application;
887 Actor actor = Actor::New();
889 Vector3 vector(0.0f, 0.0f, 100.0f);
891 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
895 // flush the queue and render once
896 application.SendNotification();
897 application.Render();
899 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
902 static void UtcDaliActorMoveBy()
904 TestApplication application;
906 Actor actor = Actor::New();
907 Vector3 vector(100.0f, 100.0f, 100.0f);
909 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
911 actor.SetPosition(vector);
913 // flush the queue and render once
914 application.SendNotification();
915 application.Render();
917 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
919 actor.MoveBy(vector);
921 // flush the queue and render once
922 application.SendNotification();
923 application.Render();
925 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
928 static void UtcDaliActorGetCurrentPosition()
930 TestApplication application;
932 Actor actor = Actor::New();
933 Vector3 setVector(100.0f, 100.0f, 0.0f);
934 actor.SetPosition(setVector);
936 // flush the queue and render once
937 application.SendNotification();
938 application.Render();
940 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
943 static void UtcDaliActorGetCurrentWorldPosition()
945 TestApplication application;
947 Actor parent = Actor::New();
948 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
949 parent.SetPosition( parentPosition );
950 parent.SetParentOrigin( ParentOrigin::CENTER );
951 parent.SetAnchorPoint( AnchorPoint::CENTER );
952 Stage::GetCurrent().Add( parent );
954 Actor child = Actor::New();
955 child.SetParentOrigin( ParentOrigin::CENTER );
956 child.SetAnchorPoint( AnchorPoint::CENTER );
957 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
958 child.SetPosition( childPosition );
961 // The actors should not have a world position yet
962 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
963 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
965 application.SendNotification();
966 application.Render(0);
968 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
969 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
971 // The actors should have a world position now
972 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
973 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
976 static void UtcDaliActorInheritPosition()
978 tet_infoline("Testing Actor::SetPositionInheritanceMode");
979 TestApplication application;
981 Actor parent = Actor::New();
982 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
983 parent.SetPosition( parentPosition );
984 parent.SetParentOrigin( ParentOrigin::CENTER );
985 parent.SetAnchorPoint( AnchorPoint::CENTER );
986 Stage::GetCurrent().Add( parent );
988 Actor child = Actor::New();
989 child.SetParentOrigin( ParentOrigin::CENTER );
990 child.SetAnchorPoint( AnchorPoint::CENTER );
991 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
992 child.SetPosition( childPosition );
995 // The actors should not have a world position yet
996 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
997 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
999 // first test default, which is INHERIT_PARENT_POSITION
1000 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1001 application.SendNotification();
1002 application.Render(0); // should only really call Update as Render is not required to update scene
1003 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1004 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1005 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1006 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1008 // Change inheritance mode to use parent
1009 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1010 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1011 application.SendNotification();
1012 application.Render(0); // should only really call Update as Render is not required to update scene
1013 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1014 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1015 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1016 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1018 // Change inheritance mode to use parent + offset
1019 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1020 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1021 child.SetPosition( childOffset );
1022 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1023 application.SendNotification();
1024 application.Render(0); // should only really call Update as Render is not required to update scene
1025 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1026 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1027 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1028 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1030 // Change inheritance mode to not inherit
1031 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1032 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1033 application.SendNotification();
1034 application.Render(0); // should only really call Update as Render is not required to update scene
1035 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1036 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1037 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1038 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1041 // SetRotation(float angleRadians, Vector3 axis)
1042 static void UtcDaliActorSetRotation01()
1044 TestApplication application;
1046 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1047 Actor actor = Actor::New();
1049 actor.SetRotation(rotation);
1051 // flush the queue and render once
1052 application.SendNotification();
1053 application.Render();
1055 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1058 static void UtcDaliActorSetRotation02()
1060 TestApplication application;
1062 Actor actor = Actor::New();
1064 float angle = 0.785f;
1065 Vector3 axis(1.0f, 1.0f, 0.0f);
1067 actor.SetRotation(Radian( angle ), axis);
1068 Quaternion rotation( angle, axis );
1069 // flush the queue and render once
1070 application.SendNotification();
1071 application.Render();
1072 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1074 Stage::GetCurrent().Add( actor );
1075 actor.RotateBy( Degree( 360 ), axis);
1076 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1078 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1079 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1080 // flush the queue and render once
1081 application.SendNotification();
1082 application.Render();
1083 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1085 actor.SetRotation(Radian( angle ), axis);
1086 // flush the queue and render once
1087 application.SendNotification();
1088 application.Render();
1089 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1091 Stage::GetCurrent().Remove( actor );
1094 // RotateBy(float angleRadians, Vector3 axis)
1095 static void UtcDaliActorRotateBy01()
1097 TestApplication application;
1099 Actor actor = Actor::New();
1101 float angle = M_PI * 0.25f;
1102 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1103 // flush the queue and render once
1104 application.SendNotification();
1105 application.Render();
1106 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1108 Stage::GetCurrent().Add( actor );
1110 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1111 // flush the queue and render once
1112 application.SendNotification();
1113 application.Render();
1114 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1116 Stage::GetCurrent().Remove( actor );
1119 // RotateBy(Quaternion relativeRotation)
1120 static void UtcDaliActorRotateBy02()
1122 TestApplication application;
1124 Actor actor = Actor::New();
1126 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1127 actor.RotateBy(rotation);
1128 // flush the queue and render once
1129 application.SendNotification();
1130 application.Render();
1131 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1133 actor.RotateBy(rotation);
1134 // flush the queue and render once
1135 application.SendNotification();
1136 application.Render();
1137 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1140 static void UtcDaliActorGetCurrentRotation()
1142 TestApplication application;
1143 Actor actor = Actor::New();
1145 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1146 actor.SetRotation(rotation);
1147 // flush the queue and render once
1148 application.SendNotification();
1149 application.Render();
1150 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1153 static void UtcDaliActorGetCurrentWorldRotation()
1155 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1156 TestApplication application;
1158 Actor parent = Actor::New();
1159 Radian rotationAngle( Degree(90.0f) );
1160 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1161 parent.SetRotation( rotation );
1162 Stage::GetCurrent().Add( parent );
1164 Actor child = Actor::New();
1165 child.SetRotation( rotation );
1166 parent.Add( child );
1168 // The actors should not have a world rotation yet
1169 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1170 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1172 application.SendNotification();
1173 application.Render(0);
1175 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1176 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1178 // The actors should have a world rotation now
1179 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1180 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1182 // turn off child rotation inheritance
1183 child.SetInheritRotation( false );
1184 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1185 application.SendNotification();
1186 application.Render(0);
1188 // The actors should have a world rotation now
1189 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1190 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1193 // SetScale(float scale)
1194 static void UtcDaliActorSetScale01()
1196 TestApplication application;
1198 Actor actor = Actor::New();
1200 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1201 actor.SetScale(0.25f);
1203 Vector3 scale(10.0f, 10.0f, 10.0f);
1204 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1206 actor.SetScale(scale.x);
1208 // flush the queue and render once
1209 application.SendNotification();
1210 application.Render();
1212 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1215 // SetScale(float scaleX, float scaleY, float scaleZ)
1216 static void UtcDaliActorSetScale02()
1218 TestApplication application;
1219 Vector3 scale(10.0f, 10.0f, 10.0f);
1221 Actor actor = Actor::New();
1223 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1224 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1226 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1228 actor.SetScale(scale.x, scale.y, scale.z);
1229 // flush the queue and render once
1230 application.SendNotification();
1231 application.Render();
1232 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1234 // add to stage and test
1235 Stage::GetCurrent().Add( actor );
1236 actor.SetScale( 2.0f, 2.0f, 2.0f );
1237 // flush the queue and render once
1238 application.SendNotification();
1239 application.Render();
1240 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1242 Stage::GetCurrent().Remove( actor );
1246 // SetScale(Vector3 scale)
1247 static void UtcDaliActorSetScale03()
1249 TestApplication application;
1250 Vector3 scale(10.0f, 10.0f, 10.0f);
1252 Actor actor = Actor::New();
1254 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1255 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1257 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1259 actor.SetScale(scale);
1261 // flush the queue and render once
1262 application.SendNotification();
1263 application.Render();
1265 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1268 static void UtcDaliActorScaleBy()
1270 TestApplication application;
1271 Actor actor = Actor::New();
1272 Vector3 vector(100.0f, 100.0f, 100.0f);
1274 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1276 actor.SetScale(vector);
1278 // flush the queue and render once
1279 application.SendNotification();
1280 application.Render();
1282 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1284 actor.ScaleBy(vector);
1286 // flush the queue and render once
1287 application.SendNotification();
1288 application.Render();
1290 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1293 static void UtcDaliActorGetCurrentScale()
1295 TestApplication application;
1296 Vector3 scale(12.0f, 1.0f, 2.0f);
1298 Actor actor = Actor::New();
1300 actor.SetScale(scale);
1302 // flush the queue and render once
1303 application.SendNotification();
1304 application.Render();
1306 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1309 static void UtcDaliActorGetCurrentWorldScale()
1311 TestApplication application;
1313 Actor parent = Actor::New();
1314 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1315 parent.SetScale( parentScale );
1316 Stage::GetCurrent().Add( parent );
1318 Actor child = Actor::New();
1319 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1320 child.SetScale( childScale );
1321 parent.Add( child );
1323 // The actors should not have a scale yet
1324 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1325 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1327 // The actors should not have a world scale yet
1328 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1329 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1331 application.SendNotification();
1332 application.Render(0);
1334 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1335 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1337 // The actors should have a world scale now
1338 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1339 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1342 static void UtcDaliActorInheritScale()
1344 tet_infoline("Testing Actor::SetInheritScale");
1345 TestApplication application;
1347 Actor parent = Actor::New();
1348 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1349 parent.SetScale( parentScale );
1350 Stage::GetCurrent().Add( parent );
1352 Actor child = Actor::New();
1353 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1354 child.SetScale( childScale );
1355 parent.Add( child );
1357 application.SendNotification();
1358 application.Render(0);
1360 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1361 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1363 child.SetInheritScale( false );
1364 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1366 application.SendNotification();
1367 application.Render(0);
1369 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1372 static void UtcDaliActorSetVisible()
1374 TestApplication application;
1376 Actor actor = Actor::New();
1377 actor.SetVisible(false);
1378 // flush the queue and render once
1379 application.SendNotification();
1380 application.Render();
1381 DALI_TEST_CHECK(actor.IsVisible() == false);
1383 actor.SetVisible(true);
1384 // flush the queue and render once
1385 application.SendNotification();
1386 application.Render();
1387 DALI_TEST_CHECK(actor.IsVisible() == true);
1389 // put actor on stage
1390 Stage::GetCurrent().Add( actor );
1391 actor.SetVisible(false);
1392 // flush the queue and render once
1393 application.SendNotification();
1394 application.Render();
1395 DALI_TEST_CHECK(actor.IsVisible() == false);
1398 static void UtcDaliActorIsVisible()
1400 TestApplication application;
1402 Actor actor = Actor::New();
1404 DALI_TEST_CHECK(actor.IsVisible() == true);
1407 static void UtcDaliActorSetOpacity()
1409 TestApplication application;
1411 Actor actor = Actor::New();
1412 // initial opacity is 1
1413 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1415 actor.SetOpacity( 0.4f);
1416 // flush the queue and render once
1417 application.SendNotification();
1418 application.Render();
1419 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1421 // change opacity, actor is on stage to change is not immediate
1422 actor.OpacityBy( 0.1f );
1423 // flush the queue and render once
1424 application.SendNotification();
1425 application.Render();
1426 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1428 // put actor on stage
1429 Stage::GetCurrent().Add( actor );
1431 // change opacity, actor is on stage to change is not immediate
1432 actor.SetOpacity( 0.9f );
1433 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1434 // flush the queue and render once
1435 application.SendNotification();
1436 application.Render();
1437 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1439 // change opacity, actor is on stage to change is not immediate
1440 actor.OpacityBy( -0.9f );
1441 // flush the queue and render once
1442 application.SendNotification();
1443 application.Render();
1444 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1447 static void UtcDaliActorGetCurrentOpacity()
1449 TestApplication application;
1451 Actor actor = Actor::New();
1452 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1454 actor.SetOpacity(0.5f);
1455 // flush the queue and render once
1456 application.SendNotification();
1457 application.Render();
1458 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1461 static void UtcDaliActorSetSensitive()
1463 TestApplication application;
1464 Actor actor = Actor::New();
1466 bool sensitive = !actor.IsSensitive();
1468 actor.SetSensitive(sensitive);
1470 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1473 static void UtcDaliActorIsSensitive()
1475 TestApplication application;
1476 Actor actor = Actor::New();
1477 actor.SetSensitive(false);
1479 DALI_TEST_CHECK(false == actor.IsSensitive());
1482 static void UtcDaliActorSetInheritShaderEffect()
1484 TestApplication application;
1486 Actor actor = Actor::New();
1488 actor.SetInheritShaderEffect(false);
1489 // flush the queue and render once
1490 application.SendNotification();
1491 application.Render();
1492 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == false);
1494 actor.SetInheritShaderEffect(true);
1495 // flush the queue and render once
1496 application.SendNotification();
1497 application.Render();
1498 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1501 static void UtcDaliActorGetInheritShaderEffect()
1503 TestApplication application;
1505 Actor actor = Actor::New();
1507 DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true);
1510 static void UtcDaliActorSetShaderEffect()
1512 TestApplication application;
1513 Actor actor = Actor::New();
1515 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1517 DALI_TEST_CHECK(effect != actor.GetShaderEffect());
1519 actor.SetShaderEffect(effect);
1521 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1524 static void UtcDaliActorGetShaderEffect()
1526 TestApplication application;
1527 Actor actor = Actor::New();
1529 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1530 actor.SetShaderEffect(effect);
1532 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1535 static void UtcDaliActorRemoveShaderEffect01()
1537 TestApplication application;
1538 Actor actor = Actor::New();
1540 ShaderEffect defaultEffect = actor.GetShaderEffect();
1542 ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource);
1543 actor.SetShaderEffect(effect);
1545 DALI_TEST_CHECK(effect == actor.GetShaderEffect());
1547 actor.RemoveShaderEffect();
1549 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1552 static void UtcDaliActorRemoveShaderEffect02()
1554 TestApplication application;
1555 Actor actor = Actor::New();
1557 ShaderEffect defaultEffect = actor.GetShaderEffect();
1559 actor.RemoveShaderEffect();
1561 DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
1564 static void UtcDaliActorSetColor()
1566 TestApplication application;
1567 Actor actor = Actor::New();
1568 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1570 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1572 actor.SetColor(color);
1573 // flush the queue and render once
1574 application.SendNotification();
1575 application.Render();
1576 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1578 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1579 // flush the queue and render once
1580 application.SendNotification();
1581 application.Render();
1582 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1584 Stage::GetCurrent().Add( actor );
1585 actor.SetColor( color );
1586 // flush the queue and render once
1587 application.SendNotification();
1588 application.Render();
1589 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1591 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1592 // flush the queue and render once
1593 application.SendNotification();
1594 application.Render();
1595 // Actor color is not clamped
1596 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1597 // world color is clamped
1598 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1600 Stage::GetCurrent().Remove( actor );
1603 static void UtcDaliActorGetCurrentColor()
1605 TestApplication application;
1606 Actor actor = Actor::New();
1607 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1609 actor.SetColor(color);
1610 // flush the queue and render once
1611 application.SendNotification();
1612 application.Render();
1613 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1616 static void UtcDaliActorGetCurrentWorldColor()
1618 tet_infoline("Actor::GetCurrentWorldColor");
1619 TestApplication application;
1621 Actor parent = Actor::New();
1622 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1623 parent.SetColor( parentColor );
1624 Stage::GetCurrent().Add( parent );
1626 Actor child = Actor::New();
1627 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1628 child.SetColor( childColor );
1629 parent.Add( child );
1631 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1632 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1634 // verify the default color mode
1635 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1637 // The actors should not have a world color yet
1638 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1639 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1641 application.SendNotification();
1642 application.Render(0);
1644 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1645 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1647 // The actors should have a world color now
1648 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1649 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1652 child.SetColorMode( USE_OWN_COLOR );
1653 application.SendNotification();
1654 application.Render(0);
1655 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1658 child.SetColorMode( USE_PARENT_COLOR );
1659 application.SendNotification();
1660 application.Render(0);
1661 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1662 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1665 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1666 application.SendNotification();
1667 application.Render(0);
1668 Vector4 expectedColor( childColor );
1669 expectedColor.a *= parentColor.a;
1670 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1671 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1674 static void UtcDaliActorSetColorMode()
1676 tet_infoline("Actor::SetColorMode");
1677 TestApplication application;
1678 Actor actor = Actor::New();
1679 Actor child = Actor::New();
1682 actor.SetColorMode( USE_OWN_COLOR );
1683 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1685 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1686 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1688 actor.SetColorMode( USE_PARENT_COLOR );
1689 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1691 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1692 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1695 static void UtcDaliActorScreenToLocal()
1697 TestApplication application;
1698 Actor actor = Actor::New();
1699 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1700 actor.SetSize(100.0f, 100.0f);
1701 actor.SetPosition(10.0f, 10.0f);
1702 Stage::GetCurrent().Add(actor);
1704 // flush the queue and render once
1705 application.SendNotification();
1706 application.Render();
1711 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1713 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1714 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1717 static void UtcDaliActorSetLeaveRequired()
1719 TestApplication application;
1721 Actor actor = Actor::New();
1723 actor.SetLeaveRequired(false);
1724 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1726 actor.SetLeaveRequired(true);
1727 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1730 static void UtcDaliActorGetLeaveRequired()
1732 TestApplication application;
1734 Actor actor = Actor::New();
1736 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1739 static void UtcDaliActorSetKeyboardFocusable()
1741 TestApplication application;
1743 Actor actor = Actor::New();
1745 actor.SetKeyboardFocusable(true);
1746 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1748 actor.SetKeyboardFocusable(false);
1749 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1752 static void UtcDaliActorIsKeyboardFocusable()
1754 TestApplication application;
1756 Actor actor = Actor::New();
1758 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1761 static bool gTestConstraintCalled;
1763 struct TestConstraint
1765 Vector4 operator()(const Vector4& color)
1767 gTestConstraintCalled = true;
1768 return Vector4(color.x, color.y, color.z, 0.1f);
1773 * TestConstraint reference.
1774 * When constraint is called, the resultRef is updated
1775 * with the value supplied.
1777 template<typename T>
1778 struct TestConstraintRef
1780 TestConstraintRef(unsigned int& resultRef, unsigned int value)
1781 : mResultRef(resultRef),
1786 T operator()(const T& current)
1788 mResultRef = mValue;
1792 unsigned int& mResultRef;
1793 unsigned int mValue;
1796 static void UtcDaliActorApplyConstraint()
1798 TestApplication application;
1800 gTestConstraintCalled = false;
1802 Actor actor = Actor::New();
1804 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1805 actor.ApplyConstraint(constraint);
1807 DALI_TEST_CHECK( gTestConstraintCalled == false );
1809 Stage::GetCurrent().Add( actor );
1811 // flush the queue and render once
1812 application.SendNotification();
1813 application.Render();
1815 DALI_TEST_CHECK( gTestConstraintCalled == true );
1818 bool wasConstraintCallbackCalled1 = false;
1819 void TestConstraintCallback1( ActiveConstraint& constraint )
1821 wasConstraintCallbackCalled1 = true;
1824 bool wasConstraintCallbackCalled2 = false;
1825 void TestConstraintCallback2( ActiveConstraint& constraint )
1827 wasConstraintCallbackCalled2 = true;
1830 bool wasConstraintCallbackCalled3 = false;
1831 void TestConstraintCallback3( ActiveConstraint& constraint )
1833 wasConstraintCallbackCalled3 = true;
1836 static void UtcDaliActorApplyConstraintAppliedCallback()
1838 TestApplication application;
1840 // Build a reusable constraint
1842 Actor parent = Actor::New();
1843 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1844 parent.SetSize( parentSize );
1845 Stage::GetCurrent().Add( parent );
1847 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1848 Source( parent, Actor::SIZE ),
1849 EqualToConstraint() );
1851 // Create some child actors
1853 Actor child1 = Actor::New();
1854 parent.Add( child1 );
1856 Actor child2 = Actor::New();
1857 parent.Add( child2 );
1859 Actor child3 = Actor::New();
1860 parent.Add( child3 );
1862 // Apply constraint with different timings - everything should be finished after 10 seconds
1864 wasConstraintCallbackCalled1 = false;
1865 wasConstraintCallbackCalled2 = false;
1866 wasConstraintCallbackCalled3 = false;
1868 constraint.SetApplyTime( 5.0f );
1869 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1870 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1872 constraint.SetApplyTime( 10.0f );
1873 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1874 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1876 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1877 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1878 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1880 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1881 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1882 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1884 application.SendNotification();
1886 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1887 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1888 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1889 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1891 // Check signals have not fired
1892 application.SendNotification();
1893 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1894 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1895 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1897 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1898 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1899 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1900 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1902 // Check signals have not fired
1903 application.SendNotification();
1904 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1905 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1906 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1908 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1909 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1910 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1911 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1913 // Check signals have not fired
1914 application.SendNotification();
1915 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1916 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1917 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1919 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1920 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1921 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1922 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
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 );
1930 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1931 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1932 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1933 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
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 );
1941 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1942 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1943 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1944 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1946 // 1st signal should have fired
1947 application.SendNotification();
1948 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1949 wasConstraintCallbackCalled1 = false;
1950 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1951 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1953 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1954 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1955 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1956 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1958 // Check signals have not fired
1959 application.SendNotification();
1960 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1961 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1962 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1964 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1965 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1966 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1967 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
1969 // 3rd signal should have fired
1970 application.SendNotification();
1972 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1973 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1974 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
1975 wasConstraintCallbackCalled3 = false;
1977 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
1978 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1979 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
1980 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1982 // Check signals have not fired
1983 application.SendNotification();
1984 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1985 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1986 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1988 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
1989 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1990 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
1991 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1993 // 2nd signal should have fired
1994 application.SendNotification();
1995 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1996 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
1997 wasConstraintCallbackCalled2 = false;
1998 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2000 // Check that nothing has changed after a couple of buffer swaps
2002 application.Render(0);
2003 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2004 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2005 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2007 application.SendNotification();
2008 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2009 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2010 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2012 application.Render(0);
2013 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2014 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2015 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2017 application.SendNotification();
2018 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2019 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2020 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2023 static void UtcDaliActorRemoveConstraints()
2025 tet_infoline(" UtcDaliActorRemoveConstraints");
2026 TestApplication application;
2028 gTestConstraintCalled = false;
2030 Actor actor = Actor::New();
2032 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
2033 actor.ApplyConstraint(constraint);
2034 actor.RemoveConstraints();
2036 DALI_TEST_CHECK( gTestConstraintCalled == false );
2038 Stage::GetCurrent().Add( actor );
2039 actor.ApplyConstraint(constraint);
2041 // flush the queue and render once
2042 application.SendNotification();
2043 application.Render();
2045 actor.RemoveConstraints();
2047 DALI_TEST_CHECK( gTestConstraintCalled == true );
2050 static void UtcDaliActorRemoveConstraint()
2052 tet_infoline(" UtcDaliActorRemoveConstraint");
2053 TestApplication application;
2055 Actor actor = Actor::New();
2057 // 1. Apply Constraint1 and Constraint2, and test...
2058 unsigned int result1 = 0u;
2059 unsigned int result2 = 0u;
2060 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2061 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2063 Stage::GetCurrent().Add( actor );
2064 // flush the queue and render once
2065 application.SendNotification();
2066 application.Render();
2068 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2069 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2071 // 2. Remove Constraint1 and test...
2074 actor.RemoveConstraint(activeConstraint1);
2075 // make color property dirty, which will trigger constraints to be reapplied.
2076 actor.SetColor( Color::WHITE );
2077 // flush the queue and render once
2078 application.SendNotification();
2079 application.Render();
2081 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2082 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2084 // 3. Re-Apply Constraint1 and test...
2087 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2088 // make color property dirty, which will trigger constraints to be reapplied.
2089 actor.SetColor( Color::WHITE );
2090 // flush the queue and render once
2091 application.SendNotification();
2092 application.Render();
2094 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2095 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2097 // 2. Remove Constraint2 and test...
2100 actor.RemoveConstraint(activeConstraint2);
2101 // make color property dirty, which will trigger constraints to be reapplied.
2102 actor.SetColor( Color::WHITE );
2103 // flush the queue and render once
2104 application.SendNotification();
2105 application.Render();
2107 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2108 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2110 // 2. Remove Constraint1 as well and test...
2113 actor.RemoveConstraint(activeConstraint1);
2114 // make color property dirty, which will trigger constraints to be reapplied.
2115 actor.SetColor( Color::WHITE );
2116 // flush the queue and render once
2117 application.SendNotification();
2118 application.Render();
2120 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2121 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2124 static bool gTouchCallBackCalled;
2125 static bool gTouchCallBack2Called;
2127 static bool TestCallback(Actor actor, const TouchEvent& event)
2129 gTouchCallBackCalled = true;
2133 static bool TestCallback2(Actor actor, const TouchEvent& event)
2135 gTouchCallBack2Called = true;
2140 static void UtcDaliActorTouchedSignal()
2142 TestApplication application;
2144 gTouchCallBackCalled = false;
2146 // get the root layer
2147 Actor actor = Stage::GetCurrent().GetRootLayer();
2148 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2150 application.SendNotification();
2151 application.Render();
2153 // connect to its touch signal
2154 actor.TouchedSignal().Connect( TestCallback );
2156 // simulate a touch event in the middle of the screen
2157 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2158 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2159 Dali::Integration::TouchEvent event;
2160 event.AddPoint( point );
2161 application.GetCore().SendEvent( event );
2163 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2166 static Vector3 gSetSize;
2167 static bool gSetSizeCallBackCalled;
2168 static void SetSizeCallback( Actor actor, const Vector3& size )
2170 gSetSizeCallBackCalled = true;
2174 static void UtcDaliActorSetSizeSignal()
2176 TestApplication application;
2178 Actor actor = Actor::New();
2179 actor.SetSizeSignal().Connect( SetSizeCallback );
2181 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2182 gSetSizeCallBackCalled = false;
2183 Vector2 size2d( 1.0f, 2.0f );
2184 actor.SetSize( size2d );
2185 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2186 // SetSize with Vector2 sets depth to be the minimum of width & height
2187 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2189 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2190 gSetSizeCallBackCalled = false;
2191 actor.SetSize( 22.0f, 11.0f );
2192 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2193 // SetSize with Vector2 sets depth to be the minimum of width & height
2194 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2196 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2197 gSetSizeCallBackCalled = false;
2198 Vector3 size( 3.0f, 4.0f, 5.0f );
2199 actor.SetSize( size );
2200 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2201 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2203 // add actor to stage to see that signal still works
2204 Stage::GetCurrent().Add( actor );
2206 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2207 gSetSizeCallBackCalled = false;
2208 actor.SetSize( -1.0f, -2.0f, -3.0f );
2209 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2210 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2213 // validation stuff for onstage & offstage signals
2214 static std::vector< std::string > gActorNamesOnOffStage;
2215 static int gOnStageCallBackCalled;
2216 static void OnStageCallback( Actor actor )
2218 ++gOnStageCallBackCalled;
2219 gActorNamesOnOffStage.push_back( actor.GetName() );
2220 DALI_TEST_CHECK( actor.OnStage() == true );
2222 static int gOffStageCallBackCalled;
2223 static void OffStageCallback( Actor actor )
2225 ++gOffStageCallBackCalled;
2226 gActorNamesOnOffStage.push_back( actor.GetName() );
2227 DALI_TEST_CHECK( actor.OnStage() == false );
2230 static void UtcDaliActorOnOffStageSignal()
2232 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2234 TestApplication application;
2237 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2238 gActorNamesOnOffStage.clear();
2240 Actor parent = Actor::New();
2241 parent.SetName( "parent" );
2242 parent.OnStageSignal().Connect( OnStageCallback );
2243 parent.OffStageSignal().Connect( OffStageCallback );
2245 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2246 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2248 // add parent to stage
2249 Stage::GetCurrent().Add( parent );
2250 // onstage emitted, offstage not
2251 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2252 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2253 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2255 // test adding a child, should get onstage emitted
2257 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2258 gActorNamesOnOffStage.clear();
2260 Actor child = Actor::New();
2261 child.SetName( "child" );
2262 child.OnStageSignal().Connect( OnStageCallback );
2263 child.OffStageSignal().Connect( OffStageCallback );
2264 parent.Add( child ); // add child
2265 // onstage emitted, offstage not
2266 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2267 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2268 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2270 // test removing parent from stage
2272 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2273 gActorNamesOnOffStage.clear();
2275 Stage::GetCurrent().Remove( parent );
2276 // onstage not emitted, offstage is
2277 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2278 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2279 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2280 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2282 // test adding parent back to stage
2284 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2285 gActorNamesOnOffStage.clear();
2287 Stage::GetCurrent().Add( parent );
2288 // onstage emitted, offstage not
2289 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2290 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2291 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2292 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2294 // test removing child
2296 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2297 gActorNamesOnOffStage.clear();
2299 parent.Remove( child );
2300 // onstage not emitted, offstage is
2301 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2302 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2303 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2305 // test removing parent
2307 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2308 gActorNamesOnOffStage.clear();
2310 Stage::GetCurrent().Remove( parent );
2311 // onstage not emitted, offstage is
2312 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2313 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2314 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2317 static void UtcDaliActorFindChildByName()
2319 tet_infoline("Testing Dali::Actor::FindChildByName()");
2320 TestApplication application;
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" );
2332 Actor found = parent.FindChildByName( "foo" );
2333 DALI_TEST_CHECK( !found );
2335 found = parent.FindChildByName( "parent" );
2336 DALI_TEST_CHECK( found == parent );
2338 found = parent.FindChildByName( "first" );
2339 DALI_TEST_CHECK( found == first );
2341 found = parent.FindChildByName( "second" );
2342 DALI_TEST_CHECK( found == second );
2345 static void UtcDaliActorFindChildByAlias()
2347 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2348 TestApplication application;
2350 Actor parent = Actor::New();
2351 parent.SetName( "parent" );
2352 Actor first = Actor::New();
2353 first .SetName( "first" );
2354 Actor second = Actor::New();
2355 second.SetName( "second" );
2360 Actor found = parent.FindChildByAlias( "foo" );
2361 DALI_TEST_CHECK( !found );
2363 found = parent.FindChildByAlias( "parent" );
2364 DALI_TEST_CHECK( found == parent );
2366 found = parent.FindChildByAlias( "first" );
2367 DALI_TEST_CHECK( found == first );
2369 found = parent.FindChildByAlias( "second" );
2370 DALI_TEST_CHECK( found == second );
2373 static void UtcDaliActorFindChildById()
2375 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2376 TestApplication application;
2378 Actor parent = Actor::New();
2379 Actor first = Actor::New();
2380 Actor second = Actor::New();
2385 Actor found = parent.FindChildById( 100000 );
2386 DALI_TEST_CHECK( !found );
2388 found = parent.FindChildById( parent.GetId() );
2389 DALI_TEST_CHECK( found == parent );
2391 found = parent.FindChildById( first.GetId() );
2392 DALI_TEST_CHECK( found == first );
2394 found = parent.FindChildById( second.GetId() );
2395 DALI_TEST_CHECK( found == second );
2398 static void UtcDaliActorHitTest()
2403 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2405 mTouchPoint( touchPoint ),
2410 Vector2 mTouchPoint;
2414 TestApplication application;
2415 tet_infoline(" UtcDaliActorHitTest");
2417 // Fill a vector with different hit tests.
2418 struct HitTestData* hitTestData[] = {
2419 // scale touch point result
2420 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2421 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2422 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.
2423 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2424 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 // get the root layer
2429 Actor actor = Actor::New();
2430 actor.SetAnchorPoint( AnchorPoint::CENTER );
2431 actor.SetParentOrigin( ParentOrigin::CENTER );
2433 Stage::GetCurrent().Add( actor );
2435 gTouchCallBackCalled = false;
2437 unsigned int index = 0;
2438 while( NULL != hitTestData[index] )
2440 actor.SetSize( 1.f, 1.f );
2441 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2443 // flush the queue and render once
2444 application.SendNotification();
2445 application.Render();
2447 DALI_TEST_CHECK( !gTouchCallBackCalled );
2449 // connect to its touch signal
2450 actor.TouchedSignal().Connect(TestCallback);
2452 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2453 Dali::Integration::TouchEvent event;
2454 event.AddPoint( point );
2456 // flush the queue and render once
2457 application.SendNotification();
2458 application.Render();
2459 application.GetCore().SendEvent( event );
2461 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2463 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2464 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2465 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2466 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2467 hitTestData[index]->mResult );
2469 gTouchCallBackCalled = false;
2474 static void UtcDaliActorSetDrawMode()
2476 TestApplication app;
2477 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2479 Actor a = Actor::New();
2481 Stage::GetCurrent().Add(a);
2482 app.SendNotification();
2484 app.SendNotification();
2487 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2489 a.SetDrawMode( DrawMode::OVERLAY );
2490 app.SendNotification();
2493 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2495 a.SetDrawMode( DrawMode::STENCIL );
2496 app.SendNotification();
2499 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2501 a.SetDrawMode( DrawMode::NORMAL );
2502 app.SendNotification();
2505 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2508 static void UtcDaliActorSetDrawModeOverlayRender()
2510 TestApplication app;
2511 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2513 std::vector<GLuint> ids;
2514 ids.push_back( 8 ); // first rendered actor
2515 ids.push_back( 9 ); // second rendered actor
2516 ids.push_back( 10 ); // third rendered actor
2517 app.GetGlAbstraction().SetNextTextureIds( ids );
2519 BitmapImage imageA = BitmapImage::New(16, 16);
2520 BitmapImage imageB = BitmapImage::New(16, 16);
2521 BitmapImage imageC = BitmapImage::New(16, 16);
2522 ImageActor a = ImageActor::New( imageA );
2523 ImageActor b = ImageActor::New( imageB );
2524 ImageActor c = ImageActor::New( imageC );
2526 // Render a,b,c as regular non-overlays. so order will be:
2530 Stage::GetCurrent().Add(a);
2531 Stage::GetCurrent().Add(b);
2532 Stage::GetCurrent().Add(c);
2534 app.SendNotification();
2536 app.SendNotification();
2539 // Should be 3 textures changes.
2540 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2541 typedef std::vector<GLuint>::size_type TextureSize;
2542 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2543 if( boundTextures.size() == 3 )
2545 DALI_TEST_CHECK( boundTextures[0] == 8u );
2546 DALI_TEST_CHECK( boundTextures[1] == 9u );
2547 DALI_TEST_CHECK( boundTextures[2] == 10u );
2550 // Now texture ids have been set, we can monitor their render order.
2551 // render a as an overlay (last), so order will be:
2555 a.SetDrawMode( DrawMode::OVERLAY );
2556 app.GetGlAbstraction().ClearBoundTextures();
2558 app.SendNotification();
2561 // Should be 3 texture changes.
2562 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2563 if( boundTextures.size() == 3 )
2565 DALI_TEST_CHECK( boundTextures[0] == 9u );
2566 DALI_TEST_CHECK( boundTextures[1] == 10u );
2567 DALI_TEST_CHECK( boundTextures[2] == 8u );
2572 * Simulates a Down Touch at 25.0, 25.0.
2573 * @param[in] app Test Application instance.
2575 static void SimulateTouchForSetOverlayHitTest(TestApplication& app)
2577 app.SendNotification();
2579 app.SendNotification();
2582 gTouchCallBackCalled = false;
2583 gTouchCallBack2Called = false;
2585 // simulate a touch event
2586 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
2587 Dali::Integration::TouchEvent event;
2588 event.AddPoint( point );
2589 app.GetCore().SendEvent( event );
2591 app.SendNotification();
2593 app.SendNotification();
2597 static void UtcDaliActorSetDrawModeOverlayHitTest()
2599 TestApplication app;
2600 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2602 BitmapImage imageA = BitmapImage::New(16, 16);
2603 BitmapImage imageB = BitmapImage::New(16, 16);
2604 ImageActor a = ImageActor::New( imageA );
2605 ImageActor b = ImageActor::New( imageB );
2607 // Render a,b as regular non-overlays. so order will be:
2608 Stage::GetCurrent().Add(a);
2609 Stage::GetCurrent().Add(b);
2611 a.SetSize(Vector2(100.0f, 100.0f));
2612 b.SetSize(Vector2(100.0f, 100.0f));
2614 // position b overlapping a. (regular non-overlays)
2615 // hit test at point 'x'
2626 // note: b is on top, because it's Z position is higher.
2627 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2628 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2630 // connect to their touch signals
2631 a.TouchedSignal().Connect(TestCallback);
2632 b.TouchedSignal().Connect(TestCallback2);
2634 a.SetDrawMode( DrawMode::NORMAL );
2635 b.SetDrawMode( DrawMode::NORMAL );
2636 SimulateTouchForSetOverlayHitTest(app);
2638 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2639 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2640 // Make Actor a an overlay.
2651 // note: a is on top, because it is an overlay.
2652 a.SetDrawMode( DrawMode::OVERLAY );
2653 b.SetDrawMode( DrawMode::NORMAL );
2654 SimulateTouchForSetOverlayHitTest(app);
2656 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2657 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2658 // Make both Actors as overlays
2669 // note: b is on top, because it is the 2nd child in the hierarchy.
2670 a.SetDrawMode( DrawMode::OVERLAY );
2671 b.SetDrawMode( DrawMode::OVERLAY );
2672 SimulateTouchForSetOverlayHitTest(app);
2674 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2675 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2678 static void UtcDaliActorGetCurrentWorldMatrix()
2680 TestApplication app;
2681 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2683 Actor parent = Actor::New();
2684 parent.SetParentOrigin(ParentOrigin::CENTER);
2685 parent.SetAnchorPoint(AnchorPoint::CENTER);
2686 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2687 Radian rotationAngle(Degree(85.0f));
2688 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2689 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2690 parent.SetPosition( parentPosition );
2691 parent.SetRotation( parentRotation );
2692 parent.SetScale( parentScale );
2693 Stage::GetCurrent().Add( parent );
2695 Actor child = Actor::New();
2696 child.SetParentOrigin(ParentOrigin::CENTER);
2697 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2698 Radian childRotationAngle(Degree(23.0f));
2699 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2700 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2701 child.SetPosition( childPosition );
2702 child.SetRotation( childRotation );
2703 child.SetScale( childScale );
2704 parent.Add( child );
2706 // The actors should not have a world matrix yet
2707 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2708 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2710 app.SendNotification();
2713 app.SendNotification();
2715 Matrix parentMatrix(false);
2716 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2718 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2719 Quaternion childWorldRotation = parentRotation * childRotation;
2720 Vector3 childWorldScale = parentScale * childScale;
2722 Matrix childWorldMatrix(false);
2723 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2725 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2726 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2730 struct PositionComponentConstraint
2732 PositionComponentConstraint(){}
2734 Vector3 operator()(const Vector3& current, const PropertyInput& property)
2736 const Matrix& m = property.GetMatrix();
2740 m.GetTransformComponents(pos, rot, scale);
2746 static void UtcDaliActorConstrainedToWorldMatrix()
2748 TestApplication app;
2749 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2751 Actor parent = Actor::New();
2752 parent.SetParentOrigin(ParentOrigin::CENTER);
2753 parent.SetAnchorPoint(AnchorPoint::CENTER);
2754 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2755 Radian rotationAngle(Degree(85.0f));
2756 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2757 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2758 parent.SetPosition( parentPosition );
2759 parent.SetRotation( parentRotation );
2760 parent.SetScale( parentScale );
2761 Stage::GetCurrent().Add( parent );
2763 Actor child = Actor::New();
2764 child.SetParentOrigin(ParentOrigin::CENTER);
2765 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2766 child.ApplyConstraint(posConstraint);
2768 Stage::GetCurrent().Add( child );
2770 // The actors should not have a world matrix yet
2771 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2772 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2774 app.SendNotification();
2777 app.SendNotification();
2779 Matrix parentMatrix(false);
2780 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2782 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2783 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2786 static void UtcDaliActorUnparent()
2788 TestApplication app;
2789 tet_infoline(" UtcDaliActorUnparent");
2791 Actor parent = Actor::New();
2792 Stage::GetCurrent().Add( parent );
2794 Actor child = Actor::New();
2796 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2797 DALI_TEST_CHECK( !child.GetParent() );
2799 // Test that calling Unparent with no parent is a NOOP
2802 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2803 DALI_TEST_CHECK( !child.GetParent() );
2805 // Test that Unparent works
2806 parent.Add( child );
2808 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2809 DALI_TEST_CHECK( parent == child.GetParent() );
2813 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2814 DALI_TEST_CHECK( !child.GetParent() );
2816 // Test that UnparentAndReset works
2817 parent.Add( child );
2819 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2820 DALI_TEST_CHECK( parent == child.GetParent() );
2822 UnparentAndReset( child );
2824 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2825 DALI_TEST_CHECK( !child );
2827 // Test that UnparentAndReset is a NOOP with empty handle
2828 UnparentAndReset( child );
2830 DALI_TEST_CHECK( !child );
2833 static void UtcDaliActorGetChildAt()
2835 TestApplication app;
2836 tet_infoline(" UtcDaliActorGetChildAt");
2838 Actor parent = Actor::New();
2839 Stage::GetCurrent().Add( parent );
2841 Actor child0 = Actor::New();
2842 parent.Add( child0 );
2844 Actor child1 = Actor::New();
2845 parent.Add( child1 );
2847 Actor child2 = Actor::New();
2848 parent.Add( child2 );
2850 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2851 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2852 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2855 static void UtcDaliActorSetGetOverlay()
2857 TestApplication app;
2858 tet_infoline(" UtcDaliActorSetGetOverlay");
2860 Actor parent = Actor::New();
2861 parent.SetDrawMode(DrawMode::OVERLAY );
2862 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2866 // Current Dynamics functions are crashing, so testing these sections are futile
2868 static void UtcDaliActorDynamics()
2870 DALI_TEST_CHECK( true );
2873 static void UtcDaliActorCreateDestroy()
2875 Actor* actor = new Actor;
2876 DALI_TEST_CHECK( actor );