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>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit-test-suite-utils.h>
30 using namespace Dali::Toolkit;
32 static void Startup();
33 static void Cleanup();
37 static bool gObjectCreatedCallBackCalled;
39 static void TestCallback(BaseHandle handle)
41 gObjectCreatedCallBackCalled = true;
46 void (*tet_startup)() = Startup;
47 void (*tet_cleanup)() = Cleanup;
51 POSITIVE_TC_IDX = 0x01,
55 #define MAX_NUMBER_OF_TESTS 10000
57 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
60 // Add test functionality for all APIs in the class (Positive and Negative)
61 TEST_FUNCTION( UtcDaliAlignmentConstructorNegative, NEGATIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliAlignmentConstructorPositive, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliAlignmentConstructorRegister, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOffStage, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOnStage, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypeNegative, NEGATIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliAlignmentGetAlignmentType, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliAlignmentSetScaling, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliAlignmentGetScaling, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliAlignmentSetPaddingPositive, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliAlignmentSetPaddingNegative, NEGATIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliAlignmentGetPadding, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliAlignmentChildAddAndRemove, POSITIVE_TC_IDX );
74 TEST_FUNCTION( UtcDaliAlignmentOnSizeSet, POSITIVE_TC_IDX );
75 TEST_FUNCTION( UtcDaliAlignmentOnTouchEvent, POSITIVE_TC_IDX );
76 TEST_FUNCTION( UtcDaliAlignmentOnKeyEvent, POSITIVE_TC_IDX );
77 TEST_FUNCTION( UtcDaliAlignmentOnSizeAnimation, POSITIVE_TC_IDX );
78 TEST_FUNCTION( UtcDaliAlignmentCopyAndAssignment, POSITIVE_TC_IDX );
80 // Called only once before first test is run.
85 // Called only once after last test is run
90 static void UtcDaliAlignmentConstructorNegative()
92 ToolkitTestApplication application;
98 Alignment::Padding padding;
99 alignment.SetPadding(padding);
100 tet_result(TET_FAIL);
102 catch (DaliException& exception)
104 if (exception.mCondition == "alignment")
106 tet_result(TET_PASS);
111 static void UtcDaliAlignmentConstructorPositive()
113 ToolkitTestApplication application;
115 Alignment alignment = Alignment::New();
119 Alignment::Padding padding;
120 alignment.SetPadding(padding);
121 tet_result(TET_PASS);
123 catch (DaliException& exception)
125 tet_result(TET_FAIL);
128 Actor actor = alignment;
129 alignment = Alignment::DownCast( actor );
131 DALI_TEST_CHECK( alignment );
134 static void UtcDaliAlignmentConstructorRegister()
136 ToolkitTestApplication application;
138 //Te ensure the object is registered after creation
139 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
140 DALI_TEST_CHECK( registry );
142 gObjectCreatedCallBackCalled = false;
143 registry.ObjectCreatedSignal().Connect(&TestCallback);
145 Alignment alignment = Alignment::New();
147 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
150 static void UtcDaliAlignmentSetAlignmentTypePositiveOffStage()
152 ToolkitTestApplication application;
154 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
156 Alignment alignment = Alignment::New();
158 // Check default values
159 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
161 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
162 alignment.SetAlignmentType(type);
163 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
166 // HorizontalLeft, VerticalCenter
168 Alignment alignment = Alignment::New();
170 // Check default values
171 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
173 Alignment::Type type(Alignment::HorizontalLeft);
174 alignment.SetAlignmentType(type);
175 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
178 // HorizontalRight, VerticalCenter
180 Alignment alignment = Alignment::New();
182 // Check default values
183 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
185 Alignment::Type type(Alignment::HorizontalRight);
186 alignment.SetAlignmentType(type);
187 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
190 // HorizontalLeft, VerticalTop
192 Alignment alignment = Alignment::New();
194 // Check default values
195 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
197 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
198 alignment.SetAlignmentType(type);
199 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
202 // HorizontalCenter, VerticalTop
204 Alignment alignment = Alignment::New();
206 // Check default values
207 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
209 Alignment::Type type(Alignment::VerticalTop);
210 alignment.SetAlignmentType(type);
211 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
214 // HorizontalRight, VerticalTop
216 Alignment alignment = Alignment::New();
218 // Check default values
219 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
221 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
222 alignment.SetAlignmentType(type);
223 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
226 // HorizontalLeft, VerticalBottom
228 Alignment alignment = Alignment::New();
230 // Check default values
231 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
233 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
234 alignment.SetAlignmentType(type);
235 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
238 // HorizontalCenter, VerticalBottom
240 Alignment alignment = Alignment::New();
242 // Check default values
243 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
245 Alignment::Type type(Alignment::VerticalBottom);
246 alignment.SetAlignmentType(type);
247 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
250 // HorizontalRight, VerticalBottom
252 Alignment alignment = Alignment::New();
254 // Check default values
255 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
257 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
258 alignment.SetAlignmentType(type);
259 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
263 static void UtcDaliAlignmentSetAlignmentTypePositiveOnStage()
265 ToolkitTestApplication application;
267 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
269 Alignment alignment = Alignment::New();
270 alignment.Add(RenderableActor::New());
271 Stage::GetCurrent().Add(alignment);
272 application.Render();
273 application.SendNotification();
275 // Check default values
276 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
278 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
279 alignment.SetAlignmentType(type);
280 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
282 Stage::GetCurrent().Remove(alignment);
283 application.Render();
284 application.SendNotification();
287 // HorizontalLeft, VerticalCenter
289 Alignment alignment = Alignment::New();
290 alignment.Add(RenderableActor::New());
291 Stage::GetCurrent().Add(alignment);
292 application.Render();
293 application.SendNotification();
295 // Check default values
296 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
298 Alignment::Type type(Alignment::HorizontalLeft);
299 alignment.SetAlignmentType(type);
300 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
302 Stage::GetCurrent().Remove(alignment);
303 application.Render();
304 application.SendNotification();
307 // HorizontalRight, VerticalCenter
309 Alignment alignment = Alignment::New();
310 alignment.Add(RenderableActor::New());
311 Stage::GetCurrent().Add(alignment);
312 application.Render();
313 application.SendNotification();
315 // Check default values
316 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
318 Alignment::Type type(Alignment::HorizontalRight);
319 alignment.SetAlignmentType(type);
320 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
322 Stage::GetCurrent().Remove(alignment);
323 application.Render();
324 application.SendNotification();
327 // HorizontalLeft, VerticalTop
329 Alignment alignment = Alignment::New();
330 alignment.Add(RenderableActor::New());
331 Stage::GetCurrent().Add(alignment);
332 application.Render();
333 application.SendNotification();
335 // Check default values
336 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
338 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
339 alignment.SetAlignmentType(type);
340 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
342 Stage::GetCurrent().Remove(alignment);
343 application.Render();
344 application.SendNotification();
347 // HorizontalCenter, VerticalTop
349 Alignment alignment = Alignment::New();
350 alignment.Add(RenderableActor::New());
351 Stage::GetCurrent().Add(alignment);
352 application.Render();
353 application.SendNotification();
355 // Check default values
356 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
358 Alignment::Type type(Alignment::VerticalTop);
359 alignment.SetAlignmentType(type);
360 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
362 Stage::GetCurrent().Remove(alignment);
363 application.Render();
364 application.SendNotification();
367 // HorizontalRight, VerticalTop
369 Alignment alignment = Alignment::New();
370 alignment.Add(RenderableActor::New());
371 Stage::GetCurrent().Add(alignment);
372 application.Render();
373 application.SendNotification();
375 // Check default values
376 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
378 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
379 alignment.SetAlignmentType(type);
380 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
382 Stage::GetCurrent().Remove(alignment);
383 application.Render();
384 application.SendNotification();
387 // HorizontalLeft, VerticalBottom
389 Alignment alignment = Alignment::New();
390 alignment.Add(RenderableActor::New());
391 Stage::GetCurrent().Add(alignment);
392 application.Render();
393 application.SendNotification();
395 // Check default values
396 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
398 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
399 alignment.SetAlignmentType(type);
400 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
402 Stage::GetCurrent().Remove(alignment);
403 application.Render();
404 application.SendNotification();
407 // HorizontalCenter, VerticalBottom
409 Alignment alignment = Alignment::New();
410 alignment.Add(RenderableActor::New());
411 Stage::GetCurrent().Add(alignment);
412 application.Render();
413 application.SendNotification();
415 // Check default values
416 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
418 Alignment::Type type(Alignment::VerticalBottom);
419 alignment.SetAlignmentType(type);
420 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
422 Stage::GetCurrent().Remove(alignment);
423 application.Render();
424 application.SendNotification();
427 // HorizontalRight, VerticalBottom
429 Alignment alignment = Alignment::New();
430 alignment.Add(RenderableActor::New());
431 Stage::GetCurrent().Add(alignment);
432 application.Render();
433 application.SendNotification();
435 // Check default values
436 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
438 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
439 alignment.SetAlignmentType(type);
440 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
442 Stage::GetCurrent().Remove(alignment);
443 application.Render();
444 application.SendNotification();
448 static void UtcDaliAlignmentSetAlignmentTypeNegative()
450 ToolkitTestApplication application;
452 // Setting HorizontalLeft, HorizontalCenter
454 Alignment alignment = Alignment::New();
455 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
459 alignment.SetAlignmentType(type);
460 tet_result(TET_FAIL);
462 catch (DaliException& exception)
464 if (exception.mCondition == "!horizontalSet")
466 tet_result(TET_PASS);
471 // Setting HorizontalCenter, HorizontalRight
473 Alignment alignment = Alignment::New();
474 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
478 alignment.SetAlignmentType(type);
479 tet_result(TET_FAIL);
481 catch (DaliException& exception)
483 if (exception.mCondition == "!horizontalSet")
485 tet_result(TET_PASS);
490 // Setting VerticalTop, VerticalCenter
492 Alignment alignment = Alignment::New();
493 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
497 alignment.SetAlignmentType(type);
498 tet_result(TET_FAIL);
500 catch (DaliException& exception)
502 if (exception.mCondition == "!verticalSet")
504 tet_result(TET_PASS);
509 // Setting VerticalCenter, VerticalBottom
511 Alignment alignment = Alignment::New();
512 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
516 alignment.SetAlignmentType(type);
517 tet_result(TET_FAIL);
519 catch (DaliException& exception)
521 if (exception.mCondition == "!veritcalSet")
523 tet_result(TET_PASS);
529 static void UtcDaliAlignmentGetAlignmentType()
531 ToolkitTestApplication application;
533 // Default, HorizonalCenter, VerticalCenter
535 Alignment alignment = Alignment::New();
536 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
537 alignment.Add(RenderableActor::New());
538 Stage::GetCurrent().Add(alignment);
539 application.Render();
540 application.SendNotification();
541 Stage::GetCurrent().Remove(alignment);
542 application.Render();
543 application.SendNotification();
546 // HorizontalLeft, VerticalCenter
548 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
549 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
550 alignment.Add(RenderableActor::New());
551 Stage::GetCurrent().Add(alignment);
552 application.Render();
553 application.SendNotification();
554 Stage::GetCurrent().Remove(alignment);
555 application.Render();
556 application.SendNotification();
559 // HorizontalRight, VerticalCenter
561 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
562 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
563 alignment.Add(RenderableActor::New());
564 Stage::GetCurrent().Add(alignment);
565 application.Render();
566 application.SendNotification();
567 Stage::GetCurrent().Remove(alignment);
568 application.Render();
569 application.SendNotification();
572 // HorizontalLeft, VerticalTop
574 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
575 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
576 alignment.Add(RenderableActor::New());
577 Stage::GetCurrent().Add(alignment);
578 application.Render();
579 application.SendNotification();
580 Stage::GetCurrent().Remove(alignment);
581 application.Render();
582 application.SendNotification();
585 // HorizontalCenter, VerticalTop
587 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
588 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
589 alignment.Add(RenderableActor::New());
590 Stage::GetCurrent().Add(alignment);
591 application.Render();
592 application.SendNotification();
593 Stage::GetCurrent().Remove(alignment);
594 application.Render();
595 application.SendNotification();
598 // HorizontalRight, VerticalTop
600 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
601 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
602 alignment.Add(RenderableActor::New());
603 Stage::GetCurrent().Add(alignment);
604 application.Render();
605 application.SendNotification();
606 Stage::GetCurrent().Remove(alignment);
607 application.Render();
608 application.SendNotification();
611 // HorizontalLeft, VerticalBottom
613 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
614 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
615 alignment.Add(RenderableActor::New());
616 Stage::GetCurrent().Add(alignment);
617 application.Render();
618 application.SendNotification();
619 Stage::GetCurrent().Remove(alignment);
620 application.Render();
621 application.SendNotification();
624 // HorizontalCenter, VerticalBottom
626 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
627 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
628 alignment.Add(RenderableActor::New());
629 Stage::GetCurrent().Add(alignment);
630 application.Render();
631 application.SendNotification();
632 Stage::GetCurrent().Remove(alignment);
633 application.Render();
634 application.SendNotification();
637 // HorizontalRight, VerticalBottom
639 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
640 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
641 alignment.Add(RenderableActor::New());
642 Stage::GetCurrent().Add(alignment);
643 application.Render();
644 application.SendNotification();
645 Stage::GetCurrent().Remove(alignment);
646 application.Render();
647 application.SendNotification();
651 static void UtcDaliAlignmentSetScaling()
653 ToolkitTestApplication application;
657 Alignment alignment = Alignment::New();
658 alignment.Add(RenderableActor::New());
659 Stage::GetCurrent().Add(alignment);
660 application.Render();
661 application.SendNotification();
663 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
664 alignment.SetScaling(Alignment::ScaleToFill);
665 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
666 application.Render();
667 application.SendNotification();
669 // For complete line coverage
670 alignment.SetAlignmentType(Alignment::HorizontalLeft);
671 application.Render();
672 application.SendNotification();
673 alignment.SetAlignmentType(Alignment::HorizontalRight);
674 application.Render();
675 application.SendNotification();
676 alignment.SetAlignmentType(Alignment::VerticalTop);
677 application.Render();
678 application.SendNotification();
679 alignment.SetAlignmentType(Alignment::VerticalBottom);
680 application.Render();
681 application.SendNotification();
683 Stage::GetCurrent().Remove(alignment);
684 application.Render();
685 application.SendNotification();
688 // ScaleToFitKeepAspect
690 Alignment alignment = Alignment::New();
691 alignment.Add(RenderableActor::New());
692 Stage::GetCurrent().Add(alignment);
693 application.Render();
694 application.SendNotification();
696 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
697 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
698 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
699 application.Render();
700 application.SendNotification();
702 // For complete line coverage
703 alignment.SetAlignmentType(Alignment::HorizontalLeft);
704 application.Render();
705 application.SendNotification();
706 alignment.SetAlignmentType(Alignment::HorizontalRight);
707 application.Render();
708 application.SendNotification();
709 alignment.SetAlignmentType(Alignment::VerticalTop);
710 application.Render();
711 application.SendNotification();
712 alignment.SetAlignmentType(Alignment::VerticalBottom);
713 application.Render();
714 application.SendNotification();
716 Stage::GetCurrent().Remove(alignment);
717 application.Render();
718 application.SendNotification();
721 // ScaleToFillKeepAspect
723 Alignment alignment = Alignment::New();
724 alignment.Add(RenderableActor::New());
725 Stage::GetCurrent().Add(alignment);
726 application.Render();
727 application.SendNotification();
729 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
730 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
731 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
732 application.Render();
733 application.SendNotification();
735 // For complete line coverage
736 alignment.SetAlignmentType(Alignment::HorizontalLeft);
737 application.Render();
738 application.SendNotification();
739 alignment.SetAlignmentType(Alignment::HorizontalRight);
740 application.Render();
741 application.SendNotification();
742 alignment.SetAlignmentType(Alignment::VerticalTop);
743 application.Render();
744 application.SendNotification();
745 alignment.SetAlignmentType(Alignment::VerticalBottom);
746 application.Render();
747 application.SendNotification();
749 Stage::GetCurrent().Remove(alignment);
750 application.Render();
751 application.SendNotification();
756 Alignment alignment = Alignment::New();
757 alignment.Add(RenderableActor::New());
758 Stage::GetCurrent().Add(alignment);
759 application.Render();
760 application.SendNotification();
762 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
763 alignment.SetScaling(Alignment::ShrinkToFit);
764 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
765 application.Render();
766 application.SendNotification();
768 // For complete line coverage
769 alignment.SetAlignmentType(Alignment::HorizontalLeft);
770 application.Render();
771 application.SendNotification();
772 alignment.SetAlignmentType(Alignment::HorizontalRight);
773 application.Render();
774 application.SendNotification();
775 alignment.SetAlignmentType(Alignment::VerticalTop);
776 application.Render();
777 application.SendNotification();
778 alignment.SetAlignmentType(Alignment::VerticalBottom);
779 application.Render();
780 application.SendNotification();
782 Stage::GetCurrent().Remove(alignment);
783 application.Render();
784 application.SendNotification();
787 // ShrinkToFitKeepAspect
789 Alignment alignment = Alignment::New();
790 alignment.Add(RenderableActor::New());
791 Stage::GetCurrent().Add(alignment);
792 application.Render();
793 application.SendNotification();
795 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
796 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
797 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
798 application.Render();
799 application.SendNotification();
801 // For complete line coverage
802 alignment.SetAlignmentType(Alignment::HorizontalLeft);
803 application.Render();
804 application.SendNotification();
805 alignment.SetAlignmentType(Alignment::HorizontalRight);
806 application.Render();
807 application.SendNotification();
808 alignment.SetAlignmentType(Alignment::VerticalTop);
809 application.Render();
810 application.SendNotification();
811 alignment.SetAlignmentType(Alignment::VerticalBottom);
812 application.Render();
813 application.SendNotification();
815 Stage::GetCurrent().Remove(alignment);
816 application.Render();
817 application.SendNotification();
821 static void UtcDaliAlignmentGetScaling()
823 ToolkitTestApplication application;
827 Alignment alignment = Alignment::New();
828 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
830 alignment.SetScaling(Alignment::ScaleToFill);
831 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
834 // ScaleToFitKeepAspect
836 Alignment alignment = Alignment::New();
837 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
839 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
840 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
843 // ScaleToFillKeepAspect
845 Alignment alignment = Alignment::New();
846 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
848 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
849 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
854 Alignment alignment = Alignment::New();
855 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
857 alignment.SetScaling(Alignment::ShrinkToFit);
858 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
861 // ShrinkToFitKeepAspect
863 Alignment alignment = Alignment::New();
864 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
866 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
867 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
872 static void UtcDaliAlignmentSetPaddingPositive()
874 ToolkitTestApplication application;
876 Alignment alignment = Alignment::New();
878 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
879 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
880 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
881 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
882 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
884 alignment.SetPadding(padding);
885 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
886 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
887 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
888 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
891 static void UtcDaliAlignmentSetPaddingNegative()
893 ToolkitTestApplication application;
895 Alignment alignment = Alignment::New();
899 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
900 alignment.SetPadding(padding);
901 tet_result(TET_FAIL);
903 catch (DaliException& exception)
905 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
907 tet_result(TET_PASS);
913 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
914 alignment.SetPadding(padding);
915 tet_result(TET_FAIL);
917 catch (DaliException& exception)
919 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
921 tet_result(TET_PASS);
927 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
928 alignment.SetPadding(padding);
929 tet_result(TET_FAIL);
931 catch (DaliException& exception)
933 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
935 tet_result(TET_PASS);
941 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
942 alignment.SetPadding(padding);
943 tet_result(TET_FAIL);
945 catch (DaliException& exception)
947 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
949 tet_result(TET_PASS);
954 static void UtcDaliAlignmentGetPadding()
956 ToolkitTestApplication application;
958 Alignment alignment = Alignment::New();
959 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
960 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
961 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
962 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
964 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
965 alignment.SetPadding(padding);
966 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
967 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
968 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
969 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
972 static void UtcDaliAlignmentChildAddAndRemove()
974 ToolkitTestApplication application;
976 Alignment alignment = Alignment::New();
977 Stage::GetCurrent().Add(alignment);
979 application.Render();
980 application.SendNotification();
982 Actor actor = RenderableActor::New();
983 alignment.Add(actor);
985 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
987 application.Render();
988 application.SendNotification();
990 alignment.Remove(actor);
992 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
994 application.Render();
995 application.SendNotification();
997 Stage::GetCurrent().Remove(alignment);
1000 static void UtcDaliAlignmentOnSizeSet()
1002 ToolkitTestApplication application;
1004 Alignment alignment = Alignment::New();
1005 Stage::GetCurrent().Add(alignment);
1007 application.Render();
1008 application.SendNotification();
1010 Vector3 size(100.0f, 200.0f, 0.0f);
1011 alignment.SetSize(size);
1013 application.Render();
1014 application.SendNotification();
1015 application.Render();
1016 application.SendNotification();
1018 DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
1020 Stage::GetCurrent().Remove(alignment);
1023 ///////////////////////////////////////////////////////////////////////////////
1024 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
1029 ///////////////////////////////////////////////////////////////////////////////
1031 static void UtcDaliAlignmentOnTouchEvent()
1033 ToolkitTestApplication application;
1035 Alignment alignment = Alignment::New();
1036 alignment.SetSize(100.0f, 100.0f);
1037 alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1038 Stage::GetCurrent().Add(alignment);
1040 alignment.TouchedSignal().Connect(&TouchEventCallback);
1042 application.Render();
1043 application.SendNotification();
1044 application.Render();
1045 application.SendNotification();
1047 Integration::TouchEvent touchEvent(1);
1048 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
1049 touchEvent.AddPoint(point);
1050 application.ProcessEvent(touchEvent);
1052 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1055 static void UtcDaliAlignmentOnKeyEvent()
1057 ToolkitTestApplication application;
1059 Alignment alignment = Alignment::New();
1060 Stage::GetCurrent().Add(alignment);
1062 alignment.SetKeyInputFocus();
1064 application.Render();
1065 application.SendNotification();
1066 application.Render();
1067 application.SendNotification();
1069 Integration::KeyEvent keyEvent;
1070 application.ProcessEvent(keyEvent);
1072 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1075 static void UtcDaliAlignmentOnSizeAnimation()
1077 ToolkitTestApplication application;
1079 Alignment alignment = Alignment::New();
1080 Stage::GetCurrent().Add(alignment);
1082 Animation animation = Animation::New(100.0f);
1083 animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
1086 application.Render();
1087 application.SendNotification();
1088 application.Render();
1089 application.SendNotification();
1091 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1094 static void UtcDaliAlignmentCopyAndAssignment()
1096 ToolkitTestApplication application;
1098 Alignment alignment = Alignment::New();
1099 Alignment emptyAlignment;
1101 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1102 alignment.SetPadding(padding);
1104 Alignment alignmentCopy(alignment);
1105 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1106 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1107 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1108 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1110 Alignment alignmentEmptyCopy(emptyAlignment);
1111 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1113 Alignment alignmentEquals;
1114 alignmentEquals = alignment;
1115 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1116 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1117 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1118 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1120 Alignment alignmentEmptyEquals;
1121 alignmentEmptyEquals = emptyAlignment;
1122 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1125 alignment = alignment;
1126 DALI_TEST_CHECK(alignment == alignmentCopy);