2 * Copyright (c) 2022 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.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit/devel-api/controls/alignment/alignment.h>
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/integration-api/events/touch-event-integ.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;
58 int UtcDaliAlignmentConstructorNegative(void)
60 ToolkitTestApplication application;
66 Alignment::Padding padding;
67 alignment.SetPadding(padding);
70 catch(DaliException& e)
72 DALI_TEST_ASSERT(e, "alignment", TEST_LOCATION);
77 int UtcDaliAlignmentConstructorPositive(void)
79 ToolkitTestApplication application;
81 Alignment alignment = Alignment::New();
85 Alignment::Padding padding;
86 alignment.SetPadding(padding);
89 catch(DaliException& exception)
94 Actor actor = alignment;
95 alignment = Alignment::DownCast(actor);
97 DALI_TEST_CHECK(alignment);
101 int UtcDaliAlignmentConstructorRegister(void)
103 ToolkitTestApplication application;
105 //To ensure the object is registered after creation
106 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
107 DALI_TEST_CHECK(registry);
109 gObjectCreatedCallBackCalled = false;
110 registry.ObjectCreatedSignal().Connect(&TestCallback);
112 Alignment alignment = Alignment::New();
114 DALI_TEST_CHECK(gObjectCreatedCallBackCalled);
118 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
120 ToolkitTestApplication application;
122 // Default, HORIZONTAL_CENTER, VERTICAL_CENTER - Ensure they do not change!
124 Alignment alignment = Alignment::New();
126 // Check default values
127 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
129 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER));
130 alignment.SetAlignmentType(type);
131 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
134 // HORIZONTAL_LEFT, VERTICAL_CENTER
136 Alignment alignment = Alignment::New();
138 // Check default values
139 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
141 Alignment::Type type(Alignment::HORIZONTAL_LEFT);
142 alignment.SetAlignmentType(type);
143 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
146 // HORIZONTAL_RIGHT, VERTICAL_CENTER
148 Alignment alignment = Alignment::New();
150 // Check default values
151 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
153 Alignment::Type type(Alignment::HORIZONTAL_RIGHT);
154 alignment.SetAlignmentType(type);
155 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
158 // HORIZONTAL_LEFT, VERTICAL_TOP
160 Alignment alignment = Alignment::New();
162 // Check default values
163 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
165 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_TOP));
166 alignment.SetAlignmentType(type);
167 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
170 // HORIZONTAL_CENTER, VERTICAL_TOP
172 Alignment alignment = Alignment::New();
174 // Check default values
175 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
177 Alignment::Type type(Alignment::VERTICAL_TOP);
178 alignment.SetAlignmentType(type);
179 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
182 // HORIZONTAL_RIGHT, VERTICAL_TOP
184 Alignment alignment = Alignment::New();
186 // Check default values
187 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
189 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_TOP));
190 alignment.SetAlignmentType(type);
191 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
194 // HORIZONTAL_LEFT, VERTICAL_BOTTOM
196 Alignment alignment = Alignment::New();
198 // Check default values
199 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
201 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_BOTTOM));
202 alignment.SetAlignmentType(type);
203 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
206 // HORIZONTAL_CENTER, VERTICAL_BOTTOM
208 Alignment alignment = Alignment::New();
210 // Check default values
211 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
213 Alignment::Type type(Alignment::VERTICAL_BOTTOM);
214 alignment.SetAlignmentType(type);
215 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
218 // HORIZONTAL_RIGHT, VERTICAL_BOTTOM
220 Alignment alignment = Alignment::New();
222 // Check default values
223 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
225 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_BOTTOM));
226 alignment.SetAlignmentType(type);
227 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
232 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
234 ToolkitTestApplication application;
236 // Default, HORIZONTAL_CENTER, VERTICAL_CENTER - Ensure they do not change!
238 Alignment alignment = Alignment::New();
239 alignment.Add(Actor::New());
240 application.GetScene().Add(alignment);
241 application.Render();
242 application.SendNotification();
244 // Check default values
245 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
247 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER));
248 alignment.SetAlignmentType(type);
249 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
251 application.GetScene().Remove(alignment);
252 application.Render();
253 application.SendNotification();
256 // HORIZONTAL_LEFT, VERTICAL_CENTER
258 Alignment alignment = Alignment::New();
259 alignment.Add(Actor::New());
260 application.GetScene().Add(alignment);
261 application.Render();
262 application.SendNotification();
264 // Check default values
265 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
267 Alignment::Type type(Alignment::HORIZONTAL_LEFT);
268 alignment.SetAlignmentType(type);
269 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
271 application.GetScene().Remove(alignment);
272 application.Render();
273 application.SendNotification();
276 // HORIZONTAL_RIGHT, VERTICAL_CENTER
278 Alignment alignment = Alignment::New();
279 alignment.Add(Actor::New());
280 application.GetScene().Add(alignment);
281 application.Render();
282 application.SendNotification();
284 // Check default values
285 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
287 Alignment::Type type(Alignment::HORIZONTAL_RIGHT);
288 alignment.SetAlignmentType(type);
289 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
291 application.GetScene().Remove(alignment);
292 application.Render();
293 application.SendNotification();
296 // HORIZONTAL_LEFT, VERTICAL_TOP
298 Alignment alignment = Alignment::New();
299 alignment.Add(Actor::New());
300 application.GetScene().Add(alignment);
301 application.Render();
302 application.SendNotification();
304 // Check default values
305 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
307 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_TOP));
308 alignment.SetAlignmentType(type);
309 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
311 application.GetScene().Remove(alignment);
312 application.Render();
313 application.SendNotification();
316 // HORIZONTAL_CENTER, VERTICAL_TOP
318 Alignment alignment = Alignment::New();
319 alignment.Add(Actor::New());
320 application.GetScene().Add(alignment);
321 application.Render();
322 application.SendNotification();
324 // Check default values
325 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
327 Alignment::Type type(Alignment::VERTICAL_TOP);
328 alignment.SetAlignmentType(type);
329 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
331 application.GetScene().Remove(alignment);
332 application.Render();
333 application.SendNotification();
336 // HORIZONTAL_RIGHT, VERTICAL_TOP
338 Alignment alignment = Alignment::New();
339 alignment.Add(Actor::New());
340 application.GetScene().Add(alignment);
341 application.Render();
342 application.SendNotification();
344 // Check default values
345 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
347 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_TOP));
348 alignment.SetAlignmentType(type);
349 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
351 application.GetScene().Remove(alignment);
352 application.Render();
353 application.SendNotification();
356 // HORIZONTAL_LEFT, VERTICAL_BOTTOM
358 Alignment alignment = Alignment::New();
359 alignment.Add(Actor::New());
360 application.GetScene().Add(alignment);
361 application.Render();
362 application.SendNotification();
364 // Check default values
365 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
367 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_BOTTOM));
368 alignment.SetAlignmentType(type);
369 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
371 application.GetScene().Remove(alignment);
372 application.Render();
373 application.SendNotification();
376 // HORIZONTAL_CENTER, VERTICAL_BOTTOM
378 Alignment alignment = Alignment::New();
379 alignment.Add(Actor::New());
380 application.GetScene().Add(alignment);
381 application.Render();
382 application.SendNotification();
384 // Check default values
385 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
387 Alignment::Type type(Alignment::VERTICAL_BOTTOM);
388 alignment.SetAlignmentType(type);
389 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
391 application.GetScene().Remove(alignment);
392 application.Render();
393 application.SendNotification();
396 // HORIZONTAL_RIGHT, VERTICAL_BOTTOM
398 Alignment alignment = Alignment::New();
399 alignment.Add(Actor::New());
400 application.GetScene().Add(alignment);
401 application.Render();
402 application.SendNotification();
404 // Check default values
405 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
407 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_BOTTOM));
408 alignment.SetAlignmentType(type);
409 DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
411 application.GetScene().Remove(alignment);
412 application.Render();
413 application.SendNotification();
418 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
420 ToolkitTestApplication application;
422 // Setting HORIZONTAL_LEFT, HORIZONTAL_CENTER
424 Alignment alignment = Alignment::New();
425 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_LEFT | Alignment::HORIZONTAL_CENTER));
426 alignment.SetAlignmentType(type);
427 // center will prevail in conflict
428 DALI_TEST_CHECK(Alignment::HORIZONTAL_CENTER & alignment.GetAlignmentType());
429 DALI_TEST_CHECK(!(Alignment::HORIZONTAL_LEFT & alignment.GetAlignmentType()));
432 // Setting HORIZONTAL_CENTER, HORIZONTAL_RIGHT
434 Alignment alignment = Alignment::New();
435 Alignment::Type type(Alignment::Type(Alignment::HORIZONTAL_CENTER | Alignment::HORIZONTAL_RIGHT));
437 alignment.SetAlignmentType(type);
438 // center will prevail in conflict
439 DALI_TEST_CHECK(Alignment::HORIZONTAL_CENTER & alignment.GetAlignmentType());
440 DALI_TEST_CHECK(!(Alignment::HORIZONTAL_RIGHT & alignment.GetAlignmentType()));
443 // Setting VERTICAL_TOP, VERTICAL_CENTER
445 Alignment alignment = Alignment::New();
446 Alignment::Type type(Alignment::Type(Alignment::VERTICAL_TOP | Alignment::VERTICAL_CENTER));
447 alignment.SetAlignmentType(type);
448 // center will prevail in conflict
449 DALI_TEST_CHECK(Alignment::VERTICAL_CENTER & alignment.GetAlignmentType());
450 DALI_TEST_CHECK(!(Alignment::VERTICAL_TOP & alignment.GetAlignmentType()));
453 // Setting VERTICAL_CENTER, VERTICAL_BOTTOM
455 Alignment alignment = Alignment::New();
456 Alignment::Type type(Alignment::Type(Alignment::VERTICAL_TOP | Alignment::VERTICAL_BOTTOM));
457 alignment.SetAlignmentType(type);
458 // top will prevail in conflict
459 DALI_TEST_CHECK(Alignment::VERTICAL_TOP & alignment.GetAlignmentType());
460 DALI_TEST_CHECK(!(Alignment::VERTICAL_BOTTOM & alignment.GetAlignmentType()));
465 int UtcDaliAlignmentGetAlignmentType(void)
467 ToolkitTestApplication application;
469 // Default, HorizonalCenter, VERTICAL_CENTER
471 Alignment alignment = Alignment::New();
472 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
473 alignment.Add(Actor::New());
474 application.GetScene().Add(alignment);
475 application.Render();
476 application.SendNotification();
477 application.GetScene().Remove(alignment);
478 application.Render();
479 application.SendNotification();
482 // HORIZONTAL_LEFT, VERTICAL_CENTER
484 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_LEFT);
485 DALI_TEST_EQUALS(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
486 alignment.Add(Actor::New());
487 application.GetScene().Add(alignment);
488 application.Render();
489 application.SendNotification();
490 application.GetScene().Remove(alignment);
491 application.Render();
492 application.SendNotification();
495 // HORIZONTAL_RIGHT, VERTICAL_CENTER
497 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_RIGHT);
498 DALI_TEST_EQUALS(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_CENTER, alignment.GetAlignmentType(), TEST_LOCATION);
499 alignment.Add(Actor::New());
500 application.GetScene().Add(alignment);
501 application.Render();
502 application.SendNotification();
503 application.GetScene().Remove(alignment);
504 application.Render();
505 application.SendNotification();
508 // HORIZONTAL_LEFT, VERTICAL_TOP
510 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_LEFT, Alignment::VERTICAL_TOP);
511 DALI_TEST_EQUALS(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_TOP, alignment.GetAlignmentType(), TEST_LOCATION);
512 alignment.Add(Actor::New());
513 application.GetScene().Add(alignment);
514 application.Render();
515 application.SendNotification();
516 application.GetScene().Remove(alignment);
517 application.Render();
518 application.SendNotification();
521 // HORIZONTAL_CENTER, VERTICAL_TOP
523 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_CENTER, Alignment::VERTICAL_TOP);
524 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_TOP, alignment.GetAlignmentType(), TEST_LOCATION);
525 alignment.Add(Actor::New());
526 application.GetScene().Add(alignment);
527 application.Render();
528 application.SendNotification();
529 application.GetScene().Remove(alignment);
530 application.Render();
531 application.SendNotification();
534 // HORIZONTAL_RIGHT, VERTICAL_TOP
536 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_RIGHT, Alignment::VERTICAL_TOP);
537 DALI_TEST_EQUALS(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_TOP, alignment.GetAlignmentType(), TEST_LOCATION);
538 alignment.Add(Actor::New());
539 application.GetScene().Add(alignment);
540 application.Render();
541 application.SendNotification();
542 application.GetScene().Remove(alignment);
543 application.Render();
544 application.SendNotification();
547 // HORIZONTAL_LEFT, VERTICAL_BOTTOM
549 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_LEFT, Alignment::VERTICAL_BOTTOM);
550 DALI_TEST_EQUALS(Alignment::HORIZONTAL_LEFT | Alignment::VERTICAL_BOTTOM, alignment.GetAlignmentType(), TEST_LOCATION);
551 alignment.Add(Actor::New());
552 application.GetScene().Add(alignment);
553 application.Render();
554 application.SendNotification();
555 application.GetScene().Remove(alignment);
556 application.Render();
557 application.SendNotification();
560 // HORIZONTAL_CENTER, VERTICAL_BOTTOM
562 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_CENTER, Alignment::VERTICAL_BOTTOM);
563 DALI_TEST_EQUALS(Alignment::HORIZONTAL_CENTER | Alignment::VERTICAL_BOTTOM, alignment.GetAlignmentType(), TEST_LOCATION);
564 alignment.Add(Actor::New());
565 application.GetScene().Add(alignment);
566 application.Render();
567 application.SendNotification();
568 application.GetScene().Remove(alignment);
569 application.Render();
570 application.SendNotification();
573 // HORIZONTAL_RIGHT, VERTICAL_BOTTOM
575 Alignment alignment = Alignment::New(Alignment::HORIZONTAL_RIGHT, Alignment::VERTICAL_BOTTOM);
576 DALI_TEST_EQUALS(Alignment::HORIZONTAL_RIGHT | Alignment::VERTICAL_BOTTOM, alignment.GetAlignmentType(), TEST_LOCATION);
577 alignment.Add(Actor::New());
578 application.GetScene().Add(alignment);
579 application.Render();
580 application.SendNotification();
581 application.GetScene().Remove(alignment);
582 application.Render();
583 application.SendNotification();
588 int UtcDaliAlignmentSetScaling(void)
590 ToolkitTestApplication application;
594 Alignment alignment = Alignment::New();
595 alignment.Add(Actor::New());
596 application.GetScene().Add(alignment);
597 application.Render();
598 application.SendNotification();
600 DALI_TEST_EQUALS(Alignment::SCALE_NONE, alignment.GetScaling(), TEST_LOCATION);
601 alignment.SetScaling(Alignment::SCALE_TO_FILL);
602 DALI_TEST_EQUALS(Alignment::SCALE_TO_FILL, alignment.GetScaling(), TEST_LOCATION);
603 application.Render();
604 application.SendNotification();
606 // For complete line coverage
607 alignment.SetAlignmentType(Alignment::HORIZONTAL_LEFT);
608 application.Render();
609 application.SendNotification();
610 alignment.SetAlignmentType(Alignment::HORIZONTAL_RIGHT);
611 application.Render();
612 application.SendNotification();
613 alignment.SetAlignmentType(Alignment::VERTICAL_TOP);
614 application.Render();
615 application.SendNotification();
616 alignment.SetAlignmentType(Alignment::VERTICAL_BOTTOM);
617 application.Render();
618 application.SendNotification();
620 application.GetScene().Remove(alignment);
621 application.Render();
622 application.SendNotification();
625 // SCALE_TO_FIT_KEEP_ASPECT
627 Alignment alignment = Alignment::New();
628 alignment.Add(Actor::New());
629 application.GetScene().Add(alignment);
630 application.Render();
631 application.SendNotification();
633 DALI_TEST_EQUALS(Alignment::SCALE_NONE, alignment.GetScaling(), TEST_LOCATION);
634 alignment.SetScaling(Alignment::SCALE_TO_FIT_KEEP_ASPECT);
635 DALI_TEST_EQUALS(Alignment::SCALE_TO_FIT_KEEP_ASPECT, alignment.GetScaling(), TEST_LOCATION);
636 application.Render();
637 application.SendNotification();
639 // For complete line coverage
640 alignment.SetAlignmentType(Alignment::HORIZONTAL_LEFT);
641 application.Render();
642 application.SendNotification();
643 alignment.SetAlignmentType(Alignment::HORIZONTAL_RIGHT);
644 application.Render();
645 application.SendNotification();
646 alignment.SetAlignmentType(Alignment::VERTICAL_TOP);
647 application.Render();
648 application.SendNotification();
649 alignment.SetAlignmentType(Alignment::VERTICAL_BOTTOM);
650 application.Render();
651 application.SendNotification();
653 application.GetScene().Remove(alignment);
654 application.Render();
655 application.SendNotification();
658 // SCALE_TO_FILL_KEEP_ASPECT
660 Alignment alignment = Alignment::New();
661 alignment.Add(Actor::New());
662 application.GetScene().Add(alignment);
663 application.Render();
664 application.SendNotification();
666 DALI_TEST_EQUALS(Alignment::SCALE_NONE, alignment.GetScaling(), TEST_LOCATION);
667 alignment.SetScaling(Alignment::SCALE_TO_FILL_KEEP_ASPECT);
668 DALI_TEST_EQUALS(Alignment::SCALE_TO_FILL_KEEP_ASPECT, alignment.GetScaling(), TEST_LOCATION);
669 application.Render();
670 application.SendNotification();
672 // For complete line coverage
673 alignment.SetAlignmentType(Alignment::HORIZONTAL_LEFT);
674 application.Render();
675 application.SendNotification();
676 alignment.SetAlignmentType(Alignment::HORIZONTAL_RIGHT);
677 application.Render();
678 application.SendNotification();
679 alignment.SetAlignmentType(Alignment::VERTICAL_TOP);
680 application.Render();
681 application.SendNotification();
682 alignment.SetAlignmentType(Alignment::VERTICAL_BOTTOM);
683 application.Render();
684 application.SendNotification();
686 application.GetScene().Remove(alignment);
687 application.Render();
688 application.SendNotification();
693 Alignment alignment = Alignment::New();
694 alignment.Add(Actor::New());
695 application.GetScene().Add(alignment);
696 application.Render();
697 application.SendNotification();
699 DALI_TEST_EQUALS(Alignment::SCALE_NONE, alignment.GetScaling(), TEST_LOCATION);
700 alignment.SetScaling(Alignment::SHRINK_TO_FIT);
701 DALI_TEST_EQUALS(Alignment::SHRINK_TO_FIT, alignment.GetScaling(), TEST_LOCATION);
702 application.Render();
703 application.SendNotification();
705 // For complete line coverage
706 alignment.SetAlignmentType(Alignment::HORIZONTAL_LEFT);
707 application.Render();
708 application.SendNotification();
709 alignment.SetAlignmentType(Alignment::HORIZONTAL_RIGHT);
710 application.Render();
711 application.SendNotification();
712 alignment.SetAlignmentType(Alignment::VERTICAL_TOP);
713 application.Render();
714 application.SendNotification();
715 alignment.SetAlignmentType(Alignment::VERTICAL_BOTTOM);
716 application.Render();
717 application.SendNotification();
719 application.GetScene().Remove(alignment);
720 application.Render();
721 application.SendNotification();
724 // SHRINK_TO_FIT_KEEP_ASPECT
726 Alignment alignment = Alignment::New();
727 alignment.Add(Actor::New());
728 application.GetScene().Add(alignment);
729 application.Render();
730 application.SendNotification();
732 DALI_TEST_EQUALS(Alignment::SCALE_NONE, alignment.GetScaling(), TEST_LOCATION);
733 alignment.SetScaling(Alignment::SHRINK_TO_FIT_KEEP_ASPECT);
734 DALI_TEST_EQUALS(Alignment::SHRINK_TO_FIT_KEEP_ASPECT, alignment.GetScaling(), TEST_LOCATION);
735 application.Render();
736 application.SendNotification();
738 // For complete line coverage
739 alignment.SetAlignmentType(Alignment::HORIZONTAL_LEFT);
740 application.Render();
741 application.SendNotification();
742 alignment.SetAlignmentType(Alignment::HORIZONTAL_RIGHT);
743 application.Render();
744 application.SendNotification();
745 alignment.SetAlignmentType(Alignment::VERTICAL_TOP);
746 application.Render();
747 application.SendNotification();
748 alignment.SetAlignmentType(Alignment::VERTICAL_BOTTOM);
749 application.Render();
750 application.SendNotification();
752 application.GetScene().Remove(alignment);
753 application.Render();
754 application.SendNotification();
759 int UtcDaliAlignmentGetScaling(void)
761 ToolkitTestApplication application;
765 Alignment alignment = Alignment::New();
766 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_NONE);
768 alignment.SetScaling(Alignment::SCALE_TO_FILL);
769 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_TO_FILL);
772 // SCALE_TO_FIT_KEEP_ASPECT
774 Alignment alignment = Alignment::New();
775 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_NONE);
777 alignment.SetScaling(Alignment::SCALE_TO_FIT_KEEP_ASPECT);
778 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_TO_FIT_KEEP_ASPECT);
781 // SCALE_TO_FILL_KEEP_ASPECT
783 Alignment alignment = Alignment::New();
784 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_NONE);
786 alignment.SetScaling(Alignment::SCALE_TO_FILL_KEEP_ASPECT);
787 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_TO_FILL_KEEP_ASPECT);
792 Alignment alignment = Alignment::New();
793 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_NONE);
795 alignment.SetScaling(Alignment::SHRINK_TO_FIT);
796 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SHRINK_TO_FIT);
799 // SHRINK_TO_FIT_KEEP_ASPECT
801 Alignment alignment = Alignment::New();
802 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SCALE_NONE);
804 alignment.SetScaling(Alignment::SHRINK_TO_FIT_KEEP_ASPECT);
805 DALI_TEST_CHECK(alignment.GetScaling() == Alignment::SHRINK_TO_FIT_KEEP_ASPECT);
811 int UtcDaliAlignmentSetPaddingPositive(void)
813 ToolkitTestApplication application;
815 Alignment alignment = Alignment::New();
817 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
818 DALI_TEST_CHECK(fabs(padding.left - alignment.GetPadding().left) > GetRangedEpsilon(padding.left, alignment.GetPadding().left));
819 DALI_TEST_CHECK(fabs(padding.right - alignment.GetPadding().right) > GetRangedEpsilon(padding.right, alignment.GetPadding().right));
820 DALI_TEST_CHECK(fabs(padding.top - alignment.GetPadding().top) > GetRangedEpsilon(padding.top, alignment.GetPadding().top));
821 DALI_TEST_CHECK(fabs(padding.bottom - alignment.GetPadding().bottom) > GetRangedEpsilon(padding.bottom, alignment.GetPadding().bottom));
823 alignment.SetPadding(padding);
824 DALI_TEST_CHECK(fabs(padding.left - alignment.GetPadding().left) < GetRangedEpsilon(padding.left, alignment.GetPadding().left));
825 DALI_TEST_CHECK(fabs(padding.right - alignment.GetPadding().right) < GetRangedEpsilon(padding.right, alignment.GetPadding().right));
826 DALI_TEST_CHECK(fabs(padding.top - alignment.GetPadding().top) < GetRangedEpsilon(padding.top, alignment.GetPadding().top));
827 DALI_TEST_CHECK(fabs(padding.bottom - alignment.GetPadding().bottom) < GetRangedEpsilon(padding.bottom, alignment.GetPadding().bottom));
831 int UtcDaliAlignmentSetPaddingNegative(void)
833 ToolkitTestApplication application;
835 Alignment alignment = Alignment::New();
839 Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
840 alignment.SetPadding(padding);
841 tet_result(TET_FAIL);
843 catch(DaliException& e)
845 DALI_TEST_ASSERT(e, "(padding.left >= 0.f) && (padding.top >= 0.f) && (padding.right >= 0.f) && (padding.bottom >= 0.f)", TEST_LOCATION);
850 Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
851 alignment.SetPadding(padding);
852 tet_result(TET_FAIL);
854 catch(DaliException& e)
856 DALI_TEST_ASSERT(e, "(padding.left >= 0.f) && (padding.top >= 0.f) && (padding.right >= 0.f) && (padding.bottom >= 0.f)", TEST_LOCATION);
861 Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
862 alignment.SetPadding(padding);
863 tet_result(TET_FAIL);
865 catch(DaliException& e)
867 DALI_TEST_ASSERT(e, "(padding.left >= 0.f) && (padding.top >= 0.f) && (padding.right >= 0.f) && (padding.bottom >= 0.f)", TEST_LOCATION);
872 Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
873 alignment.SetPadding(padding);
874 tet_result(TET_FAIL);
876 catch(DaliException& e)
878 DALI_TEST_ASSERT(e, "(padding.left >= 0.f) && (padding.top >= 0.f) && (padding.right >= 0.f) && (padding.bottom >= 0.f)", TEST_LOCATION);
883 int UtcDaliAlignmentGetPadding(void)
885 ToolkitTestApplication application;
887 Alignment alignment = Alignment::New();
888 DALI_TEST_CHECK(fabs(alignment.GetPadding().left) < GetRangedEpsilon(0.f, alignment.GetPadding().left));
889 DALI_TEST_CHECK(fabs(alignment.GetPadding().right) < GetRangedEpsilon(0.f, alignment.GetPadding().right));
890 DALI_TEST_CHECK(fabs(alignment.GetPadding().top) < GetRangedEpsilon(0.f, alignment.GetPadding().top));
891 DALI_TEST_CHECK(fabs(alignment.GetPadding().bottom) < GetRangedEpsilon(0.f, alignment.GetPadding().bottom));
893 Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
894 alignment.SetPadding(padding);
895 DALI_TEST_CHECK(fabs(padding.left - alignment.GetPadding().left) < GetRangedEpsilon(padding.left, alignment.GetPadding().left));
896 DALI_TEST_CHECK(fabs(padding.right - alignment.GetPadding().right) < GetRangedEpsilon(padding.right, alignment.GetPadding().right));
897 DALI_TEST_CHECK(fabs(padding.top - alignment.GetPadding().top) < GetRangedEpsilon(padding.top, alignment.GetPadding().top));
898 DALI_TEST_CHECK(fabs(padding.bottom - alignment.GetPadding().bottom) < GetRangedEpsilon(padding.bottom, alignment.GetPadding().bottom));
902 int UtcDaliAlignmentChildAddAndRemove(void)
904 ToolkitTestApplication application;
906 Alignment alignment = Alignment::New();
907 application.GetScene().Add(alignment);
909 application.Render();
910 application.SendNotification();
912 Actor actor = Actor::New();
913 alignment.Add(actor);
915 DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
917 application.Render();
918 application.SendNotification();
920 alignment.Remove(actor);
922 DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
924 application.Render();
925 application.SendNotification();
927 application.GetScene().Remove(alignment);
931 int UtcDaliAlignmentSizeSetP(void)
933 ToolkitTestApplication application;
935 Alignment alignment = Alignment::New();
936 application.GetScene().Add(alignment);
938 application.Render();
939 application.SendNotification();
941 Vector2 size(100.0f, 200.0f);
942 alignment.SetProperty(Actor::Property::SIZE, size);
944 application.Render();
945 application.SendNotification();
946 application.Render();
947 application.SendNotification();
949 DALI_TEST_EQUALS(size, alignment.GetTargetSize().GetVectorXY(), TEST_LOCATION);
951 application.GetScene().Remove(alignment);
955 ///////////////////////////////////////////////////////////////////////////////
956 static bool TouchCallback(Actor actor, const TouchEvent& event)
961 ///////////////////////////////////////////////////////////////////////////////
963 int UtcDaliAlignmentOnTouchEvent(void)
965 ToolkitTestApplication application;
967 Alignment alignment = Alignment::New();
968 alignment.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
969 alignment.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
970 application.GetScene().Add(alignment);
972 alignment.TouchedSignal().Connect(&TouchCallback);
974 application.Render();
975 application.SendNotification();
976 application.Render();
977 application.SendNotification();
979 Integration::TouchEvent touchEvent(1);
980 Integration::Point point;
981 point.SetDeviceId(1);
982 point.SetState(PointState::DOWN);
983 point.SetScreenPosition(Vector2(20.0f, 20.0f));
984 touchEvent.AddPoint(point);
985 application.ProcessEvent(touchEvent);
987 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
991 int UtcDaliAlignmentOnKeyEvent(void)
993 ToolkitTestApplication application;
995 Alignment alignment = Alignment::New();
996 application.GetScene().Add(alignment);
998 alignment.SetKeyInputFocus();
1000 application.Render();
1001 application.SendNotification();
1002 application.Render();
1003 application.SendNotification();
1005 Integration::KeyEvent keyEvent;
1006 application.ProcessEvent(keyEvent);
1008 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1012 int UtcDaliAlignmentOnSizeAnimation(void)
1014 ToolkitTestApplication application;
1016 Alignment alignment = Alignment::New();
1017 application.GetScene().Add(alignment);
1019 Animation animation = Animation::New(100.0f);
1020 animation.AnimateTo(Property(alignment, Actor::Property::SIZE), Vector3(100.0f, 150.0f, 200.0f));
1023 application.Render();
1024 application.SendNotification();
1025 application.Render();
1026 application.SendNotification();
1028 tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1032 int UtcDaliAlignmentCopyAndAssignment(void)
1034 ToolkitTestApplication application;
1036 Alignment alignment = Alignment::New();
1037 Alignment emptyAlignment;
1039 Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1040 alignment.SetPadding(padding);
1042 Alignment alignmentCopy(alignment);
1043 DALI_TEST_CHECK(fabs(padding.left - alignmentCopy.GetPadding().left) < GetRangedEpsilon(padding.left, alignmentCopy.GetPadding().left));
1044 DALI_TEST_CHECK(fabs(padding.right - alignmentCopy.GetPadding().right) < GetRangedEpsilon(padding.right, alignmentCopy.GetPadding().right));
1045 DALI_TEST_CHECK(fabs(padding.top - alignmentCopy.GetPadding().top) < GetRangedEpsilon(padding.top, alignmentCopy.GetPadding().top));
1046 DALI_TEST_CHECK(fabs(padding.bottom - alignmentCopy.GetPadding().bottom) < GetRangedEpsilon(padding.bottom, alignmentCopy.GetPadding().bottom));
1048 Alignment alignmentEmptyCopy(emptyAlignment);
1049 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1051 Alignment alignmentEquals;
1052 alignmentEquals = alignment;
1053 DALI_TEST_CHECK(fabs(padding.left - alignmentEquals.GetPadding().left) < GetRangedEpsilon(padding.left, alignmentEquals.GetPadding().left));
1054 DALI_TEST_CHECK(fabs(padding.right - alignmentEquals.GetPadding().right) < GetRangedEpsilon(padding.right, alignmentEquals.GetPadding().right));
1055 DALI_TEST_CHECK(fabs(padding.top - alignmentEquals.GetPadding().top) < GetRangedEpsilon(padding.top, alignmentEquals.GetPadding().top));
1056 DALI_TEST_CHECK(fabs(padding.bottom - alignmentEquals.GetPadding().bottom) < GetRangedEpsilon(padding.bottom, alignmentEquals.GetPadding().bottom));
1058 Alignment alignmentEmptyEquals;
1059 alignmentEmptyEquals = emptyAlignment;
1060 DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1063 alignment = alignment;
1064 DALI_TEST_CHECK(alignment == alignmentCopy);