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.
22 // Need to override adaptor classes for toolkit test harness, so include
23 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit/dali-toolkit.h>
30 using namespace Dali::Toolkit;
32 void utc_dali_toolkit_alignment_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_alignment_cleanup(void)
39 test_return_value = TET_PASS;
45 static bool gObjectCreatedCallBackCalled;
47 static void TestCallback(BaseHandle handle)
49 gObjectCreatedCallBackCalled = true;
54 int UtcDaliAlignmentConstructorNegative(void)
56 ToolkitTestApplication application;
62 Alignment::Padding padding;
63 alignment.SetPadding(padding);
66 catch (DaliException& exception)
68 if (exception.mCondition == "alignment")
76 int UtcDaliAlignmentConstructorPositive(void)
78 ToolkitTestApplication application;
80 Alignment alignment = Alignment::New();
84 Alignment::Padding padding;
85 alignment.SetPadding(padding);
88 catch (DaliException& exception)
93 Actor actor = alignment;
94 alignment = Alignment::DownCast( actor );
96 DALI_TEST_CHECK( alignment );
100 int UtcDaliAlignmentConstructorRegister(void)
102 ToolkitTestApplication application;
104 //Te ensure the object is registered after creation
105 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
106 DALI_TEST_CHECK( registry );
108 gObjectCreatedCallBackCalled = false;
109 registry.ObjectCreatedSignal().Connect(&TestCallback);
111 Alignment alignment = Alignment::New();
113 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
117 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
119 ToolkitTestApplication application;
121 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
123 Alignment alignment = Alignment::New();
125 // Check default values
126 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
128 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
129 alignment.SetAlignmentType(type);
130 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
133 // HorizontalLeft, VerticalCenter
135 Alignment alignment = Alignment::New();
137 // Check default values
138 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
140 Alignment::Type type(Alignment::HorizontalLeft);
141 alignment.SetAlignmentType(type);
142 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
145 // HorizontalRight, VerticalCenter
147 Alignment alignment = Alignment::New();
149 // Check default values
150 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
152 Alignment::Type type(Alignment::HorizontalRight);
153 alignment.SetAlignmentType(type);
154 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
157 // HorizontalLeft, VerticalTop
159 Alignment alignment = Alignment::New();
161 // Check default values
162 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
164 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
165 alignment.SetAlignmentType(type);
166 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
169 // HorizontalCenter, VerticalTop
171 Alignment alignment = Alignment::New();
173 // Check default values
174 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
176 Alignment::Type type(Alignment::VerticalTop);
177 alignment.SetAlignmentType(type);
178 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
181 // HorizontalRight, VerticalTop
183 Alignment alignment = Alignment::New();
185 // Check default values
186 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
188 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
189 alignment.SetAlignmentType(type);
190 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
193 // HorizontalLeft, VerticalBottom
195 Alignment alignment = Alignment::New();
197 // Check default values
198 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
200 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
201 alignment.SetAlignmentType(type);
202 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
205 // HorizontalCenter, VerticalBottom
207 Alignment alignment = Alignment::New();
209 // Check default values
210 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
212 Alignment::Type type(Alignment::VerticalBottom);
213 alignment.SetAlignmentType(type);
214 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
217 // HorizontalRight, VerticalBottom
219 Alignment alignment = Alignment::New();
221 // Check default values
222 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
224 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
225 alignment.SetAlignmentType(type);
226 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
231 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
233 ToolkitTestApplication application;
235 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
237 Alignment alignment = Alignment::New();
238 alignment.Add(RenderableActor::New());
239 Stage::GetCurrent().Add(alignment);
240 application.Render();
241 application.SendNotification();
243 // Check default values
244 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
246 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
247 alignment.SetAlignmentType(type);
248 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
250 Stage::GetCurrent().Remove(alignment);
251 application.Render();
252 application.SendNotification();
255 // HorizontalLeft, VerticalCenter
257 Alignment alignment = Alignment::New();
258 alignment.Add(RenderableActor::New());
259 Stage::GetCurrent().Add(alignment);
260 application.Render();
261 application.SendNotification();
263 // Check default values
264 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
266 Alignment::Type type(Alignment::HorizontalLeft);
267 alignment.SetAlignmentType(type);
268 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
270 Stage::GetCurrent().Remove(alignment);
271 application.Render();
272 application.SendNotification();
275 // HorizontalRight, VerticalCenter
277 Alignment alignment = Alignment::New();
278 alignment.Add(RenderableActor::New());
279 Stage::GetCurrent().Add(alignment);
280 application.Render();
281 application.SendNotification();
283 // Check default values
284 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
286 Alignment::Type type(Alignment::HorizontalRight);
287 alignment.SetAlignmentType(type);
288 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
290 Stage::GetCurrent().Remove(alignment);
291 application.Render();
292 application.SendNotification();
295 // HorizontalLeft, VerticalTop
297 Alignment alignment = Alignment::New();
298 alignment.Add(RenderableActor::New());
299 Stage::GetCurrent().Add(alignment);
300 application.Render();
301 application.SendNotification();
303 // Check default values
304 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
306 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
307 alignment.SetAlignmentType(type);
308 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
310 Stage::GetCurrent().Remove(alignment);
311 application.Render();
312 application.SendNotification();
315 // HorizontalCenter, VerticalTop
317 Alignment alignment = Alignment::New();
318 alignment.Add(RenderableActor::New());
319 Stage::GetCurrent().Add(alignment);
320 application.Render();
321 application.SendNotification();
323 // Check default values
324 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
326 Alignment::Type type(Alignment::VerticalTop);
327 alignment.SetAlignmentType(type);
328 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
330 Stage::GetCurrent().Remove(alignment);
331 application.Render();
332 application.SendNotification();
335 // HorizontalRight, VerticalTop
337 Alignment alignment = Alignment::New();
338 alignment.Add(RenderableActor::New());
339 Stage::GetCurrent().Add(alignment);
340 application.Render();
341 application.SendNotification();
343 // Check default values
344 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
346 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
347 alignment.SetAlignmentType(type);
348 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
350 Stage::GetCurrent().Remove(alignment);
351 application.Render();
352 application.SendNotification();
355 // HorizontalLeft, VerticalBottom
357 Alignment alignment = Alignment::New();
358 alignment.Add(RenderableActor::New());
359 Stage::GetCurrent().Add(alignment);
360 application.Render();
361 application.SendNotification();
363 // Check default values
364 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
366 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
367 alignment.SetAlignmentType(type);
368 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
370 Stage::GetCurrent().Remove(alignment);
371 application.Render();
372 application.SendNotification();
375 // HorizontalCenter, VerticalBottom
377 Alignment alignment = Alignment::New();
378 alignment.Add(RenderableActor::New());
379 Stage::GetCurrent().Add(alignment);
380 application.Render();
381 application.SendNotification();
383 // Check default values
384 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
386 Alignment::Type type(Alignment::VerticalBottom);
387 alignment.SetAlignmentType(type);
388 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
390 Stage::GetCurrent().Remove(alignment);
391 application.Render();
392 application.SendNotification();
395 // HorizontalRight, VerticalBottom
397 Alignment alignment = Alignment::New();
398 alignment.Add(RenderableActor::New());
399 Stage::GetCurrent().Add(alignment);
400 application.Render();
401 application.SendNotification();
403 // Check default values
404 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
406 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
407 alignment.SetAlignmentType(type);
408 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
410 Stage::GetCurrent().Remove(alignment);
411 application.Render();
412 application.SendNotification();
417 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
419 ToolkitTestApplication application;
421 // Setting HorizontalLeft, HorizontalCenter
423 Alignment alignment = Alignment::New();
424 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
428 alignment.SetAlignmentType(type);
429 tet_result(TET_FAIL);
431 catch (DaliException& exception)
433 if (exception.mCondition == "!horizontalSet")
435 tet_result(TET_PASS);
440 // Setting HorizontalCenter, HorizontalRight
442 Alignment alignment = Alignment::New();
443 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
447 alignment.SetAlignmentType(type);
448 tet_result(TET_FAIL);
450 catch (DaliException& exception)
452 if (exception.mCondition == "!horizontalSet")
454 tet_result(TET_PASS);
459 // Setting VerticalTop, VerticalCenter
461 Alignment alignment = Alignment::New();
462 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
466 alignment.SetAlignmentType(type);
467 tet_result(TET_FAIL);
469 catch (DaliException& exception)
471 if (exception.mCondition == "!verticalSet")
473 tet_result(TET_PASS);
478 // Setting VerticalCenter, VerticalBottom
480 Alignment alignment = Alignment::New();
481 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
485 alignment.SetAlignmentType(type);
486 tet_result(TET_FAIL);
488 catch (DaliException& exception)
490 if (exception.mCondition == "!veritcalSet")
492 tet_result(TET_PASS);
499 int UtcDaliAlignmentGetAlignmentType(void)
501 ToolkitTestApplication application;
503 // Default, HorizonalCenter, VerticalCenter
505 Alignment alignment = Alignment::New();
506 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
507 alignment.Add(RenderableActor::New());
508 Stage::GetCurrent().Add(alignment);
509 application.Render();
510 application.SendNotification();
511 Stage::GetCurrent().Remove(alignment);
512 application.Render();
513 application.SendNotification();
516 // HorizontalLeft, VerticalCenter
518 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
519 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
520 alignment.Add(RenderableActor::New());
521 Stage::GetCurrent().Add(alignment);
522 application.Render();
523 application.SendNotification();
524 Stage::GetCurrent().Remove(alignment);
525 application.Render();
526 application.SendNotification();
529 // HorizontalRight, VerticalCenter
531 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
532 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
533 alignment.Add(RenderableActor::New());
534 Stage::GetCurrent().Add(alignment);
535 application.Render();
536 application.SendNotification();
537 Stage::GetCurrent().Remove(alignment);
538 application.Render();
539 application.SendNotification();
542 // HorizontalLeft, VerticalTop
544 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
545 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
546 alignment.Add(RenderableActor::New());
547 Stage::GetCurrent().Add(alignment);
548 application.Render();
549 application.SendNotification();
550 Stage::GetCurrent().Remove(alignment);
551 application.Render();
552 application.SendNotification();
555 // HorizontalCenter, VerticalTop
557 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
558 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
559 alignment.Add(RenderableActor::New());
560 Stage::GetCurrent().Add(alignment);
561 application.Render();
562 application.SendNotification();
563 Stage::GetCurrent().Remove(alignment);
564 application.Render();
565 application.SendNotification();
568 // HorizontalRight, VerticalTop
570 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
571 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
572 alignment.Add(RenderableActor::New());
573 Stage::GetCurrent().Add(alignment);
574 application.Render();
575 application.SendNotification();
576 Stage::GetCurrent().Remove(alignment);
577 application.Render();
578 application.SendNotification();
581 // HorizontalLeft, VerticalBottom
583 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
584 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
585 alignment.Add(RenderableActor::New());
586 Stage::GetCurrent().Add(alignment);
587 application.Render();
588 application.SendNotification();
589 Stage::GetCurrent().Remove(alignment);
590 application.Render();
591 application.SendNotification();
594 // HorizontalCenter, VerticalBottom
596 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
597 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
598 alignment.Add(RenderableActor::New());
599 Stage::GetCurrent().Add(alignment);
600 application.Render();
601 application.SendNotification();
602 Stage::GetCurrent().Remove(alignment);
603 application.Render();
604 application.SendNotification();
607 // HorizontalRight, VerticalBottom
609 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
610 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
611 alignment.Add(RenderableActor::New());
612 Stage::GetCurrent().Add(alignment);
613 application.Render();
614 application.SendNotification();
615 Stage::GetCurrent().Remove(alignment);
616 application.Render();
617 application.SendNotification();
622 int UtcDaliAlignmentSetScaling(void)
624 ToolkitTestApplication application;
628 Alignment alignment = Alignment::New();
629 alignment.Add(RenderableActor::New());
630 Stage::GetCurrent().Add(alignment);
631 application.Render();
632 application.SendNotification();
634 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
635 alignment.SetScaling(Alignment::ScaleToFill);
636 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
637 application.Render();
638 application.SendNotification();
640 // For complete line coverage
641 alignment.SetAlignmentType(Alignment::HorizontalLeft);
642 application.Render();
643 application.SendNotification();
644 alignment.SetAlignmentType(Alignment::HorizontalRight);
645 application.Render();
646 application.SendNotification();
647 alignment.SetAlignmentType(Alignment::VerticalTop);
648 application.Render();
649 application.SendNotification();
650 alignment.SetAlignmentType(Alignment::VerticalBottom);
651 application.Render();
652 application.SendNotification();
654 Stage::GetCurrent().Remove(alignment);
655 application.Render();
656 application.SendNotification();
659 // ScaleToFitKeepAspect
661 Alignment alignment = Alignment::New();
662 alignment.Add(RenderableActor::New());
663 Stage::GetCurrent().Add(alignment);
664 application.Render();
665 application.SendNotification();
667 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
668 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
669 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
670 application.Render();
671 application.SendNotification();
673 // For complete line coverage
674 alignment.SetAlignmentType(Alignment::HorizontalLeft);
675 application.Render();
676 application.SendNotification();
677 alignment.SetAlignmentType(Alignment::HorizontalRight);
678 application.Render();
679 application.SendNotification();
680 alignment.SetAlignmentType(Alignment::VerticalTop);
681 application.Render();
682 application.SendNotification();
683 alignment.SetAlignmentType(Alignment::VerticalBottom);
684 application.Render();
685 application.SendNotification();
687 Stage::GetCurrent().Remove(alignment);
688 application.Render();
689 application.SendNotification();
692 // ScaleToFillKeepAspect
694 Alignment alignment = Alignment::New();
695 alignment.Add(RenderableActor::New());
696 Stage::GetCurrent().Add(alignment);
697 application.Render();
698 application.SendNotification();
700 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
701 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
702 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
703 application.Render();
704 application.SendNotification();
706 // For complete line coverage
707 alignment.SetAlignmentType(Alignment::HorizontalLeft);
708 application.Render();
709 application.SendNotification();
710 alignment.SetAlignmentType(Alignment::HorizontalRight);
711 application.Render();
712 application.SendNotification();
713 alignment.SetAlignmentType(Alignment::VerticalTop);
714 application.Render();
715 application.SendNotification();
716 alignment.SetAlignmentType(Alignment::VerticalBottom);
717 application.Render();
718 application.SendNotification();
720 Stage::GetCurrent().Remove(alignment);
721 application.Render();
722 application.SendNotification();
727 Alignment alignment = Alignment::New();
728 alignment.Add(RenderableActor::New());
729 Stage::GetCurrent().Add(alignment);
730 application.Render();
731 application.SendNotification();
733 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
734 alignment.SetScaling(Alignment::ShrinkToFit);
735 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
736 application.Render();
737 application.SendNotification();
739 // For complete line coverage
740 alignment.SetAlignmentType(Alignment::HorizontalLeft);
741 application.Render();
742 application.SendNotification();
743 alignment.SetAlignmentType(Alignment::HorizontalRight);
744 application.Render();
745 application.SendNotification();
746 alignment.SetAlignmentType(Alignment::VerticalTop);
747 application.Render();
748 application.SendNotification();
749 alignment.SetAlignmentType(Alignment::VerticalBottom);
750 application.Render();
751 application.SendNotification();
753 Stage::GetCurrent().Remove(alignment);
754 application.Render();
755 application.SendNotification();
758 // ShrinkToFitKeepAspect
760 Alignment alignment = Alignment::New();
761 alignment.Add(RenderableActor::New());
762 Stage::GetCurrent().Add(alignment);
763 application.Render();
764 application.SendNotification();
766 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
767 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
768 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
769 application.Render();
770 application.SendNotification();
772 // For complete line coverage
773 alignment.SetAlignmentType(Alignment::HorizontalLeft);
774 application.Render();
775 application.SendNotification();
776 alignment.SetAlignmentType(Alignment::HorizontalRight);
777 application.Render();
778 application.SendNotification();
779 alignment.SetAlignmentType(Alignment::VerticalTop);
780 application.Render();
781 application.SendNotification();
782 alignment.SetAlignmentType(Alignment::VerticalBottom);
783 application.Render();
784 application.SendNotification();
786 Stage::GetCurrent().Remove(alignment);
787 application.Render();
788 application.SendNotification();
793 int UtcDaliAlignmentGetScaling(void)
795 ToolkitTestApplication application;
799 Alignment alignment = Alignment::New();
800 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
802 alignment.SetScaling(Alignment::ScaleToFill);
803 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
806 // ScaleToFitKeepAspect
808 Alignment alignment = Alignment::New();
809 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
811 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
812 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
815 // ScaleToFillKeepAspect
817 Alignment alignment = Alignment::New();
818 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
820 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
821 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
826 Alignment alignment = Alignment::New();
827 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
829 alignment.SetScaling(Alignment::ShrinkToFit);
830 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
833 // ShrinkToFitKeepAspect
835 Alignment alignment = Alignment::New();
836 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
838 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
839 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
845 int UtcDaliAlignmentSetPaddingPositive(void)
847 ToolkitTestApplication application;
849 Alignment alignment = Alignment::New();
851 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
852 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
853 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
854 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
855 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
857 alignment.SetPadding(padding);
858 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
859 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
860 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
861 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
865 int UtcDaliAlignmentSetPaddingNegative(void)
867 ToolkitTestApplication application;
869 Alignment alignment = Alignment::New();
873 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
874 alignment.SetPadding(padding);
875 tet_result(TET_FAIL);
877 catch (DaliException& exception)
879 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
881 tet_result(TET_PASS);
887 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
888 alignment.SetPadding(padding);
889 tet_result(TET_FAIL);
891 catch (DaliException& exception)
893 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
895 tet_result(TET_PASS);
901 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
902 alignment.SetPadding(padding);
903 tet_result(TET_FAIL);
905 catch (DaliException& exception)
907 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
909 tet_result(TET_PASS);
915 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
916 alignment.SetPadding(padding);
917 tet_result(TET_FAIL);
919 catch (DaliException& exception)
921 if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
923 tet_result(TET_PASS);
929 int UtcDaliAlignmentGetPadding(void)
931 ToolkitTestApplication application;
933 Alignment alignment = Alignment::New();
934 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
935 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
936 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
937 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
939 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
940 alignment.SetPadding(padding);
941 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
942 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
943 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
944 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
948 int UtcDaliAlignmentChildAddAndRemove(void)
950 ToolkitTestApplication application;
952 Alignment alignment = Alignment::New();
953 Stage::GetCurrent().Add(alignment);
955 application.Render();
956 application.SendNotification();
958 Actor actor = RenderableActor::New();
959 alignment.Add(actor);
961 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
963 application.Render();
964 application.SendNotification();
966 alignment.Remove(actor);
968 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
970 application.Render();
971 application.SendNotification();
973 Stage::GetCurrent().Remove(alignment);
977 int UtcDaliAlignmentOnSizeSet(void)
979 ToolkitTestApplication application;
981 Alignment alignment = Alignment::New();
982 Stage::GetCurrent().Add(alignment);
984 application.Render();
985 application.SendNotification();
987 Vector3 size(100.0f, 200.0f, 0.0f);
988 alignment.SetSize(size);
990 application.Render();
991 application.SendNotification();
992 application.Render();
993 application.SendNotification();
995 DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
997 Stage::GetCurrent().Remove(alignment);
1001 ///////////////////////////////////////////////////////////////////////////////
1002 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
1007 ///////////////////////////////////////////////////////////////////////////////
1009 int UtcDaliAlignmentOnTouchEvent(void)
1011 ToolkitTestApplication application;
1013 Alignment alignment = Alignment::New();
1014 alignment.SetSize(100.0f, 100.0f);
1015 alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1016 Stage::GetCurrent().Add(alignment);
1018 alignment.TouchedSignal().Connect(&TouchEventCallback);
1020 application.Render();
1021 application.SendNotification();
1022 application.Render();
1023 application.SendNotification();
1025 Integration::TouchEvent touchEvent(1);
1026 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
1027 touchEvent.AddPoint(point);
1028 application.ProcessEvent(touchEvent);
1030 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1034 int UtcDaliAlignmentOnKeyEvent(void)
1036 ToolkitTestApplication application;
1038 Alignment alignment = Alignment::New();
1039 Stage::GetCurrent().Add(alignment);
1041 alignment.SetKeyInputFocus();
1043 application.Render();
1044 application.SendNotification();
1045 application.Render();
1046 application.SendNotification();
1048 Integration::KeyEvent keyEvent;
1049 application.ProcessEvent(keyEvent);
1051 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1055 int UtcDaliAlignmentOnSizeAnimation(void)
1057 ToolkitTestApplication application;
1059 Alignment alignment = Alignment::New();
1060 Stage::GetCurrent().Add(alignment);
1062 Animation animation = Animation::New(100.0f);
1063 animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
1066 application.Render();
1067 application.SendNotification();
1068 application.Render();
1069 application.SendNotification();
1071 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1075 int UtcDaliAlignmentCopyAndAssignment(void)
1077 ToolkitTestApplication application;
1079 Alignment alignment = Alignment::New();
1080 Alignment emptyAlignment;
1082 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1083 alignment.SetPadding(padding);
1085 Alignment alignmentCopy(alignment);
1086 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1087 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1088 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1089 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1091 Alignment alignmentEmptyCopy(emptyAlignment);
1092 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1094 Alignment alignmentEquals;
1095 alignmentEquals = alignment;
1096 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1097 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1098 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1099 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1101 Alignment alignmentEmptyEquals;
1102 alignmentEmptyEquals = emptyAlignment;
1103 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1106 alignment = alignment;
1107 DALI_TEST_CHECK(alignment == alignmentCopy);