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.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.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>
29 using namespace Dali::Toolkit;
31 void utc_dali_toolkit_alignment_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_toolkit_alignment_cleanup(void)
38 test_return_value = TET_PASS;
44 static bool gObjectCreatedCallBackCalled;
46 static void TestCallback(BaseHandle handle)
48 gObjectCreatedCallBackCalled = true;
53 int UtcDaliAlignmentConstructorNegative(void)
55 ToolkitTestApplication application;
61 Alignment::Padding padding;
62 alignment.SetPadding(padding);
65 catch (DaliException& exception)
67 if (exception.mCondition == "alignment")
75 int UtcDaliAlignmentConstructorPositive(void)
77 ToolkitTestApplication application;
79 Alignment alignment = Alignment::New();
83 Alignment::Padding padding;
84 alignment.SetPadding(padding);
87 catch (DaliException& exception)
92 Actor actor = alignment;
93 alignment = Alignment::DownCast( actor );
95 DALI_TEST_CHECK( alignment );
99 int UtcDaliAlignmentConstructorRegister(void)
101 ToolkitTestApplication application;
103 //Te ensure the object is registered after creation
104 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
105 DALI_TEST_CHECK( registry );
107 gObjectCreatedCallBackCalled = false;
108 registry.ObjectCreatedSignal().Connect(&TestCallback);
110 Alignment alignment = Alignment::New();
112 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
116 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
118 ToolkitTestApplication application;
120 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
122 Alignment alignment = Alignment::New();
124 // Check default values
125 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
127 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
128 alignment.SetAlignmentType(type);
129 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
132 // HorizontalLeft, VerticalCenter
134 Alignment alignment = Alignment::New();
136 // Check default values
137 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
139 Alignment::Type type(Alignment::HorizontalLeft);
140 alignment.SetAlignmentType(type);
141 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
144 // HorizontalRight, VerticalCenter
146 Alignment alignment = Alignment::New();
148 // Check default values
149 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
151 Alignment::Type type(Alignment::HorizontalRight);
152 alignment.SetAlignmentType(type);
153 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
156 // HorizontalLeft, VerticalTop
158 Alignment alignment = Alignment::New();
160 // Check default values
161 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
163 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
164 alignment.SetAlignmentType(type);
165 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
168 // HorizontalCenter, VerticalTop
170 Alignment alignment = Alignment::New();
172 // Check default values
173 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
175 Alignment::Type type(Alignment::VerticalTop);
176 alignment.SetAlignmentType(type);
177 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
180 // HorizontalRight, VerticalTop
182 Alignment alignment = Alignment::New();
184 // Check default values
185 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
187 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
188 alignment.SetAlignmentType(type);
189 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
192 // HorizontalLeft, VerticalBottom
194 Alignment alignment = Alignment::New();
196 // Check default values
197 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
199 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
200 alignment.SetAlignmentType(type);
201 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
204 // HorizontalCenter, VerticalBottom
206 Alignment alignment = Alignment::New();
208 // Check default values
209 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
211 Alignment::Type type(Alignment::VerticalBottom);
212 alignment.SetAlignmentType(type);
213 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
216 // HorizontalRight, VerticalBottom
218 Alignment alignment = Alignment::New();
220 // Check default values
221 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
223 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
224 alignment.SetAlignmentType(type);
225 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
230 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
232 ToolkitTestApplication application;
234 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
236 Alignment alignment = Alignment::New();
237 alignment.Add(RenderableActor::New());
238 Stage::GetCurrent().Add(alignment);
239 application.Render();
240 application.SendNotification();
242 // Check default values
243 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
245 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
246 alignment.SetAlignmentType(type);
247 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
249 Stage::GetCurrent().Remove(alignment);
250 application.Render();
251 application.SendNotification();
254 // HorizontalLeft, VerticalCenter
256 Alignment alignment = Alignment::New();
257 alignment.Add(RenderableActor::New());
258 Stage::GetCurrent().Add(alignment);
259 application.Render();
260 application.SendNotification();
262 // Check default values
263 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
265 Alignment::Type type(Alignment::HorizontalLeft);
266 alignment.SetAlignmentType(type);
267 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
269 Stage::GetCurrent().Remove(alignment);
270 application.Render();
271 application.SendNotification();
274 // HorizontalRight, VerticalCenter
276 Alignment alignment = Alignment::New();
277 alignment.Add(RenderableActor::New());
278 Stage::GetCurrent().Add(alignment);
279 application.Render();
280 application.SendNotification();
282 // Check default values
283 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
285 Alignment::Type type(Alignment::HorizontalRight);
286 alignment.SetAlignmentType(type);
287 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
289 Stage::GetCurrent().Remove(alignment);
290 application.Render();
291 application.SendNotification();
294 // HorizontalLeft, VerticalTop
296 Alignment alignment = Alignment::New();
297 alignment.Add(RenderableActor::New());
298 Stage::GetCurrent().Add(alignment);
299 application.Render();
300 application.SendNotification();
302 // Check default values
303 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
305 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
306 alignment.SetAlignmentType(type);
307 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
309 Stage::GetCurrent().Remove(alignment);
310 application.Render();
311 application.SendNotification();
314 // HorizontalCenter, VerticalTop
316 Alignment alignment = Alignment::New();
317 alignment.Add(RenderableActor::New());
318 Stage::GetCurrent().Add(alignment);
319 application.Render();
320 application.SendNotification();
322 // Check default values
323 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
325 Alignment::Type type(Alignment::VerticalTop);
326 alignment.SetAlignmentType(type);
327 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
329 Stage::GetCurrent().Remove(alignment);
330 application.Render();
331 application.SendNotification();
334 // HorizontalRight, VerticalTop
336 Alignment alignment = Alignment::New();
337 alignment.Add(RenderableActor::New());
338 Stage::GetCurrent().Add(alignment);
339 application.Render();
340 application.SendNotification();
342 // Check default values
343 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
345 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
346 alignment.SetAlignmentType(type);
347 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
349 Stage::GetCurrent().Remove(alignment);
350 application.Render();
351 application.SendNotification();
354 // HorizontalLeft, VerticalBottom
356 Alignment alignment = Alignment::New();
357 alignment.Add(RenderableActor::New());
358 Stage::GetCurrent().Add(alignment);
359 application.Render();
360 application.SendNotification();
362 // Check default values
363 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
365 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
366 alignment.SetAlignmentType(type);
367 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
369 Stage::GetCurrent().Remove(alignment);
370 application.Render();
371 application.SendNotification();
374 // HorizontalCenter, VerticalBottom
376 Alignment alignment = Alignment::New();
377 alignment.Add(RenderableActor::New());
378 Stage::GetCurrent().Add(alignment);
379 application.Render();
380 application.SendNotification();
382 // Check default values
383 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
385 Alignment::Type type(Alignment::VerticalBottom);
386 alignment.SetAlignmentType(type);
387 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
389 Stage::GetCurrent().Remove(alignment);
390 application.Render();
391 application.SendNotification();
394 // HorizontalRight, VerticalBottom
396 Alignment alignment = Alignment::New();
397 alignment.Add(RenderableActor::New());
398 Stage::GetCurrent().Add(alignment);
399 application.Render();
400 application.SendNotification();
402 // Check default values
403 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
405 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
406 alignment.SetAlignmentType(type);
407 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
409 Stage::GetCurrent().Remove(alignment);
410 application.Render();
411 application.SendNotification();
416 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
418 ToolkitTestApplication application;
420 // Setting HorizontalLeft, HorizontalCenter
422 Alignment alignment = Alignment::New();
423 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
427 alignment.SetAlignmentType(type);
428 tet_result(TET_FAIL);
430 catch (DaliException& exception)
432 if (exception.mCondition == "!horizontalSet")
434 tet_result(TET_PASS);
439 // Setting HorizontalCenter, HorizontalRight
441 Alignment alignment = Alignment::New();
442 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
446 alignment.SetAlignmentType(type);
447 tet_result(TET_FAIL);
449 catch (DaliException& exception)
451 if (exception.mCondition == "!horizontalSet")
453 tet_result(TET_PASS);
458 // Setting VerticalTop, VerticalCenter
460 Alignment alignment = Alignment::New();
461 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
465 alignment.SetAlignmentType(type);
466 tet_result(TET_FAIL);
468 catch (DaliException& exception)
470 if (exception.mCondition == "!verticalSet")
472 tet_result(TET_PASS);
477 // Setting VerticalCenter, VerticalBottom
479 Alignment alignment = Alignment::New();
480 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
484 alignment.SetAlignmentType(type);
485 tet_result(TET_FAIL);
487 catch (DaliException& exception)
489 if (exception.mCondition == "!veritcalSet")
491 tet_result(TET_PASS);
498 int UtcDaliAlignmentGetAlignmentType(void)
500 ToolkitTestApplication application;
502 // Default, HorizonalCenter, VerticalCenter
504 Alignment alignment = Alignment::New();
505 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
506 alignment.Add(RenderableActor::New());
507 Stage::GetCurrent().Add(alignment);
508 application.Render();
509 application.SendNotification();
510 Stage::GetCurrent().Remove(alignment);
511 application.Render();
512 application.SendNotification();
515 // HorizontalLeft, VerticalCenter
517 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
518 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
519 alignment.Add(RenderableActor::New());
520 Stage::GetCurrent().Add(alignment);
521 application.Render();
522 application.SendNotification();
523 Stage::GetCurrent().Remove(alignment);
524 application.Render();
525 application.SendNotification();
528 // HorizontalRight, VerticalCenter
530 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
531 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
532 alignment.Add(RenderableActor::New());
533 Stage::GetCurrent().Add(alignment);
534 application.Render();
535 application.SendNotification();
536 Stage::GetCurrent().Remove(alignment);
537 application.Render();
538 application.SendNotification();
541 // HorizontalLeft, VerticalTop
543 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
544 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
545 alignment.Add(RenderableActor::New());
546 Stage::GetCurrent().Add(alignment);
547 application.Render();
548 application.SendNotification();
549 Stage::GetCurrent().Remove(alignment);
550 application.Render();
551 application.SendNotification();
554 // HorizontalCenter, VerticalTop
556 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
557 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
558 alignment.Add(RenderableActor::New());
559 Stage::GetCurrent().Add(alignment);
560 application.Render();
561 application.SendNotification();
562 Stage::GetCurrent().Remove(alignment);
563 application.Render();
564 application.SendNotification();
567 // HorizontalRight, VerticalTop
569 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
570 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
571 alignment.Add(RenderableActor::New());
572 Stage::GetCurrent().Add(alignment);
573 application.Render();
574 application.SendNotification();
575 Stage::GetCurrent().Remove(alignment);
576 application.Render();
577 application.SendNotification();
580 // HorizontalLeft, VerticalBottom
582 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
583 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
584 alignment.Add(RenderableActor::New());
585 Stage::GetCurrent().Add(alignment);
586 application.Render();
587 application.SendNotification();
588 Stage::GetCurrent().Remove(alignment);
589 application.Render();
590 application.SendNotification();
593 // HorizontalCenter, VerticalBottom
595 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
596 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
597 alignment.Add(RenderableActor::New());
598 Stage::GetCurrent().Add(alignment);
599 application.Render();
600 application.SendNotification();
601 Stage::GetCurrent().Remove(alignment);
602 application.Render();
603 application.SendNotification();
606 // HorizontalRight, VerticalBottom
608 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
609 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
610 alignment.Add(RenderableActor::New());
611 Stage::GetCurrent().Add(alignment);
612 application.Render();
613 application.SendNotification();
614 Stage::GetCurrent().Remove(alignment);
615 application.Render();
616 application.SendNotification();
621 int UtcDaliAlignmentSetScaling(void)
623 ToolkitTestApplication application;
627 Alignment alignment = Alignment::New();
628 alignment.Add(RenderableActor::New());
629 Stage::GetCurrent().Add(alignment);
630 application.Render();
631 application.SendNotification();
633 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
634 alignment.SetScaling(Alignment::ScaleToFill);
635 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
636 application.Render();
637 application.SendNotification();
639 // For complete line coverage
640 alignment.SetAlignmentType(Alignment::HorizontalLeft);
641 application.Render();
642 application.SendNotification();
643 alignment.SetAlignmentType(Alignment::HorizontalRight);
644 application.Render();
645 application.SendNotification();
646 alignment.SetAlignmentType(Alignment::VerticalTop);
647 application.Render();
648 application.SendNotification();
649 alignment.SetAlignmentType(Alignment::VerticalBottom);
650 application.Render();
651 application.SendNotification();
653 Stage::GetCurrent().Remove(alignment);
654 application.Render();
655 application.SendNotification();
658 // ScaleToFitKeepAspect
660 Alignment alignment = Alignment::New();
661 alignment.Add(RenderableActor::New());
662 Stage::GetCurrent().Add(alignment);
663 application.Render();
664 application.SendNotification();
666 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
667 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
668 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
669 application.Render();
670 application.SendNotification();
672 // For complete line coverage
673 alignment.SetAlignmentType(Alignment::HorizontalLeft);
674 application.Render();
675 application.SendNotification();
676 alignment.SetAlignmentType(Alignment::HorizontalRight);
677 application.Render();
678 application.SendNotification();
679 alignment.SetAlignmentType(Alignment::VerticalTop);
680 application.Render();
681 application.SendNotification();
682 alignment.SetAlignmentType(Alignment::VerticalBottom);
683 application.Render();
684 application.SendNotification();
686 Stage::GetCurrent().Remove(alignment);
687 application.Render();
688 application.SendNotification();
691 // ScaleToFillKeepAspect
693 Alignment alignment = Alignment::New();
694 alignment.Add(RenderableActor::New());
695 Stage::GetCurrent().Add(alignment);
696 application.Render();
697 application.SendNotification();
699 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
700 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
701 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
702 application.Render();
703 application.SendNotification();
705 // For complete line coverage
706 alignment.SetAlignmentType(Alignment::HorizontalLeft);
707 application.Render();
708 application.SendNotification();
709 alignment.SetAlignmentType(Alignment::HorizontalRight);
710 application.Render();
711 application.SendNotification();
712 alignment.SetAlignmentType(Alignment::VerticalTop);
713 application.Render();
714 application.SendNotification();
715 alignment.SetAlignmentType(Alignment::VerticalBottom);
716 application.Render();
717 application.SendNotification();
719 Stage::GetCurrent().Remove(alignment);
720 application.Render();
721 application.SendNotification();
726 Alignment alignment = Alignment::New();
727 alignment.Add(RenderableActor::New());
728 Stage::GetCurrent().Add(alignment);
729 application.Render();
730 application.SendNotification();
732 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
733 alignment.SetScaling(Alignment::ShrinkToFit);
734 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
735 application.Render();
736 application.SendNotification();
738 // For complete line coverage
739 alignment.SetAlignmentType(Alignment::HorizontalLeft);
740 application.Render();
741 application.SendNotification();
742 alignment.SetAlignmentType(Alignment::HorizontalRight);
743 application.Render();
744 application.SendNotification();
745 alignment.SetAlignmentType(Alignment::VerticalTop);
746 application.Render();
747 application.SendNotification();
748 alignment.SetAlignmentType(Alignment::VerticalBottom);
749 application.Render();
750 application.SendNotification();
752 Stage::GetCurrent().Remove(alignment);
753 application.Render();
754 application.SendNotification();
757 // ShrinkToFitKeepAspect
759 Alignment alignment = Alignment::New();
760 alignment.Add(RenderableActor::New());
761 Stage::GetCurrent().Add(alignment);
762 application.Render();
763 application.SendNotification();
765 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
766 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
767 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
768 application.Render();
769 application.SendNotification();
771 // For complete line coverage
772 alignment.SetAlignmentType(Alignment::HorizontalLeft);
773 application.Render();
774 application.SendNotification();
775 alignment.SetAlignmentType(Alignment::HorizontalRight);
776 application.Render();
777 application.SendNotification();
778 alignment.SetAlignmentType(Alignment::VerticalTop);
779 application.Render();
780 application.SendNotification();
781 alignment.SetAlignmentType(Alignment::VerticalBottom);
782 application.Render();
783 application.SendNotification();
785 Stage::GetCurrent().Remove(alignment);
786 application.Render();
787 application.SendNotification();
792 int UtcDaliAlignmentGetScaling(void)
794 ToolkitTestApplication application;
798 Alignment alignment = Alignment::New();
799 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
801 alignment.SetScaling(Alignment::ScaleToFill);
802 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
805 // ScaleToFitKeepAspect
807 Alignment alignment = Alignment::New();
808 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
810 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
811 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
814 // ScaleToFillKeepAspect
816 Alignment alignment = Alignment::New();
817 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
819 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
820 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
825 Alignment alignment = Alignment::New();
826 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
828 alignment.SetScaling(Alignment::ShrinkToFit);
829 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
832 // ShrinkToFitKeepAspect
834 Alignment alignment = Alignment::New();
835 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
837 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
838 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
844 int UtcDaliAlignmentSetPaddingPositive(void)
846 ToolkitTestApplication application;
848 Alignment alignment = Alignment::New();
850 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
851 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
852 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
853 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
854 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
856 alignment.SetPadding(padding);
857 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
858 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
859 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
860 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
864 int UtcDaliAlignmentSetPaddingNegative(void)
866 ToolkitTestApplication application;
868 Alignment alignment = Alignment::New();
872 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
873 alignment.SetPadding(padding);
874 tet_result(TET_FAIL);
876 catch (DaliException& exception)
878 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
880 tet_result(TET_PASS);
886 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
887 alignment.SetPadding(padding);
888 tet_result(TET_FAIL);
890 catch (DaliException& exception)
892 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
894 tet_result(TET_PASS);
900 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.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 int UtcDaliAlignmentGetPadding(void)
930 ToolkitTestApplication application;
932 Alignment alignment = Alignment::New();
933 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
934 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
935 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
936 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
938 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
939 alignment.SetPadding(padding);
940 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
941 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
942 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
943 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
947 int UtcDaliAlignmentChildAddAndRemove(void)
949 ToolkitTestApplication application;
951 Alignment alignment = Alignment::New();
952 Stage::GetCurrent().Add(alignment);
954 application.Render();
955 application.SendNotification();
957 Actor actor = RenderableActor::New();
958 alignment.Add(actor);
960 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
962 application.Render();
963 application.SendNotification();
965 alignment.Remove(actor);
967 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
969 application.Render();
970 application.SendNotification();
972 Stage::GetCurrent().Remove(alignment);
976 int UtcDaliAlignmentOnSizeSet(void)
978 ToolkitTestApplication application;
980 Alignment alignment = Alignment::New();
981 Stage::GetCurrent().Add(alignment);
983 application.Render();
984 application.SendNotification();
986 Vector3 size(100.0f, 200.0f, 0.0f);
987 alignment.SetSize(size);
989 application.Render();
990 application.SendNotification();
991 application.Render();
992 application.SendNotification();
994 DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
996 Stage::GetCurrent().Remove(alignment);
1000 ///////////////////////////////////////////////////////////////////////////////
1001 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
1006 ///////////////////////////////////////////////////////////////////////////////
1008 int UtcDaliAlignmentOnTouchEvent(void)
1010 ToolkitTestApplication application;
1012 Alignment alignment = Alignment::New();
1013 alignment.SetSize(100.0f, 100.0f);
1014 alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1015 Stage::GetCurrent().Add(alignment);
1017 alignment.TouchedSignal().Connect(&TouchEventCallback);
1019 application.Render();
1020 application.SendNotification();
1021 application.Render();
1022 application.SendNotification();
1024 Integration::TouchEvent touchEvent(1);
1025 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
1026 touchEvent.AddPoint(point);
1027 application.ProcessEvent(touchEvent);
1029 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1033 int UtcDaliAlignmentOnKeyEvent(void)
1035 ToolkitTestApplication application;
1037 Alignment alignment = Alignment::New();
1038 Stage::GetCurrent().Add(alignment);
1040 alignment.SetKeyInputFocus();
1042 application.Render();
1043 application.SendNotification();
1044 application.Render();
1045 application.SendNotification();
1047 Integration::KeyEvent keyEvent;
1048 application.ProcessEvent(keyEvent);
1050 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1054 int UtcDaliAlignmentOnSizeAnimation(void)
1056 ToolkitTestApplication application;
1058 Alignment alignment = Alignment::New();
1059 Stage::GetCurrent().Add(alignment);
1061 Animation animation = Animation::New(100.0f);
1062 animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
1065 application.Render();
1066 application.SendNotification();
1067 application.Render();
1068 application.SendNotification();
1070 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1074 int UtcDaliAlignmentCopyAndAssignment(void)
1076 ToolkitTestApplication application;
1078 Alignment alignment = Alignment::New();
1079 Alignment emptyAlignment;
1081 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1082 alignment.SetPadding(padding);
1084 Alignment alignmentCopy(alignment);
1085 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1086 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1087 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1088 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1090 Alignment alignmentEmptyCopy(emptyAlignment);
1091 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1093 Alignment alignmentEquals;
1094 alignmentEquals = alignment;
1095 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1096 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1097 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1098 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1100 Alignment alignmentEmptyEquals;
1101 alignmentEmptyEquals = emptyAlignment;
1102 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1105 alignment = alignment;
1106 DALI_TEST_CHECK(alignment == alignmentCopy);