2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <dali/public-api/dali-core.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit-test-suite-utils.h>
31 using namespace Dali::Toolkit;
33 static void Startup();
34 static void Cleanup();
38 static bool gObjectCreatedCallBackCalled;
40 static void TestCallback(BaseHandle handle)
42 gObjectCreatedCallBackCalled = true;
47 void (*tet_startup)() = Startup;
48 void (*tet_cleanup)() = Cleanup;
52 POSITIVE_TC_IDX = 0x01,
56 #define MAX_NUMBER_OF_TESTS 10000
58 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
61 // Add test functionality for all APIs in the class (Positive and Negative)
62 TEST_FUNCTION( UtcDaliAlignmentConstructorNegative, NEGATIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliAlignmentConstructorPositive, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliAlignmentConstructorRegister, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOffStage, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOnStage, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypeNegative, NEGATIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliAlignmentGetAlignmentType, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliAlignmentSetScaling, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliAlignmentGetScaling, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliAlignmentSetPaddingPositive, POSITIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliAlignmentSetPaddingNegative, NEGATIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliAlignmentGetPadding, POSITIVE_TC_IDX );
74 TEST_FUNCTION( UtcDaliAlignmentChildAddAndRemove, POSITIVE_TC_IDX );
75 TEST_FUNCTION( UtcDaliAlignmentOnSizeSet, POSITIVE_TC_IDX );
76 TEST_FUNCTION( UtcDaliAlignmentOnTouchEvent, POSITIVE_TC_IDX );
77 TEST_FUNCTION( UtcDaliAlignmentOnKeyEvent, POSITIVE_TC_IDX );
78 TEST_FUNCTION( UtcDaliAlignmentOnSizeAnimation, POSITIVE_TC_IDX );
79 TEST_FUNCTION( UtcDaliAlignmentCopyAndAssignment, POSITIVE_TC_IDX );
81 // Called only once before first test is run.
86 // Called only once after last test is run
91 static void UtcDaliAlignmentConstructorNegative()
93 ToolkitTestApplication application;
99 Alignment::Padding padding;
100 alignment.SetPadding(padding);
101 tet_result(TET_FAIL);
103 catch (DaliException& exception)
105 if (exception.mCondition == "alignment")
107 tet_result(TET_PASS);
112 static void UtcDaliAlignmentConstructorPositive()
114 ToolkitTestApplication application;
116 Alignment alignment = Alignment::New();
120 Alignment::Padding padding;
121 alignment.SetPadding(padding);
122 tet_result(TET_PASS);
124 catch (DaliException& exception)
126 tet_result(TET_FAIL);
129 Actor actor = alignment;
130 alignment = Alignment::DownCast( actor );
132 DALI_TEST_CHECK( alignment );
135 static void UtcDaliAlignmentConstructorRegister()
137 ToolkitTestApplication application;
139 //Te ensure the object is registered after creation
140 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
141 DALI_TEST_CHECK( registry );
143 gObjectCreatedCallBackCalled = false;
144 registry.ObjectCreatedSignal().Connect(&TestCallback);
146 Alignment alignment = Alignment::New();
148 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
151 static void UtcDaliAlignmentSetAlignmentTypePositiveOffStage()
153 ToolkitTestApplication application;
155 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
157 Alignment alignment = Alignment::New();
159 // Check default values
160 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
162 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
163 alignment.SetAlignmentType(type);
164 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
167 // HorizontalLeft, VerticalCenter
169 Alignment alignment = Alignment::New();
171 // Check default values
172 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
174 Alignment::Type type(Alignment::HorizontalLeft);
175 alignment.SetAlignmentType(type);
176 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
179 // HorizontalRight, VerticalCenter
181 Alignment alignment = Alignment::New();
183 // Check default values
184 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
186 Alignment::Type type(Alignment::HorizontalRight);
187 alignment.SetAlignmentType(type);
188 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
191 // HorizontalLeft, VerticalTop
193 Alignment alignment = Alignment::New();
195 // Check default values
196 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
198 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
199 alignment.SetAlignmentType(type);
200 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
203 // HorizontalCenter, VerticalTop
205 Alignment alignment = Alignment::New();
207 // Check default values
208 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
210 Alignment::Type type(Alignment::VerticalTop);
211 alignment.SetAlignmentType(type);
212 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
215 // HorizontalRight, VerticalTop
217 Alignment alignment = Alignment::New();
219 // Check default values
220 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
222 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
223 alignment.SetAlignmentType(type);
224 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
227 // HorizontalLeft, VerticalBottom
229 Alignment alignment = Alignment::New();
231 // Check default values
232 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
234 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
235 alignment.SetAlignmentType(type);
236 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
239 // HorizontalCenter, VerticalBottom
241 Alignment alignment = Alignment::New();
243 // Check default values
244 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
246 Alignment::Type type(Alignment::VerticalBottom);
247 alignment.SetAlignmentType(type);
248 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
251 // HorizontalRight, VerticalBottom
253 Alignment alignment = Alignment::New();
255 // Check default values
256 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
258 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
259 alignment.SetAlignmentType(type);
260 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
264 static void UtcDaliAlignmentSetAlignmentTypePositiveOnStage()
266 ToolkitTestApplication application;
268 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
270 Alignment alignment = Alignment::New();
271 alignment.Add(RenderableActor::New());
272 Stage::GetCurrent().Add(alignment);
273 application.Render();
274 application.SendNotification();
276 // Check default values
277 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
279 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
280 alignment.SetAlignmentType(type);
281 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
283 Stage::GetCurrent().Remove(alignment);
284 application.Render();
285 application.SendNotification();
288 // HorizontalLeft, VerticalCenter
290 Alignment alignment = Alignment::New();
291 alignment.Add(RenderableActor::New());
292 Stage::GetCurrent().Add(alignment);
293 application.Render();
294 application.SendNotification();
296 // Check default values
297 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
299 Alignment::Type type(Alignment::HorizontalLeft);
300 alignment.SetAlignmentType(type);
301 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
303 Stage::GetCurrent().Remove(alignment);
304 application.Render();
305 application.SendNotification();
308 // HorizontalRight, VerticalCenter
310 Alignment alignment = Alignment::New();
311 alignment.Add(RenderableActor::New());
312 Stage::GetCurrent().Add(alignment);
313 application.Render();
314 application.SendNotification();
316 // Check default values
317 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
319 Alignment::Type type(Alignment::HorizontalRight);
320 alignment.SetAlignmentType(type);
321 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
323 Stage::GetCurrent().Remove(alignment);
324 application.Render();
325 application.SendNotification();
328 // HorizontalLeft, VerticalTop
330 Alignment alignment = Alignment::New();
331 alignment.Add(RenderableActor::New());
332 Stage::GetCurrent().Add(alignment);
333 application.Render();
334 application.SendNotification();
336 // Check default values
337 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
339 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
340 alignment.SetAlignmentType(type);
341 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
343 Stage::GetCurrent().Remove(alignment);
344 application.Render();
345 application.SendNotification();
348 // HorizontalCenter, VerticalTop
350 Alignment alignment = Alignment::New();
351 alignment.Add(RenderableActor::New());
352 Stage::GetCurrent().Add(alignment);
353 application.Render();
354 application.SendNotification();
356 // Check default values
357 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
359 Alignment::Type type(Alignment::VerticalTop);
360 alignment.SetAlignmentType(type);
361 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
363 Stage::GetCurrent().Remove(alignment);
364 application.Render();
365 application.SendNotification();
368 // HorizontalRight, VerticalTop
370 Alignment alignment = Alignment::New();
371 alignment.Add(RenderableActor::New());
372 Stage::GetCurrent().Add(alignment);
373 application.Render();
374 application.SendNotification();
376 // Check default values
377 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
379 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
380 alignment.SetAlignmentType(type);
381 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
383 Stage::GetCurrent().Remove(alignment);
384 application.Render();
385 application.SendNotification();
388 // HorizontalLeft, VerticalBottom
390 Alignment alignment = Alignment::New();
391 alignment.Add(RenderableActor::New());
392 Stage::GetCurrent().Add(alignment);
393 application.Render();
394 application.SendNotification();
396 // Check default values
397 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
399 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
400 alignment.SetAlignmentType(type);
401 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
403 Stage::GetCurrent().Remove(alignment);
404 application.Render();
405 application.SendNotification();
408 // HorizontalCenter, VerticalBottom
410 Alignment alignment = Alignment::New();
411 alignment.Add(RenderableActor::New());
412 Stage::GetCurrent().Add(alignment);
413 application.Render();
414 application.SendNotification();
416 // Check default values
417 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
419 Alignment::Type type(Alignment::VerticalBottom);
420 alignment.SetAlignmentType(type);
421 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
423 Stage::GetCurrent().Remove(alignment);
424 application.Render();
425 application.SendNotification();
428 // HorizontalRight, VerticalBottom
430 Alignment alignment = Alignment::New();
431 alignment.Add(RenderableActor::New());
432 Stage::GetCurrent().Add(alignment);
433 application.Render();
434 application.SendNotification();
436 // Check default values
437 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
439 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
440 alignment.SetAlignmentType(type);
441 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
443 Stage::GetCurrent().Remove(alignment);
444 application.Render();
445 application.SendNotification();
449 static void UtcDaliAlignmentSetAlignmentTypeNegative()
451 ToolkitTestApplication application;
453 // Setting HorizontalLeft, HorizontalCenter
455 Alignment alignment = Alignment::New();
456 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
460 alignment.SetAlignmentType(type);
461 tet_result(TET_FAIL);
463 catch (DaliException& exception)
465 if (exception.mCondition == "!horizontalSet")
467 tet_result(TET_PASS);
472 // Setting HorizontalCenter, HorizontalRight
474 Alignment alignment = Alignment::New();
475 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
479 alignment.SetAlignmentType(type);
480 tet_result(TET_FAIL);
482 catch (DaliException& exception)
484 if (exception.mCondition == "!horizontalSet")
486 tet_result(TET_PASS);
491 // Setting VerticalTop, VerticalCenter
493 Alignment alignment = Alignment::New();
494 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
498 alignment.SetAlignmentType(type);
499 tet_result(TET_FAIL);
501 catch (DaliException& exception)
503 if (exception.mCondition == "!verticalSet")
505 tet_result(TET_PASS);
510 // Setting VerticalCenter, VerticalBottom
512 Alignment alignment = Alignment::New();
513 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
517 alignment.SetAlignmentType(type);
518 tet_result(TET_FAIL);
520 catch (DaliException& exception)
522 if (exception.mCondition == "!veritcalSet")
524 tet_result(TET_PASS);
530 static void UtcDaliAlignmentGetAlignmentType()
532 ToolkitTestApplication application;
534 // Default, HorizonalCenter, VerticalCenter
536 Alignment alignment = Alignment::New();
537 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
538 alignment.Add(RenderableActor::New());
539 Stage::GetCurrent().Add(alignment);
540 application.Render();
541 application.SendNotification();
542 Stage::GetCurrent().Remove(alignment);
543 application.Render();
544 application.SendNotification();
547 // HorizontalLeft, VerticalCenter
549 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
550 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
551 alignment.Add(RenderableActor::New());
552 Stage::GetCurrent().Add(alignment);
553 application.Render();
554 application.SendNotification();
555 Stage::GetCurrent().Remove(alignment);
556 application.Render();
557 application.SendNotification();
560 // HorizontalRight, VerticalCenter
562 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
563 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
564 alignment.Add(RenderableActor::New());
565 Stage::GetCurrent().Add(alignment);
566 application.Render();
567 application.SendNotification();
568 Stage::GetCurrent().Remove(alignment);
569 application.Render();
570 application.SendNotification();
573 // HorizontalLeft, VerticalTop
575 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
576 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
577 alignment.Add(RenderableActor::New());
578 Stage::GetCurrent().Add(alignment);
579 application.Render();
580 application.SendNotification();
581 Stage::GetCurrent().Remove(alignment);
582 application.Render();
583 application.SendNotification();
586 // HorizontalCenter, VerticalTop
588 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
589 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
590 alignment.Add(RenderableActor::New());
591 Stage::GetCurrent().Add(alignment);
592 application.Render();
593 application.SendNotification();
594 Stage::GetCurrent().Remove(alignment);
595 application.Render();
596 application.SendNotification();
599 // HorizontalRight, VerticalTop
601 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
602 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
603 alignment.Add(RenderableActor::New());
604 Stage::GetCurrent().Add(alignment);
605 application.Render();
606 application.SendNotification();
607 Stage::GetCurrent().Remove(alignment);
608 application.Render();
609 application.SendNotification();
612 // HorizontalLeft, VerticalBottom
614 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
615 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
616 alignment.Add(RenderableActor::New());
617 Stage::GetCurrent().Add(alignment);
618 application.Render();
619 application.SendNotification();
620 Stage::GetCurrent().Remove(alignment);
621 application.Render();
622 application.SendNotification();
625 // HorizontalCenter, VerticalBottom
627 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
628 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
629 alignment.Add(RenderableActor::New());
630 Stage::GetCurrent().Add(alignment);
631 application.Render();
632 application.SendNotification();
633 Stage::GetCurrent().Remove(alignment);
634 application.Render();
635 application.SendNotification();
638 // HorizontalRight, VerticalBottom
640 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
641 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
642 alignment.Add(RenderableActor::New());
643 Stage::GetCurrent().Add(alignment);
644 application.Render();
645 application.SendNotification();
646 Stage::GetCurrent().Remove(alignment);
647 application.Render();
648 application.SendNotification();
652 static void UtcDaliAlignmentSetScaling()
654 ToolkitTestApplication application;
658 Alignment alignment = Alignment::New();
659 alignment.Add(RenderableActor::New());
660 Stage::GetCurrent().Add(alignment);
661 application.Render();
662 application.SendNotification();
664 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
665 alignment.SetScaling(Alignment::ScaleToFill);
666 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
667 application.Render();
668 application.SendNotification();
670 // For complete line coverage
671 alignment.SetAlignmentType(Alignment::HorizontalLeft);
672 application.Render();
673 application.SendNotification();
674 alignment.SetAlignmentType(Alignment::HorizontalRight);
675 application.Render();
676 application.SendNotification();
677 alignment.SetAlignmentType(Alignment::VerticalTop);
678 application.Render();
679 application.SendNotification();
680 alignment.SetAlignmentType(Alignment::VerticalBottom);
681 application.Render();
682 application.SendNotification();
684 Stage::GetCurrent().Remove(alignment);
685 application.Render();
686 application.SendNotification();
689 // ScaleToFitKeepAspect
691 Alignment alignment = Alignment::New();
692 alignment.Add(RenderableActor::New());
693 Stage::GetCurrent().Add(alignment);
694 application.Render();
695 application.SendNotification();
697 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
698 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
699 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
700 application.Render();
701 application.SendNotification();
703 // For complete line coverage
704 alignment.SetAlignmentType(Alignment::HorizontalLeft);
705 application.Render();
706 application.SendNotification();
707 alignment.SetAlignmentType(Alignment::HorizontalRight);
708 application.Render();
709 application.SendNotification();
710 alignment.SetAlignmentType(Alignment::VerticalTop);
711 application.Render();
712 application.SendNotification();
713 alignment.SetAlignmentType(Alignment::VerticalBottom);
714 application.Render();
715 application.SendNotification();
717 Stage::GetCurrent().Remove(alignment);
718 application.Render();
719 application.SendNotification();
722 // ScaleToFillKeepAspect
724 Alignment alignment = Alignment::New();
725 alignment.Add(RenderableActor::New());
726 Stage::GetCurrent().Add(alignment);
727 application.Render();
728 application.SendNotification();
730 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
731 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
732 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
733 application.Render();
734 application.SendNotification();
736 // For complete line coverage
737 alignment.SetAlignmentType(Alignment::HorizontalLeft);
738 application.Render();
739 application.SendNotification();
740 alignment.SetAlignmentType(Alignment::HorizontalRight);
741 application.Render();
742 application.SendNotification();
743 alignment.SetAlignmentType(Alignment::VerticalTop);
744 application.Render();
745 application.SendNotification();
746 alignment.SetAlignmentType(Alignment::VerticalBottom);
747 application.Render();
748 application.SendNotification();
750 Stage::GetCurrent().Remove(alignment);
751 application.Render();
752 application.SendNotification();
757 Alignment alignment = Alignment::New();
758 alignment.Add(RenderableActor::New());
759 Stage::GetCurrent().Add(alignment);
760 application.Render();
761 application.SendNotification();
763 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
764 alignment.SetScaling(Alignment::ShrinkToFit);
765 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
766 application.Render();
767 application.SendNotification();
769 // For complete line coverage
770 alignment.SetAlignmentType(Alignment::HorizontalLeft);
771 application.Render();
772 application.SendNotification();
773 alignment.SetAlignmentType(Alignment::HorizontalRight);
774 application.Render();
775 application.SendNotification();
776 alignment.SetAlignmentType(Alignment::VerticalTop);
777 application.Render();
778 application.SendNotification();
779 alignment.SetAlignmentType(Alignment::VerticalBottom);
780 application.Render();
781 application.SendNotification();
783 Stage::GetCurrent().Remove(alignment);
784 application.Render();
785 application.SendNotification();
788 // ShrinkToFitKeepAspect
790 Alignment alignment = Alignment::New();
791 alignment.Add(RenderableActor::New());
792 Stage::GetCurrent().Add(alignment);
793 application.Render();
794 application.SendNotification();
796 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
797 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
798 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
799 application.Render();
800 application.SendNotification();
802 // For complete line coverage
803 alignment.SetAlignmentType(Alignment::HorizontalLeft);
804 application.Render();
805 application.SendNotification();
806 alignment.SetAlignmentType(Alignment::HorizontalRight);
807 application.Render();
808 application.SendNotification();
809 alignment.SetAlignmentType(Alignment::VerticalTop);
810 application.Render();
811 application.SendNotification();
812 alignment.SetAlignmentType(Alignment::VerticalBottom);
813 application.Render();
814 application.SendNotification();
816 Stage::GetCurrent().Remove(alignment);
817 application.Render();
818 application.SendNotification();
822 static void UtcDaliAlignmentGetScaling()
824 ToolkitTestApplication application;
828 Alignment alignment = Alignment::New();
829 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
831 alignment.SetScaling(Alignment::ScaleToFill);
832 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
835 // ScaleToFitKeepAspect
837 Alignment alignment = Alignment::New();
838 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
840 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
841 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
844 // ScaleToFillKeepAspect
846 Alignment alignment = Alignment::New();
847 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
849 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
850 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
855 Alignment alignment = Alignment::New();
856 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
858 alignment.SetScaling(Alignment::ShrinkToFit);
859 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
862 // ShrinkToFitKeepAspect
864 Alignment alignment = Alignment::New();
865 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
867 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
868 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
873 static void UtcDaliAlignmentSetPaddingPositive()
875 ToolkitTestApplication application;
877 Alignment alignment = Alignment::New();
879 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
880 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
881 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
882 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
883 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
885 alignment.SetPadding(padding);
886 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
887 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
888 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
889 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
892 static void UtcDaliAlignmentSetPaddingNegative()
894 ToolkitTestApplication application;
896 Alignment alignment = Alignment::New();
900 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
901 alignment.SetPadding(padding);
902 tet_result(TET_FAIL);
904 catch (DaliException& exception)
906 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
908 tet_result(TET_PASS);
914 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
915 alignment.SetPadding(padding);
916 tet_result(TET_FAIL);
918 catch (DaliException& exception)
920 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
922 tet_result(TET_PASS);
928 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
929 alignment.SetPadding(padding);
930 tet_result(TET_FAIL);
932 catch (DaliException& exception)
934 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
936 tet_result(TET_PASS);
942 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
943 alignment.SetPadding(padding);
944 tet_result(TET_FAIL);
946 catch (DaliException& exception)
948 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
950 tet_result(TET_PASS);
955 static void UtcDaliAlignmentGetPadding()
957 ToolkitTestApplication application;
959 Alignment alignment = Alignment::New();
960 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
961 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
962 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
963 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
965 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
966 alignment.SetPadding(padding);
967 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
968 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
969 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
970 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
973 static void UtcDaliAlignmentChildAddAndRemove()
975 ToolkitTestApplication application;
977 Alignment alignment = Alignment::New();
978 Stage::GetCurrent().Add(alignment);
980 application.Render();
981 application.SendNotification();
983 Actor actor = RenderableActor::New();
984 alignment.Add(actor);
986 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
988 application.Render();
989 application.SendNotification();
991 alignment.Remove(actor);
993 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
995 application.Render();
996 application.SendNotification();
998 Stage::GetCurrent().Remove(alignment);
1001 static void UtcDaliAlignmentOnSizeSet()
1003 ToolkitTestApplication application;
1005 Alignment alignment = Alignment::New();
1006 Stage::GetCurrent().Add(alignment);
1008 application.Render();
1009 application.SendNotification();
1011 Vector3 size(100.0f, 200.0f, 0.0f);
1012 alignment.SetSize(size);
1014 application.Render();
1015 application.SendNotification();
1016 application.Render();
1017 application.SendNotification();
1019 DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
1021 Stage::GetCurrent().Remove(alignment);
1024 ///////////////////////////////////////////////////////////////////////////////
1025 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
1030 ///////////////////////////////////////////////////////////////////////////////
1032 static void UtcDaliAlignmentOnTouchEvent()
1034 ToolkitTestApplication application;
1036 Alignment alignment = Alignment::New();
1037 alignment.SetSize(100.0f, 100.0f);
1038 alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1039 Stage::GetCurrent().Add(alignment);
1041 alignment.TouchedSignal().Connect(&TouchEventCallback);
1043 application.Render();
1044 application.SendNotification();
1045 application.Render();
1046 application.SendNotification();
1048 Integration::TouchEvent touchEvent(1);
1049 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
1050 touchEvent.AddPoint(point);
1051 application.ProcessEvent(touchEvent);
1053 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1056 static void UtcDaliAlignmentOnKeyEvent()
1058 ToolkitTestApplication application;
1060 Alignment alignment = Alignment::New();
1061 Stage::GetCurrent().Add(alignment);
1063 alignment.SetKeyInputFocus();
1065 application.Render();
1066 application.SendNotification();
1067 application.Render();
1068 application.SendNotification();
1070 Integration::KeyEvent keyEvent;
1071 application.ProcessEvent(keyEvent);
1073 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1076 static void UtcDaliAlignmentOnSizeAnimation()
1078 ToolkitTestApplication application;
1080 Alignment alignment = Alignment::New();
1081 Stage::GetCurrent().Add(alignment);
1083 Animation animation = Animation::New(100.0f);
1084 animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
1087 application.Render();
1088 application.SendNotification();
1089 application.Render();
1090 application.SendNotification();
1092 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1095 static void UtcDaliAlignmentCopyAndAssignment()
1097 ToolkitTestApplication application;
1099 Alignment alignment = Alignment::New();
1100 Alignment emptyAlignment;
1102 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1103 alignment.SetPadding(padding);
1105 Alignment alignmentCopy(alignment);
1106 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1107 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1108 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1109 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1111 Alignment alignmentEmptyCopy(emptyAlignment);
1112 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1114 Alignment alignmentEquals;
1115 alignmentEquals = alignment;
1116 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1117 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1118 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1119 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1121 Alignment alignmentEmptyEquals;
1122 alignmentEmptyEquals = emptyAlignment;
1123 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1126 alignment = alignment;
1127 DALI_TEST_CHECK(alignment == alignmentCopy);