2 * Copyright (c) 2015 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;
44 /// Compare an int (Or'd Alignment::Type) with an Alignment::Type value
45 void DALI_TEST_EQUALS( int value1, Alignment::Type value2, const char* location )
47 ::DALI_TEST_EQUALS< Alignment::Type >( static_cast< Alignment::Type >( value1 ), value2, location );
50 static bool gObjectCreatedCallBackCalled;
52 static void TestCallback(BaseHandle handle)
54 gObjectCreatedCallBackCalled = true;
59 int UtcDaliAlignmentConstructorNegative(void)
61 ToolkitTestApplication application;
67 Alignment::Padding padding;
68 alignment.SetPadding(padding);
71 catch (DaliException& e)
73 DALI_TEST_ASSERT(e, "alignment", TEST_LOCATION );
78 int UtcDaliAlignmentConstructorPositive(void)
80 ToolkitTestApplication application;
82 Alignment alignment = Alignment::New();
86 Alignment::Padding padding;
87 alignment.SetPadding(padding);
90 catch (DaliException& exception)
95 Actor actor = alignment;
96 alignment = Alignment::DownCast( actor );
98 DALI_TEST_CHECK( alignment );
102 int UtcDaliAlignmentConstructorRegister(void)
104 ToolkitTestApplication application;
106 //Te ensure the object is registered after creation
107 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
108 DALI_TEST_CHECK( registry );
110 gObjectCreatedCallBackCalled = false;
111 registry.ObjectCreatedSignal().Connect(&TestCallback);
113 Alignment alignment = Alignment::New();
115 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
119 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
121 ToolkitTestApplication application;
123 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
125 Alignment alignment = Alignment::New();
127 // Check default values
128 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
130 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
131 alignment.SetAlignmentType(type);
132 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
135 // HorizontalLeft, VerticalCenter
137 Alignment alignment = Alignment::New();
139 // Check default values
140 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
142 Alignment::Type type(Alignment::HorizontalLeft);
143 alignment.SetAlignmentType(type);
144 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
147 // HorizontalRight, VerticalCenter
149 Alignment alignment = Alignment::New();
151 // Check default values
152 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
154 Alignment::Type type(Alignment::HorizontalRight);
155 alignment.SetAlignmentType(type);
156 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
159 // HorizontalLeft, VerticalTop
161 Alignment alignment = Alignment::New();
163 // Check default values
164 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
166 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
167 alignment.SetAlignmentType(type);
168 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
171 // HorizontalCenter, VerticalTop
173 Alignment alignment = Alignment::New();
175 // Check default values
176 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
178 Alignment::Type type(Alignment::VerticalTop);
179 alignment.SetAlignmentType(type);
180 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
183 // HorizontalRight, VerticalTop
185 Alignment alignment = Alignment::New();
187 // Check default values
188 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
190 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
191 alignment.SetAlignmentType(type);
192 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
195 // HorizontalLeft, VerticalBottom
197 Alignment alignment = Alignment::New();
199 // Check default values
200 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
202 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
203 alignment.SetAlignmentType(type);
204 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
207 // HorizontalCenter, VerticalBottom
209 Alignment alignment = Alignment::New();
211 // Check default values
212 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
214 Alignment::Type type(Alignment::VerticalBottom);
215 alignment.SetAlignmentType(type);
216 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
219 // HorizontalRight, VerticalBottom
221 Alignment alignment = Alignment::New();
223 // Check default values
224 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
226 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
227 alignment.SetAlignmentType(type);
228 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
233 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
235 ToolkitTestApplication application;
237 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
239 Alignment alignment = Alignment::New();
240 alignment.Add(Actor::New());
241 Stage::GetCurrent().Add(alignment);
242 application.Render();
243 application.SendNotification();
245 // Check default values
246 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
248 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
249 alignment.SetAlignmentType(type);
250 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
252 Stage::GetCurrent().Remove(alignment);
253 application.Render();
254 application.SendNotification();
257 // HorizontalLeft, VerticalCenter
259 Alignment alignment = Alignment::New();
260 alignment.Add(Actor::New());
261 Stage::GetCurrent().Add(alignment);
262 application.Render();
263 application.SendNotification();
265 // Check default values
266 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
268 Alignment::Type type(Alignment::HorizontalLeft);
269 alignment.SetAlignmentType(type);
270 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
272 Stage::GetCurrent().Remove(alignment);
273 application.Render();
274 application.SendNotification();
277 // HorizontalRight, VerticalCenter
279 Alignment alignment = Alignment::New();
280 alignment.Add(Actor::New());
281 Stage::GetCurrent().Add(alignment);
282 application.Render();
283 application.SendNotification();
285 // Check default values
286 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
288 Alignment::Type type(Alignment::HorizontalRight);
289 alignment.SetAlignmentType(type);
290 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
292 Stage::GetCurrent().Remove(alignment);
293 application.Render();
294 application.SendNotification();
297 // HorizontalLeft, VerticalTop
299 Alignment alignment = Alignment::New();
300 alignment.Add(Actor::New());
301 Stage::GetCurrent().Add(alignment);
302 application.Render();
303 application.SendNotification();
305 // Check default values
306 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
308 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
309 alignment.SetAlignmentType(type);
310 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
312 Stage::GetCurrent().Remove(alignment);
313 application.Render();
314 application.SendNotification();
317 // HorizontalCenter, VerticalTop
319 Alignment alignment = Alignment::New();
320 alignment.Add(Actor::New());
321 Stage::GetCurrent().Add(alignment);
322 application.Render();
323 application.SendNotification();
325 // Check default values
326 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
328 Alignment::Type type(Alignment::VerticalTop);
329 alignment.SetAlignmentType(type);
330 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
332 Stage::GetCurrent().Remove(alignment);
333 application.Render();
334 application.SendNotification();
337 // HorizontalRight, VerticalTop
339 Alignment alignment = Alignment::New();
340 alignment.Add(Actor::New());
341 Stage::GetCurrent().Add(alignment);
342 application.Render();
343 application.SendNotification();
345 // Check default values
346 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
348 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
349 alignment.SetAlignmentType(type);
350 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
352 Stage::GetCurrent().Remove(alignment);
353 application.Render();
354 application.SendNotification();
357 // HorizontalLeft, VerticalBottom
359 Alignment alignment = Alignment::New();
360 alignment.Add(Actor::New());
361 Stage::GetCurrent().Add(alignment);
362 application.Render();
363 application.SendNotification();
365 // Check default values
366 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
368 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
369 alignment.SetAlignmentType(type);
370 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
372 Stage::GetCurrent().Remove(alignment);
373 application.Render();
374 application.SendNotification();
377 // HorizontalCenter, VerticalBottom
379 Alignment alignment = Alignment::New();
380 alignment.Add(Actor::New());
381 Stage::GetCurrent().Add(alignment);
382 application.Render();
383 application.SendNotification();
385 // Check default values
386 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
388 Alignment::Type type(Alignment::VerticalBottom);
389 alignment.SetAlignmentType(type);
390 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
392 Stage::GetCurrent().Remove(alignment);
393 application.Render();
394 application.SendNotification();
397 // HorizontalRight, VerticalBottom
399 Alignment alignment = Alignment::New();
400 alignment.Add(Actor::New());
401 Stage::GetCurrent().Add(alignment);
402 application.Render();
403 application.SendNotification();
405 // Check default values
406 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
408 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
409 alignment.SetAlignmentType(type);
410 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
412 Stage::GetCurrent().Remove(alignment);
413 application.Render();
414 application.SendNotification();
419 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
421 ToolkitTestApplication application;
423 // Setting HorizontalLeft, HorizontalCenter
425 Alignment alignment = Alignment::New();
426 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
427 alignment.SetAlignmentType(type);
428 // center will prevail in conflict
429 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
430 DALI_TEST_CHECK( !(Alignment::HorizontalLeft & alignment.GetAlignmentType()) );
433 // Setting HorizontalCenter, HorizontalRight
435 Alignment alignment = Alignment::New();
436 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
438 alignment.SetAlignmentType(type);
439 // center will prevail in conflict
440 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
441 DALI_TEST_CHECK( !(Alignment::HorizontalRight & alignment.GetAlignmentType()) );
444 // Setting VerticalTop, VerticalCenter
446 Alignment alignment = Alignment::New();
447 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
448 alignment.SetAlignmentType(type);
449 // center will prevail in conflict
450 DALI_TEST_CHECK( Alignment::VerticalCenter & alignment.GetAlignmentType() );
451 DALI_TEST_CHECK( !(Alignment::VerticalTop & alignment.GetAlignmentType()) );
454 // Setting VerticalCenter, VerticalBottom
456 Alignment alignment = Alignment::New();
457 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
458 alignment.SetAlignmentType(type);
459 // top will prevail in conflict
460 DALI_TEST_CHECK( Alignment::VerticalTop & alignment.GetAlignmentType() );
461 DALI_TEST_CHECK( !(Alignment::VerticalBottom & alignment.GetAlignmentType()) );
466 int UtcDaliAlignmentGetAlignmentType(void)
468 ToolkitTestApplication application;
470 // Default, HorizonalCenter, VerticalCenter
472 Alignment alignment = Alignment::New();
473 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
474 alignment.Add(Actor::New());
475 Stage::GetCurrent().Add(alignment);
476 application.Render();
477 application.SendNotification();
478 Stage::GetCurrent().Remove(alignment);
479 application.Render();
480 application.SendNotification();
483 // HorizontalLeft, VerticalCenter
485 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
486 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
487 alignment.Add(Actor::New());
488 Stage::GetCurrent().Add(alignment);
489 application.Render();
490 application.SendNotification();
491 Stage::GetCurrent().Remove(alignment);
492 application.Render();
493 application.SendNotification();
496 // HorizontalRight, VerticalCenter
498 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
499 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
500 alignment.Add(Actor::New());
501 Stage::GetCurrent().Add(alignment);
502 application.Render();
503 application.SendNotification();
504 Stage::GetCurrent().Remove(alignment);
505 application.Render();
506 application.SendNotification();
509 // HorizontalLeft, VerticalTop
511 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
512 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
513 alignment.Add(Actor::New());
514 Stage::GetCurrent().Add(alignment);
515 application.Render();
516 application.SendNotification();
517 Stage::GetCurrent().Remove(alignment);
518 application.Render();
519 application.SendNotification();
522 // HorizontalCenter, VerticalTop
524 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
525 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
526 alignment.Add(Actor::New());
527 Stage::GetCurrent().Add(alignment);
528 application.Render();
529 application.SendNotification();
530 Stage::GetCurrent().Remove(alignment);
531 application.Render();
532 application.SendNotification();
535 // HorizontalRight, VerticalTop
537 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
538 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
539 alignment.Add(Actor::New());
540 Stage::GetCurrent().Add(alignment);
541 application.Render();
542 application.SendNotification();
543 Stage::GetCurrent().Remove(alignment);
544 application.Render();
545 application.SendNotification();
548 // HorizontalLeft, VerticalBottom
550 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
551 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
552 alignment.Add(Actor::New());
553 Stage::GetCurrent().Add(alignment);
554 application.Render();
555 application.SendNotification();
556 Stage::GetCurrent().Remove(alignment);
557 application.Render();
558 application.SendNotification();
561 // HorizontalCenter, VerticalBottom
563 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
564 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
565 alignment.Add(Actor::New());
566 Stage::GetCurrent().Add(alignment);
567 application.Render();
568 application.SendNotification();
569 Stage::GetCurrent().Remove(alignment);
570 application.Render();
571 application.SendNotification();
574 // HorizontalRight, VerticalBottom
576 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
577 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
578 alignment.Add(Actor::New());
579 Stage::GetCurrent().Add(alignment);
580 application.Render();
581 application.SendNotification();
582 Stage::GetCurrent().Remove(alignment);
583 application.Render();
584 application.SendNotification();
589 int UtcDaliAlignmentSetScaling(void)
591 ToolkitTestApplication application;
595 Alignment alignment = Alignment::New();
596 alignment.Add(Actor::New());
597 Stage::GetCurrent().Add(alignment);
598 application.Render();
599 application.SendNotification();
601 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
602 alignment.SetScaling(Alignment::ScaleToFill);
603 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
604 application.Render();
605 application.SendNotification();
607 // For complete line coverage
608 alignment.SetAlignmentType(Alignment::HorizontalLeft);
609 application.Render();
610 application.SendNotification();
611 alignment.SetAlignmentType(Alignment::HorizontalRight);
612 application.Render();
613 application.SendNotification();
614 alignment.SetAlignmentType(Alignment::VerticalTop);
615 application.Render();
616 application.SendNotification();
617 alignment.SetAlignmentType(Alignment::VerticalBottom);
618 application.Render();
619 application.SendNotification();
621 Stage::GetCurrent().Remove(alignment);
622 application.Render();
623 application.SendNotification();
626 // ScaleToFitKeepAspect
628 Alignment alignment = Alignment::New();
629 alignment.Add(Actor::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::ScaleToFitKeepAspect);
636 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, 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 // ScaleToFillKeepAspect
661 Alignment alignment = Alignment::New();
662 alignment.Add(Actor::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::ScaleToFillKeepAspect);
669 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, 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();
694 Alignment alignment = Alignment::New();
695 alignment.Add(Actor::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::ShrinkToFit);
702 DALI_TEST_EQUALS(Alignment::ShrinkToFit, 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();
725 // ShrinkToFitKeepAspect
727 Alignment alignment = Alignment::New();
728 alignment.Add(Actor::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::ShrinkToFitKeepAspect);
735 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, 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();
760 int UtcDaliAlignmentGetScaling(void)
762 ToolkitTestApplication application;
766 Alignment alignment = Alignment::New();
767 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
769 alignment.SetScaling(Alignment::ScaleToFill);
770 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
773 // ScaleToFitKeepAspect
775 Alignment alignment = Alignment::New();
776 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
778 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
779 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
782 // ScaleToFillKeepAspect
784 Alignment alignment = Alignment::New();
785 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
787 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
788 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
793 Alignment alignment = Alignment::New();
794 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
796 alignment.SetScaling(Alignment::ShrinkToFit);
797 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
800 // ShrinkToFitKeepAspect
802 Alignment alignment = Alignment::New();
803 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
805 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
806 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
812 int UtcDaliAlignmentSetPaddingPositive(void)
814 ToolkitTestApplication application;
816 Alignment alignment = Alignment::New();
818 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
819 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
820 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
821 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
822 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
824 alignment.SetPadding(padding);
825 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
826 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
827 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
828 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
832 int UtcDaliAlignmentSetPaddingNegative(void)
834 ToolkitTestApplication application;
836 Alignment alignment = Alignment::New();
840 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
841 alignment.SetPadding(padding);
842 tet_result(TET_FAIL);
844 catch (DaliException& e)
846 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
851 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
852 alignment.SetPadding(padding);
853 tet_result(TET_FAIL);
855 catch (DaliException& e)
857 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
862 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
863 alignment.SetPadding(padding);
864 tet_result(TET_FAIL);
866 catch (DaliException& e)
868 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
873 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
874 alignment.SetPadding(padding);
875 tet_result(TET_FAIL);
877 catch (DaliException& e)
879 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
884 int UtcDaliAlignmentGetPadding(void)
886 ToolkitTestApplication application;
888 Alignment alignment = Alignment::New();
889 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
890 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
891 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
892 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
894 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
895 alignment.SetPadding(padding);
896 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
897 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
898 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
899 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
903 int UtcDaliAlignmentChildAddAndRemove(void)
905 ToolkitTestApplication application;
907 Alignment alignment = Alignment::New();
908 Stage::GetCurrent().Add(alignment);
910 application.Render();
911 application.SendNotification();
913 Actor actor = Actor::New();
914 alignment.Add(actor);
916 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
918 application.Render();
919 application.SendNotification();
921 alignment.Remove(actor);
923 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
925 application.Render();
926 application.SendNotification();
928 Stage::GetCurrent().Remove(alignment);
932 int UtcDaliAlignmentSizeSetP(void)
934 ToolkitTestApplication application;
936 Alignment alignment = Alignment::New();
937 Stage::GetCurrent().Add(alignment);
939 application.Render();
940 application.SendNotification();
942 Vector2 size( 100.0f, 200.0f );
943 alignment.SetProperty( Actor::Property::SIZE, size);
945 application.Render();
946 application.SendNotification();
947 application.Render();
948 application.SendNotification();
950 DALI_TEST_EQUALS(size, alignment.GetTargetSize().GetVectorXY(), TEST_LOCATION);
952 Stage::GetCurrent().Remove(alignment);
956 ///////////////////////////////////////////////////////////////////////////////
957 static bool TouchCallback(Actor actor, const TouchData& event)
962 ///////////////////////////////////////////////////////////////////////////////
964 int UtcDaliAlignmentOnTouchEvent(void)
966 ToolkitTestApplication application;
968 Alignment alignment = Alignment::New();
969 alignment.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
970 alignment.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
971 Stage::GetCurrent().Add(alignment);
973 alignment.TouchSignal().Connect(&TouchCallback);
975 application.Render();
976 application.SendNotification();
977 application.Render();
978 application.SendNotification();
980 Integration::TouchEvent touchEvent(1);
981 Integration::Point point;
982 point.SetDeviceId( 1 );
983 point.SetState( PointState::DOWN);
984 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
985 touchEvent.AddPoint(point);
986 application.ProcessEvent(touchEvent);
988 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
992 int UtcDaliAlignmentOnKeyEvent(void)
994 ToolkitTestApplication application;
996 Alignment alignment = Alignment::New();
997 Stage::GetCurrent().Add(alignment);
999 alignment.SetKeyInputFocus();
1001 application.Render();
1002 application.SendNotification();
1003 application.Render();
1004 application.SendNotification();
1006 Integration::KeyEvent keyEvent;
1007 application.ProcessEvent(keyEvent);
1009 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1013 int UtcDaliAlignmentOnSizeAnimation(void)
1015 ToolkitTestApplication application;
1017 Alignment alignment = Alignment::New();
1018 Stage::GetCurrent().Add(alignment);
1020 Animation animation = Animation::New(100.0f);
1021 animation.AnimateTo( Property( alignment, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
1024 application.Render();
1025 application.SendNotification();
1026 application.Render();
1027 application.SendNotification();
1029 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1033 int UtcDaliAlignmentCopyAndAssignment(void)
1035 ToolkitTestApplication application;
1037 Alignment alignment = Alignment::New();
1038 Alignment emptyAlignment;
1040 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1041 alignment.SetPadding(padding);
1043 Alignment alignmentCopy(alignment);
1044 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1045 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1046 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1047 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1049 Alignment alignmentEmptyCopy(emptyAlignment);
1050 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1052 Alignment alignmentEquals;
1053 alignmentEquals = alignment;
1054 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1055 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1056 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1057 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1059 Alignment alignmentEmptyEquals;
1060 alignmentEmptyEquals = emptyAlignment;
1061 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1064 alignment = alignment;
1065 DALI_TEST_CHECK(alignment == alignmentCopy);