2 * Copyright (c) 2020 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/devel-api/controls/alignment/alignment.h>
28 #include <dali-toolkit/dali-toolkit.h>
31 using namespace Dali::Toolkit;
33 void utc_dali_toolkit_alignment_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_toolkit_alignment_cleanup(void)
40 test_return_value = TET_PASS;
45 /// Compare an int (Or'd Alignment::Type) with an Alignment::Type value
46 void DALI_TEST_EQUALS( int value1, Alignment::Type value2, const char* location )
48 ::DALI_TEST_EQUALS< Alignment::Type >( static_cast< Alignment::Type >( value1 ), value2, location );
51 static bool gObjectCreatedCallBackCalled;
53 static void TestCallback(BaseHandle handle)
55 gObjectCreatedCallBackCalled = true;
60 int UtcDaliAlignmentConstructorNegative(void)
62 ToolkitTestApplication application;
68 Alignment::Padding padding;
69 alignment.SetPadding(padding);
72 catch (DaliException& e)
74 DALI_TEST_ASSERT(e, "alignment", TEST_LOCATION );
79 int UtcDaliAlignmentConstructorPositive(void)
81 ToolkitTestApplication application;
83 Alignment alignment = Alignment::New();
87 Alignment::Padding padding;
88 alignment.SetPadding(padding);
91 catch (DaliException& exception)
96 Actor actor = alignment;
97 alignment = Alignment::DownCast( actor );
99 DALI_TEST_CHECK( alignment );
103 int UtcDaliAlignmentConstructorRegister(void)
105 ToolkitTestApplication application;
107 //To ensure the object is registered after creation
108 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
109 DALI_TEST_CHECK( registry );
111 gObjectCreatedCallBackCalled = false;
112 registry.ObjectCreatedSignal().Connect(&TestCallback);
114 Alignment alignment = Alignment::New();
116 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
120 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
122 ToolkitTestApplication application;
124 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
126 Alignment alignment = Alignment::New();
128 // Check default values
129 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
131 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
132 alignment.SetAlignmentType(type);
133 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
136 // HorizontalLeft, VerticalCenter
138 Alignment alignment = Alignment::New();
140 // Check default values
141 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
143 Alignment::Type type(Alignment::HorizontalLeft);
144 alignment.SetAlignmentType(type);
145 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
148 // HorizontalRight, VerticalCenter
150 Alignment alignment = Alignment::New();
152 // Check default values
153 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
155 Alignment::Type type(Alignment::HorizontalRight);
156 alignment.SetAlignmentType(type);
157 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
160 // HorizontalLeft, VerticalTop
162 Alignment alignment = Alignment::New();
164 // Check default values
165 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
167 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
168 alignment.SetAlignmentType(type);
169 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
172 // HorizontalCenter, VerticalTop
174 Alignment alignment = Alignment::New();
176 // Check default values
177 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
179 Alignment::Type type(Alignment::VerticalTop);
180 alignment.SetAlignmentType(type);
181 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
184 // HorizontalRight, VerticalTop
186 Alignment alignment = Alignment::New();
188 // Check default values
189 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
191 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
192 alignment.SetAlignmentType(type);
193 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
196 // HorizontalLeft, VerticalBottom
198 Alignment alignment = Alignment::New();
200 // Check default values
201 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
203 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
204 alignment.SetAlignmentType(type);
205 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
208 // HorizontalCenter, VerticalBottom
210 Alignment alignment = Alignment::New();
212 // Check default values
213 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
215 Alignment::Type type(Alignment::VerticalBottom);
216 alignment.SetAlignmentType(type);
217 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
220 // HorizontalRight, VerticalBottom
222 Alignment alignment = Alignment::New();
224 // Check default values
225 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
227 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
228 alignment.SetAlignmentType(type);
229 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
234 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
236 ToolkitTestApplication application;
238 // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
240 Alignment alignment = Alignment::New();
241 alignment.Add(Actor::New());
242 application.GetScene().Add(alignment);
243 application.Render();
244 application.SendNotification();
246 // Check default values
247 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
249 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
250 alignment.SetAlignmentType(type);
251 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
253 application.GetScene().Remove(alignment);
254 application.Render();
255 application.SendNotification();
258 // HorizontalLeft, VerticalCenter
260 Alignment alignment = Alignment::New();
261 alignment.Add(Actor::New());
262 application.GetScene().Add(alignment);
263 application.Render();
264 application.SendNotification();
266 // Check default values
267 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
269 Alignment::Type type(Alignment::HorizontalLeft);
270 alignment.SetAlignmentType(type);
271 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
273 application.GetScene().Remove(alignment);
274 application.Render();
275 application.SendNotification();
278 // HorizontalRight, VerticalCenter
280 Alignment alignment = Alignment::New();
281 alignment.Add(Actor::New());
282 application.GetScene().Add(alignment);
283 application.Render();
284 application.SendNotification();
286 // Check default values
287 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
289 Alignment::Type type(Alignment::HorizontalRight);
290 alignment.SetAlignmentType(type);
291 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
293 application.GetScene().Remove(alignment);
294 application.Render();
295 application.SendNotification();
298 // HorizontalLeft, VerticalTop
300 Alignment alignment = Alignment::New();
301 alignment.Add(Actor::New());
302 application.GetScene().Add(alignment);
303 application.Render();
304 application.SendNotification();
306 // Check default values
307 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
309 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
310 alignment.SetAlignmentType(type);
311 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
313 application.GetScene().Remove(alignment);
314 application.Render();
315 application.SendNotification();
318 // HorizontalCenter, VerticalTop
320 Alignment alignment = Alignment::New();
321 alignment.Add(Actor::New());
322 application.GetScene().Add(alignment);
323 application.Render();
324 application.SendNotification();
326 // Check default values
327 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
329 Alignment::Type type(Alignment::VerticalTop);
330 alignment.SetAlignmentType(type);
331 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
333 application.GetScene().Remove(alignment);
334 application.Render();
335 application.SendNotification();
338 // HorizontalRight, VerticalTop
340 Alignment alignment = Alignment::New();
341 alignment.Add(Actor::New());
342 application.GetScene().Add(alignment);
343 application.Render();
344 application.SendNotification();
346 // Check default values
347 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
349 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
350 alignment.SetAlignmentType(type);
351 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
353 application.GetScene().Remove(alignment);
354 application.Render();
355 application.SendNotification();
358 // HorizontalLeft, VerticalBottom
360 Alignment alignment = Alignment::New();
361 alignment.Add(Actor::New());
362 application.GetScene().Add(alignment);
363 application.Render();
364 application.SendNotification();
366 // Check default values
367 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
369 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
370 alignment.SetAlignmentType(type);
371 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
373 application.GetScene().Remove(alignment);
374 application.Render();
375 application.SendNotification();
378 // HorizontalCenter, VerticalBottom
380 Alignment alignment = Alignment::New();
381 alignment.Add(Actor::New());
382 application.GetScene().Add(alignment);
383 application.Render();
384 application.SendNotification();
386 // Check default values
387 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
389 Alignment::Type type(Alignment::VerticalBottom);
390 alignment.SetAlignmentType(type);
391 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
393 application.GetScene().Remove(alignment);
394 application.Render();
395 application.SendNotification();
398 // HorizontalRight, VerticalBottom
400 Alignment alignment = Alignment::New();
401 alignment.Add(Actor::New());
402 application.GetScene().Add(alignment);
403 application.Render();
404 application.SendNotification();
406 // Check default values
407 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
409 Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
410 alignment.SetAlignmentType(type);
411 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
413 application.GetScene().Remove(alignment);
414 application.Render();
415 application.SendNotification();
420 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
422 ToolkitTestApplication application;
424 // Setting HorizontalLeft, HorizontalCenter
426 Alignment alignment = Alignment::New();
427 Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
428 alignment.SetAlignmentType(type);
429 // center will prevail in conflict
430 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
431 DALI_TEST_CHECK( !(Alignment::HorizontalLeft & alignment.GetAlignmentType()) );
434 // Setting HorizontalCenter, HorizontalRight
436 Alignment alignment = Alignment::New();
437 Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
439 alignment.SetAlignmentType(type);
440 // center will prevail in conflict
441 DALI_TEST_CHECK( Alignment::HorizontalCenter & alignment.GetAlignmentType() );
442 DALI_TEST_CHECK( !(Alignment::HorizontalRight & alignment.GetAlignmentType()) );
445 // Setting VerticalTop, VerticalCenter
447 Alignment alignment = Alignment::New();
448 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
449 alignment.SetAlignmentType(type);
450 // center will prevail in conflict
451 DALI_TEST_CHECK( Alignment::VerticalCenter & alignment.GetAlignmentType() );
452 DALI_TEST_CHECK( !(Alignment::VerticalTop & alignment.GetAlignmentType()) );
455 // Setting VerticalCenter, VerticalBottom
457 Alignment alignment = Alignment::New();
458 Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
459 alignment.SetAlignmentType(type);
460 // top will prevail in conflict
461 DALI_TEST_CHECK( Alignment::VerticalTop & alignment.GetAlignmentType() );
462 DALI_TEST_CHECK( !(Alignment::VerticalBottom & alignment.GetAlignmentType()) );
467 int UtcDaliAlignmentGetAlignmentType(void)
469 ToolkitTestApplication application;
471 // Default, HorizonalCenter, VerticalCenter
473 Alignment alignment = Alignment::New();
474 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
475 alignment.Add(Actor::New());
476 application.GetScene().Add(alignment);
477 application.Render();
478 application.SendNotification();
479 application.GetScene().Remove(alignment);
480 application.Render();
481 application.SendNotification();
484 // HorizontalLeft, VerticalCenter
486 Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
487 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
488 alignment.Add(Actor::New());
489 application.GetScene().Add(alignment);
490 application.Render();
491 application.SendNotification();
492 application.GetScene().Remove(alignment);
493 application.Render();
494 application.SendNotification();
497 // HorizontalRight, VerticalCenter
499 Alignment alignment = Alignment::New(Alignment::HorizontalRight);
500 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
501 alignment.Add(Actor::New());
502 application.GetScene().Add(alignment);
503 application.Render();
504 application.SendNotification();
505 application.GetScene().Remove(alignment);
506 application.Render();
507 application.SendNotification();
510 // HorizontalLeft, VerticalTop
512 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
513 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
514 alignment.Add(Actor::New());
515 application.GetScene().Add(alignment);
516 application.Render();
517 application.SendNotification();
518 application.GetScene().Remove(alignment);
519 application.Render();
520 application.SendNotification();
523 // HorizontalCenter, VerticalTop
525 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
526 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
527 alignment.Add(Actor::New());
528 application.GetScene().Add(alignment);
529 application.Render();
530 application.SendNotification();
531 application.GetScene().Remove(alignment);
532 application.Render();
533 application.SendNotification();
536 // HorizontalRight, VerticalTop
538 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
539 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
540 alignment.Add(Actor::New());
541 application.GetScene().Add(alignment);
542 application.Render();
543 application.SendNotification();
544 application.GetScene().Remove(alignment);
545 application.Render();
546 application.SendNotification();
549 // HorizontalLeft, VerticalBottom
551 Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
552 DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
553 alignment.Add(Actor::New());
554 application.GetScene().Add(alignment);
555 application.Render();
556 application.SendNotification();
557 application.GetScene().Remove(alignment);
558 application.Render();
559 application.SendNotification();
562 // HorizontalCenter, VerticalBottom
564 Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
565 DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
566 alignment.Add(Actor::New());
567 application.GetScene().Add(alignment);
568 application.Render();
569 application.SendNotification();
570 application.GetScene().Remove(alignment);
571 application.Render();
572 application.SendNotification();
575 // HorizontalRight, VerticalBottom
577 Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
578 DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
579 alignment.Add(Actor::New());
580 application.GetScene().Add(alignment);
581 application.Render();
582 application.SendNotification();
583 application.GetScene().Remove(alignment);
584 application.Render();
585 application.SendNotification();
590 int UtcDaliAlignmentSetScaling(void)
592 ToolkitTestApplication application;
596 Alignment alignment = Alignment::New();
597 alignment.Add(Actor::New());
598 application.GetScene().Add(alignment);
599 application.Render();
600 application.SendNotification();
602 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
603 alignment.SetScaling(Alignment::ScaleToFill);
604 DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
605 application.Render();
606 application.SendNotification();
608 // For complete line coverage
609 alignment.SetAlignmentType(Alignment::HorizontalLeft);
610 application.Render();
611 application.SendNotification();
612 alignment.SetAlignmentType(Alignment::HorizontalRight);
613 application.Render();
614 application.SendNotification();
615 alignment.SetAlignmentType(Alignment::VerticalTop);
616 application.Render();
617 application.SendNotification();
618 alignment.SetAlignmentType(Alignment::VerticalBottom);
619 application.Render();
620 application.SendNotification();
622 application.GetScene().Remove(alignment);
623 application.Render();
624 application.SendNotification();
627 // ScaleToFitKeepAspect
629 Alignment alignment = Alignment::New();
630 alignment.Add(Actor::New());
631 application.GetScene().Add(alignment);
632 application.Render();
633 application.SendNotification();
635 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
636 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
637 DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
638 application.Render();
639 application.SendNotification();
641 // For complete line coverage
642 alignment.SetAlignmentType(Alignment::HorizontalLeft);
643 application.Render();
644 application.SendNotification();
645 alignment.SetAlignmentType(Alignment::HorizontalRight);
646 application.Render();
647 application.SendNotification();
648 alignment.SetAlignmentType(Alignment::VerticalTop);
649 application.Render();
650 application.SendNotification();
651 alignment.SetAlignmentType(Alignment::VerticalBottom);
652 application.Render();
653 application.SendNotification();
655 application.GetScene().Remove(alignment);
656 application.Render();
657 application.SendNotification();
660 // ScaleToFillKeepAspect
662 Alignment alignment = Alignment::New();
663 alignment.Add(Actor::New());
664 application.GetScene().Add(alignment);
665 application.Render();
666 application.SendNotification();
668 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
669 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
670 DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
671 application.Render();
672 application.SendNotification();
674 // For complete line coverage
675 alignment.SetAlignmentType(Alignment::HorizontalLeft);
676 application.Render();
677 application.SendNotification();
678 alignment.SetAlignmentType(Alignment::HorizontalRight);
679 application.Render();
680 application.SendNotification();
681 alignment.SetAlignmentType(Alignment::VerticalTop);
682 application.Render();
683 application.SendNotification();
684 alignment.SetAlignmentType(Alignment::VerticalBottom);
685 application.Render();
686 application.SendNotification();
688 application.GetScene().Remove(alignment);
689 application.Render();
690 application.SendNotification();
695 Alignment alignment = Alignment::New();
696 alignment.Add(Actor::New());
697 application.GetScene().Add(alignment);
698 application.Render();
699 application.SendNotification();
701 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
702 alignment.SetScaling(Alignment::ShrinkToFit);
703 DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
704 application.Render();
705 application.SendNotification();
707 // For complete line coverage
708 alignment.SetAlignmentType(Alignment::HorizontalLeft);
709 application.Render();
710 application.SendNotification();
711 alignment.SetAlignmentType(Alignment::HorizontalRight);
712 application.Render();
713 application.SendNotification();
714 alignment.SetAlignmentType(Alignment::VerticalTop);
715 application.Render();
716 application.SendNotification();
717 alignment.SetAlignmentType(Alignment::VerticalBottom);
718 application.Render();
719 application.SendNotification();
721 application.GetScene().Remove(alignment);
722 application.Render();
723 application.SendNotification();
726 // ShrinkToFitKeepAspect
728 Alignment alignment = Alignment::New();
729 alignment.Add(Actor::New());
730 application.GetScene().Add(alignment);
731 application.Render();
732 application.SendNotification();
734 DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
735 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
736 DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
737 application.Render();
738 application.SendNotification();
740 // For complete line coverage
741 alignment.SetAlignmentType(Alignment::HorizontalLeft);
742 application.Render();
743 application.SendNotification();
744 alignment.SetAlignmentType(Alignment::HorizontalRight);
745 application.Render();
746 application.SendNotification();
747 alignment.SetAlignmentType(Alignment::VerticalTop);
748 application.Render();
749 application.SendNotification();
750 alignment.SetAlignmentType(Alignment::VerticalBottom);
751 application.Render();
752 application.SendNotification();
754 application.GetScene().Remove(alignment);
755 application.Render();
756 application.SendNotification();
761 int UtcDaliAlignmentGetScaling(void)
763 ToolkitTestApplication application;
767 Alignment alignment = Alignment::New();
768 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
770 alignment.SetScaling(Alignment::ScaleToFill);
771 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
774 // ScaleToFitKeepAspect
776 Alignment alignment = Alignment::New();
777 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
779 alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
780 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
783 // ScaleToFillKeepAspect
785 Alignment alignment = Alignment::New();
786 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
788 alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
789 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
794 Alignment alignment = Alignment::New();
795 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
797 alignment.SetScaling(Alignment::ShrinkToFit);
798 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
801 // ShrinkToFitKeepAspect
803 Alignment alignment = Alignment::New();
804 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
806 alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
807 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
813 int UtcDaliAlignmentSetPaddingPositive(void)
815 ToolkitTestApplication application;
817 Alignment alignment = Alignment::New();
819 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
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 ) );
825 alignment.SetPadding(padding);
826 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
827 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
828 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
829 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
833 int UtcDaliAlignmentSetPaddingNegative(void)
835 ToolkitTestApplication application;
837 Alignment alignment = Alignment::New();
841 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
842 alignment.SetPadding(padding);
843 tet_result(TET_FAIL);
845 catch (DaliException& e)
847 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
852 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
853 alignment.SetPadding(padding);
854 tet_result(TET_FAIL);
856 catch (DaliException& e)
858 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
863 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
864 alignment.SetPadding(padding);
865 tet_result(TET_FAIL);
867 catch (DaliException& e)
869 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
874 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
875 alignment.SetPadding(padding);
876 tet_result(TET_FAIL);
878 catch (DaliException& e)
880 DALI_TEST_ASSERT(e, "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )", TEST_LOCATION );
885 int UtcDaliAlignmentGetPadding(void)
887 ToolkitTestApplication application;
889 Alignment alignment = Alignment::New();
890 DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
891 DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
892 DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
893 DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
895 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
896 alignment.SetPadding(padding);
897 DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
898 DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
899 DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
900 DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
904 int UtcDaliAlignmentChildAddAndRemove(void)
906 ToolkitTestApplication application;
908 Alignment alignment = Alignment::New();
909 application.GetScene().Add(alignment);
911 application.Render();
912 application.SendNotification();
914 Actor actor = Actor::New();
915 alignment.Add(actor);
917 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
919 application.Render();
920 application.SendNotification();
922 alignment.Remove(actor);
924 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
926 application.Render();
927 application.SendNotification();
929 application.GetScene().Remove(alignment);
933 int UtcDaliAlignmentSizeSetP(void)
935 ToolkitTestApplication application;
937 Alignment alignment = Alignment::New();
938 application.GetScene().Add(alignment);
940 application.Render();
941 application.SendNotification();
943 Vector2 size( 100.0f, 200.0f );
944 alignment.SetProperty( Actor::Property::SIZE, size);
946 application.Render();
947 application.SendNotification();
948 application.Render();
949 application.SendNotification();
951 DALI_TEST_EQUALS(size, alignment.GetTargetSize().GetVectorXY(), TEST_LOCATION);
953 application.GetScene().Remove(alignment);
957 ///////////////////////////////////////////////////////////////////////////////
958 static bool TouchCallback(Actor actor, const TouchData& event)
963 ///////////////////////////////////////////////////////////////////////////////
965 int UtcDaliAlignmentOnTouchEvent(void)
967 ToolkitTestApplication application;
969 Alignment alignment = Alignment::New();
970 alignment.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
971 alignment.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
972 application.GetScene().Add(alignment);
974 alignment.TouchSignal().Connect(&TouchCallback);
976 application.Render();
977 application.SendNotification();
978 application.Render();
979 application.SendNotification();
981 Integration::TouchEvent touchEvent(1);
982 Integration::Point point;
983 point.SetDeviceId( 1 );
984 point.SetState( PointState::DOWN);
985 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
986 touchEvent.AddPoint(point);
987 application.ProcessEvent(touchEvent);
989 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
993 int UtcDaliAlignmentOnKeyEvent(void)
995 ToolkitTestApplication application;
997 Alignment alignment = Alignment::New();
998 application.GetScene().Add(alignment);
1000 alignment.SetKeyInputFocus();
1002 application.Render();
1003 application.SendNotification();
1004 application.Render();
1005 application.SendNotification();
1007 Integration::KeyEvent keyEvent;
1008 application.ProcessEvent(keyEvent);
1010 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1014 int UtcDaliAlignmentOnSizeAnimation(void)
1016 ToolkitTestApplication application;
1018 Alignment alignment = Alignment::New();
1019 application.GetScene().Add(alignment);
1021 Animation animation = Animation::New(100.0f);
1022 animation.AnimateTo( Property( alignment, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
1025 application.Render();
1026 application.SendNotification();
1027 application.Render();
1028 application.SendNotification();
1030 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1034 int UtcDaliAlignmentCopyAndAssignment(void)
1036 ToolkitTestApplication application;
1038 Alignment alignment = Alignment::New();
1039 Alignment emptyAlignment;
1041 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1042 alignment.SetPadding(padding);
1044 Alignment alignmentCopy(alignment);
1045 DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1046 DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1047 DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1048 DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1050 Alignment alignmentEmptyCopy(emptyAlignment);
1051 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1053 Alignment alignmentEquals;
1054 alignmentEquals = alignment;
1055 DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1056 DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1057 DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1058 DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1060 Alignment alignmentEmptyEquals;
1061 alignmentEmptyEquals = emptyAlignment;
1062 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1065 alignment = alignment;
1066 DALI_TEST_CHECK(alignment == alignmentCopy);