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;
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& e)
68 DALI_TEST_ASSERT(e, "alignment", TEST_LOCATION );
73 int UtcDaliAlignmentConstructorPositive(void)
75 ToolkitTestApplication application;
77 Alignment alignment = Alignment::New();
81 Alignment::Padding padding;
82 alignment.SetPadding(padding);
85 catch (DaliException& exception)
90 Actor actor = alignment;
91 alignment = Alignment::DownCast( actor );
93 DALI_TEST_CHECK( alignment );
97 int UtcDaliAlignmentConstructorRegister(void)
99 ToolkitTestApplication application;
101 //Te ensure the object is registered after creation
102 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
103 DALI_TEST_CHECK( registry );
105 gObjectCreatedCallBackCalled = false;
106 registry.ObjectCreatedSignal().Connect(&TestCallback);
108 Alignment alignment = Alignment::New();
110 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
114 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
116 ToolkitTestApplication application;
118 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
120 Alignment alignment = Alignment::New();
122 // Check default values
123 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
125 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
126 alignment.SetAlignmentType(type);
127 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
130 // HorizontalLeft, VerticalCenter
132 Alignment alignment = Alignment::New();
134 // Check default values
135 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
137 Alignment::Type type(Alignment::HorizontalLeft);
138 alignment.SetAlignmentType(type);
139 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
142 // HorizontalRight, VerticalCenter
144 Alignment alignment = Alignment::New();
146 // Check default values
147 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
149 Alignment::Type type(Alignment::HorizontalRight);
150 alignment.SetAlignmentType(type);
151 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
154 // HorizontalLeft, VerticalTop
156 Alignment alignment = Alignment::New();
158 // Check default values
159 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
161 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
162 alignment.SetAlignmentType(type);
163 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
166 // HorizontalCenter, VerticalTop
168 Alignment alignment = Alignment::New();
170 // Check default values
171 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
173 Alignment::Type type(Alignment::VerticalTop);
174 alignment.SetAlignmentType(type);
175 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
178 // HorizontalRight, VerticalTop
180 Alignment alignment = Alignment::New();
182 // Check default values
183 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
185 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
186 alignment.SetAlignmentType(type);
187 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
190 // HorizontalLeft, VerticalBottom
192 Alignment alignment = Alignment::New();
194 // Check default values
195 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
197 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
198 alignment.SetAlignmentType(type);
199 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
202 // HorizontalCenter, VerticalBottom
204 Alignment alignment = Alignment::New();
206 // Check default values
207 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
209 Alignment::Type type(Alignment::VerticalBottom);
210 alignment.SetAlignmentType(type);
211 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
214 // HorizontalRight, VerticalBottom
216 Alignment alignment = Alignment::New();
218 // Check default values
219 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
221 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
222 alignment.SetAlignmentType(type);
223 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
228 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
230 ToolkitTestApplication application;
232 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
234 Alignment alignment = Alignment::New();
235 alignment.Add(RenderableActor::New());
236 Stage::GetCurrent().Add(alignment);
237 application.Render();
238 application.SendNotification();
240 // Check default values
241 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
243 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
244 alignment.SetAlignmentType(type);
245 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
247 Stage::GetCurrent().Remove(alignment);
248 application.Render();
249 application.SendNotification();
252 // HorizontalLeft, VerticalCenter
254 Alignment alignment = Alignment::New();
255 alignment.Add(RenderableActor::New());
256 Stage::GetCurrent().Add(alignment);
257 application.Render();
258 application.SendNotification();
260 // Check default values
261 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
263 Alignment::Type type(Alignment::HorizontalLeft);
264 alignment.SetAlignmentType(type);
265 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
267 Stage::GetCurrent().Remove(alignment);
268 application.Render();
269 application.SendNotification();
272 // HorizontalRight, VerticalCenter
274 Alignment alignment = Alignment::New();
275 alignment.Add(RenderableActor::New());
276 Stage::GetCurrent().Add(alignment);
277 application.Render();
278 application.SendNotification();
280 // Check default values
281 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
283 Alignment::Type type(Alignment::HorizontalRight);
284 alignment.SetAlignmentType(type);
285 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
287 Stage::GetCurrent().Remove(alignment);
288 application.Render();
289 application.SendNotification();
292 // HorizontalLeft, VerticalTop
294 Alignment alignment = Alignment::New();
295 alignment.Add(RenderableActor::New());
296 Stage::GetCurrent().Add(alignment);
297 application.Render();
298 application.SendNotification();
300 // Check default values
301 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
303 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
304 alignment.SetAlignmentType(type);
305 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
307 Stage::GetCurrent().Remove(alignment);
308 application.Render();
309 application.SendNotification();
312 // HorizontalCenter, VerticalTop
314 Alignment alignment = Alignment::New();
315 alignment.Add(RenderableActor::New());
316 Stage::GetCurrent().Add(alignment);
317 application.Render();
318 application.SendNotification();
320 // Check default values
321 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
323 Alignment::Type type(Alignment::VerticalTop);
324 alignment.SetAlignmentType(type);
325 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
327 Stage::GetCurrent().Remove(alignment);
328 application.Render();
329 application.SendNotification();
332 // HorizontalRight, VerticalTop
334 Alignment alignment = Alignment::New();
335 alignment.Add(RenderableActor::New());
336 Stage::GetCurrent().Add(alignment);
337 application.Render();
338 application.SendNotification();
340 // Check default values
341 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
343 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
344 alignment.SetAlignmentType(type);
345 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
347 Stage::GetCurrent().Remove(alignment);
348 application.Render();
349 application.SendNotification();
352 // HorizontalLeft, VerticalBottom
354 Alignment alignment = Alignment::New();
355 alignment.Add(RenderableActor::New());
356 Stage::GetCurrent().Add(alignment);
357 application.Render();
358 application.SendNotification();
360 // Check default values
361 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
363 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
364 alignment.SetAlignmentType(type);
365 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
367 Stage::GetCurrent().Remove(alignment);
368 application.Render();
369 application.SendNotification();
372 // HorizontalCenter, VerticalBottom
374 Alignment alignment = Alignment::New();
375 alignment.Add(RenderableActor::New());
376 Stage::GetCurrent().Add(alignment);
377 application.Render();
378 application.SendNotification();
380 // Check default values
381 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
383 Alignment::Type type(Alignment::VerticalBottom);
384 alignment.SetAlignmentType(type);
385 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
387 Stage::GetCurrent().Remove(alignment);
388 application.Render();
389 application.SendNotification();
392 // HorizontalRight, VerticalBottom
394 Alignment alignment = Alignment::New();
395 alignment.Add(RenderableActor::New());
396 Stage::GetCurrent().Add(alignment);
397 application.Render();
398 application.SendNotification();
400 // Check default values
401 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
403 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
404 alignment.SetAlignmentType(type);
405 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
407 Stage::GetCurrent().Remove(alignment);
408 application.Render();
409 application.SendNotification();
414 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
416 ToolkitTestApplication application;
418 // Setting HorizontalLeft, HorizontalCenter
420 Alignment alignment = Alignment::New();
421 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
422 alignment.SetAlignmentType(type);
423 // center will prevail in conflict
424 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
425 DALI_TEST_CHECK( !(Alignment::HorizontalLeft & alignment.GetAlignmentType()) );
428 // Setting HorizontalCenter, HorizontalRight
430 Alignment alignment = Alignment::New();
431 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
433 alignment.SetAlignmentType(type);
434 // center will prevail in conflict
435 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
436 DALI_TEST_CHECK( !(Alignment::HorizontalRight & alignment.GetAlignmentType()) );
439 // Setting VerticalTop, VerticalCenter
441 Alignment alignment = Alignment::New();
442 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
443 alignment.SetAlignmentType(type);
444 // center will prevail in conflict
445 DALI_TEST_CHECK( Alignment::VerticalCenter & alignment.GetAlignmentType() );
446 DALI_TEST_CHECK( !(Alignment::VerticalTop & alignment.GetAlignmentType()) );
449 // Setting VerticalCenter, VerticalBottom
451 Alignment alignment = Alignment::New();
452 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
453 alignment.SetAlignmentType(type);
454 // top will prevail in conflict
455 DALI_TEST_CHECK( Alignment::VerticalTop & alignment.GetAlignmentType() );
456 DALI_TEST_CHECK( !(Alignment::VerticalBottom & alignment.GetAlignmentType()) );
461 int UtcDaliAlignmentGetAlignmentType(void)
463 ToolkitTestApplication application;
465 // Default, HorizonalCenter, VerticalCenter
467 Alignment alignment = Alignment::New();
468 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
469 alignment.Add(RenderableActor::New());
470 Stage::GetCurrent().Add(alignment);
471 application.Render();
472 application.SendNotification();
473 Stage::GetCurrent().Remove(alignment);
474 application.Render();
475 application.SendNotification();
478 // HorizontalLeft, VerticalCenter
480 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
481 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
482 alignment.Add(RenderableActor::New());
483 Stage::GetCurrent().Add(alignment);
484 application.Render();
485 application.SendNotification();
486 Stage::GetCurrent().Remove(alignment);
487 application.Render();
488 application.SendNotification();
491 // HorizontalRight, VerticalCenter
493 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
494 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
495 alignment.Add(RenderableActor::New());
496 Stage::GetCurrent().Add(alignment);
497 application.Render();
498 application.SendNotification();
499 Stage::GetCurrent().Remove(alignment);
500 application.Render();
501 application.SendNotification();
504 // HorizontalLeft, VerticalTop
506 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
507 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
508 alignment.Add(RenderableActor::New());
509 Stage::GetCurrent().Add(alignment);
510 application.Render();
511 application.SendNotification();
512 Stage::GetCurrent().Remove(alignment);
513 application.Render();
514 application.SendNotification();
517 // HorizontalCenter, VerticalTop
519 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
520 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
521 alignment.Add(RenderableActor::New());
522 Stage::GetCurrent().Add(alignment);
523 application.Render();
524 application.SendNotification();
525 Stage::GetCurrent().Remove(alignment);
526 application.Render();
527 application.SendNotification();
530 // HorizontalRight, VerticalTop
532 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
533 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
534 alignment.Add(RenderableActor::New());
535 Stage::GetCurrent().Add(alignment);
536 application.Render();
537 application.SendNotification();
538 Stage::GetCurrent().Remove(alignment);
539 application.Render();
540 application.SendNotification();
543 // HorizontalLeft, VerticalBottom
545 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
546 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
547 alignment.Add(RenderableActor::New());
548 Stage::GetCurrent().Add(alignment);
549 application.Render();
550 application.SendNotification();
551 Stage::GetCurrent().Remove(alignment);
552 application.Render();
553 application.SendNotification();
556 // HorizontalCenter, VerticalBottom
558 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
559 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
560 alignment.Add(RenderableActor::New());
561 Stage::GetCurrent().Add(alignment);
562 application.Render();
563 application.SendNotification();
564 Stage::GetCurrent().Remove(alignment);
565 application.Render();
566 application.SendNotification();
569 // HorizontalRight, VerticalBottom
571 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
572 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
573 alignment.Add(RenderableActor::New());
574 Stage::GetCurrent().Add(alignment);
575 application.Render();
576 application.SendNotification();
577 Stage::GetCurrent().Remove(alignment);
578 application.Render();
579 application.SendNotification();
584 int UtcDaliAlignmentSetScaling(void)
586 ToolkitTestApplication application;
590 Alignment alignment = Alignment::New();
591 alignment.Add(RenderableActor::New());
592 Stage::GetCurrent().Add(alignment);
593 application.Render();
594 application.SendNotification();
596 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
597 alignment.SetScaling(Alignment::ScaleToFill);
598 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
599 application.Render();
600 application.SendNotification();
602 // For complete line coverage
603 alignment.SetAlignmentType(Alignment::HorizontalLeft);
604 application.Render();
605 application.SendNotification();
606 alignment.SetAlignmentType(Alignment::HorizontalRight);
607 application.Render();
608 application.SendNotification();
609 alignment.SetAlignmentType(Alignment::VerticalTop);
610 application.Render();
611 application.SendNotification();
612 alignment.SetAlignmentType(Alignment::VerticalBottom);
613 application.Render();
614 application.SendNotification();
616 Stage::GetCurrent().Remove(alignment);
617 application.Render();
618 application.SendNotification();
621 // ScaleToFitKeepAspect
623 Alignment alignment = Alignment::New();
624 alignment.Add(RenderableActor::New());
625 Stage::GetCurrent().Add(alignment);
626 application.Render();
627 application.SendNotification();
629 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
630 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
631 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
632 application.Render();
633 application.SendNotification();
635 // For complete line coverage
636 alignment.SetAlignmentType(Alignment::HorizontalLeft);
637 application.Render();
638 application.SendNotification();
639 alignment.SetAlignmentType(Alignment::HorizontalRight);
640 application.Render();
641 application.SendNotification();
642 alignment.SetAlignmentType(Alignment::VerticalTop);
643 application.Render();
644 application.SendNotification();
645 alignment.SetAlignmentType(Alignment::VerticalBottom);
646 application.Render();
647 application.SendNotification();
649 Stage::GetCurrent().Remove(alignment);
650 application.Render();
651 application.SendNotification();
654 // ScaleToFillKeepAspect
656 Alignment alignment = Alignment::New();
657 alignment.Add(RenderableActor::New());
658 Stage::GetCurrent().Add(alignment);
659 application.Render();
660 application.SendNotification();
662 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
663 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
664 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
665 application.Render();
666 application.SendNotification();
668 // For complete line coverage
669 alignment.SetAlignmentType(Alignment::HorizontalLeft);
670 application.Render();
671 application.SendNotification();
672 alignment.SetAlignmentType(Alignment::HorizontalRight);
673 application.Render();
674 application.SendNotification();
675 alignment.SetAlignmentType(Alignment::VerticalTop);
676 application.Render();
677 application.SendNotification();
678 alignment.SetAlignmentType(Alignment::VerticalBottom);
679 application.Render();
680 application.SendNotification();
682 Stage::GetCurrent().Remove(alignment);
683 application.Render();
684 application.SendNotification();
689 Alignment alignment = Alignment::New();
690 alignment.Add(RenderableActor::New());
691 Stage::GetCurrent().Add(alignment);
692 application.Render();
693 application.SendNotification();
695 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
696 alignment.SetScaling(Alignment::ShrinkToFit);
697 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
698 application.Render();
699 application.SendNotification();
701 // For complete line coverage
702 alignment.SetAlignmentType(Alignment::HorizontalLeft);
703 application.Render();
704 application.SendNotification();
705 alignment.SetAlignmentType(Alignment::HorizontalRight);
706 application.Render();
707 application.SendNotification();
708 alignment.SetAlignmentType(Alignment::VerticalTop);
709 application.Render();
710 application.SendNotification();
711 alignment.SetAlignmentType(Alignment::VerticalBottom);
712 application.Render();
713 application.SendNotification();
715 Stage::GetCurrent().Remove(alignment);
716 application.Render();
717 application.SendNotification();
720 // ShrinkToFitKeepAspect
722 Alignment alignment = Alignment::New();
723 alignment.Add(RenderableActor::New());
724 Stage::GetCurrent().Add(alignment);
725 application.Render();
726 application.SendNotification();
728 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
729 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
730 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
731 application.Render();
732 application.SendNotification();
734 // For complete line coverage
735 alignment.SetAlignmentType(Alignment::HorizontalLeft);
736 application.Render();
737 application.SendNotification();
738 alignment.SetAlignmentType(Alignment::HorizontalRight);
739 application.Render();
740 application.SendNotification();
741 alignment.SetAlignmentType(Alignment::VerticalTop);
742 application.Render();
743 application.SendNotification();
744 alignment.SetAlignmentType(Alignment::VerticalBottom);
745 application.Render();
746 application.SendNotification();
748 Stage::GetCurrent().Remove(alignment);
749 application.Render();
750 application.SendNotification();
755 int UtcDaliAlignmentGetScaling(void)
757 ToolkitTestApplication application;
761 Alignment alignment = Alignment::New();
762 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
764 alignment.SetScaling(Alignment::ScaleToFill);
765 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
768 // ScaleToFitKeepAspect
770 Alignment alignment = Alignment::New();
771 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
773 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
774 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
777 // ScaleToFillKeepAspect
779 Alignment alignment = Alignment::New();
780 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
782 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
783 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
788 Alignment alignment = Alignment::New();
789 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
791 alignment.SetScaling(Alignment::ShrinkToFit);
792 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
795 // ShrinkToFitKeepAspect
797 Alignment alignment = Alignment::New();
798 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
800 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
801 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
807 int UtcDaliAlignmentSetPaddingPositive(void)
809 ToolkitTestApplication application;
811 Alignment alignment = Alignment::New();
813 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
814 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
815 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
816 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
817 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
819 alignment.SetPadding(padding);
820 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
821 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
822 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
823 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
827 int UtcDaliAlignmentSetPaddingNegative(void)
829 ToolkitTestApplication application;
831 Alignment alignment = Alignment::New();
835 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
836 alignment.SetPadding(padding);
837 tet_result(TET_FAIL);
839 catch (DaliException& e)
841 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
846 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
847 alignment.SetPadding(padding);
848 tet_result(TET_FAIL);
850 catch (DaliException& e)
852 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
857 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
858 alignment.SetPadding(padding);
859 tet_result(TET_FAIL);
861 catch (DaliException& e)
863 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
868 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
869 alignment.SetPadding(padding);
870 tet_result(TET_FAIL);
872 catch (DaliException& e)
874 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
879 int UtcDaliAlignmentGetPadding(void)
881 ToolkitTestApplication application;
883 Alignment alignment = Alignment::New();
884 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
885 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
886 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
887 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
889 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
890 alignment.SetPadding(padding);
891 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
892 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
893 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
894 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
898 int UtcDaliAlignmentChildAddAndRemove(void)
900 ToolkitTestApplication application;
902 Alignment alignment = Alignment::New();
903 Stage::GetCurrent().Add(alignment);
905 application.Render();
906 application.SendNotification();
908 Actor actor = RenderableActor::New();
909 alignment.Add(actor);
911 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
913 application.Render();
914 application.SendNotification();
916 alignment.Remove(actor);
918 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
920 application.Render();
921 application.SendNotification();
923 Stage::GetCurrent().Remove(alignment);
927 int UtcDaliAlignmentSizeSetP(void)
929 ToolkitTestApplication application;
931 Alignment alignment = Alignment::New();
932 Stage::GetCurrent().Add(alignment);
934 application.Render();
935 application.SendNotification();
937 Vector2 size( 100.0f, 200.0f );
938 alignment.SetSize(size);
940 application.Render();
941 application.SendNotification();
942 application.Render();
943 application.SendNotification();
945 DALI_TEST_EQUALS(size, alignment.GetTargetSize().GetVectorXY(), TEST_LOCATION);
947 Stage::GetCurrent().Remove(alignment);
951 ///////////////////////////////////////////////////////////////////////////////
952 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
957 ///////////////////////////////////////////////////////////////////////////////
959 int UtcDaliAlignmentOnTouchEvent(void)
961 ToolkitTestApplication application;
963 Alignment alignment = Alignment::New();
964 alignment.SetSize(100.0f, 100.0f);
965 alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
966 Stage::GetCurrent().Add(alignment);
968 alignment.TouchedSignal().Connect(&TouchEventCallback);
970 application.Render();
971 application.SendNotification();
972 application.Render();
973 application.SendNotification();
975 Integration::TouchEvent touchEvent(1);
976 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
977 touchEvent.AddPoint(point);
978 application.ProcessEvent(touchEvent);
980 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
984 int UtcDaliAlignmentOnKeyEvent(void)
986 ToolkitTestApplication application;
988 Alignment alignment = Alignment::New();
989 Stage::GetCurrent().Add(alignment);
991 alignment.SetKeyInputFocus();
993 application.Render();
994 application.SendNotification();
995 application.Render();
996 application.SendNotification();
998 Integration::KeyEvent keyEvent;
999 application.ProcessEvent(keyEvent);
1001 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1005 int UtcDaliAlignmentOnSizeAnimation(void)
1007 ToolkitTestApplication application;
1009 Alignment alignment = Alignment::New();
1010 Stage::GetCurrent().Add(alignment);
1012 Animation animation = Animation::New(100.0f);
1013 animation.AnimateTo( Property( alignment, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
1016 application.Render();
1017 application.SendNotification();
1018 application.Render();
1019 application.SendNotification();
1021 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1025 int UtcDaliAlignmentCopyAndAssignment(void)
1027 ToolkitTestApplication application;
1029 Alignment alignment = Alignment::New();
1030 Alignment emptyAlignment;
1032 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1033 alignment.SetPadding(padding);
1035 Alignment alignmentCopy(alignment);
1036 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1037 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1038 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1039 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1041 Alignment alignmentEmptyCopy(emptyAlignment);
1042 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1044 Alignment alignmentEquals;
1045 alignmentEquals = alignment;
1046 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1047 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1048 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1049 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1051 Alignment alignmentEmptyEquals;
1052 alignmentEmptyEquals = emptyAlignment;
1053 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1056 alignment = alignment;
1057 DALI_TEST_CHECK(alignment == alignmentCopy);