Adding new test harness
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Alignment.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 #include <iostream>
18 #include <stdlib.h>
19
20
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/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Dali::Toolkit;
30
31 void utc_dali_toolkit_alignment_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void utc_dali_toolkit_alignment_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41
42 namespace
43 {
44 static bool gObjectCreatedCallBackCalled;
45
46 static void TestCallback(BaseHandle handle)
47 {
48   gObjectCreatedCallBackCalled = true;
49 }
50 } // namespace
51
52
53 int UtcDaliAlignmentConstructorNegative(void)
54 {
55   ToolkitTestApplication application;
56
57   Alignment alignment;
58
59   try
60   {
61     Alignment::Padding padding;
62     alignment.SetPadding(padding);
63     tet_result(TET_FAIL);
64   }
65   catch (DaliException& exception)
66   {
67     if (exception.mCondition == "alignment")
68     {
69       tet_result(TET_PASS);
70     }
71   }
72   END_TEST;
73 }
74
75 int UtcDaliAlignmentConstructorPositive(void)
76 {
77   ToolkitTestApplication application;
78
79   Alignment alignment = Alignment::New();
80
81   try
82   {
83     Alignment::Padding padding;
84     alignment.SetPadding(padding);
85     tet_result(TET_PASS);
86   }
87   catch (DaliException& exception)
88   {
89     tet_result(TET_FAIL);
90   }
91
92   Actor actor = alignment;
93   alignment = Alignment::DownCast( actor );
94
95   DALI_TEST_CHECK( alignment );
96   END_TEST;
97 }
98
99 int UtcDaliAlignmentConstructorRegister(void)
100 {
101   ToolkitTestApplication application;
102
103   //Te ensure the object is registered after creation
104   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
105   DALI_TEST_CHECK( registry );
106
107   gObjectCreatedCallBackCalled = false;
108   registry.ObjectCreatedSignal().Connect(&TestCallback);
109   {
110     Alignment alignment = Alignment::New();
111   }
112   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
113   END_TEST;
114 }
115
116 int UtcDaliAlignmentSetAlignmentTypePositiveOffStage(void)
117 {
118   ToolkitTestApplication application;
119
120   // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
121   {
122     Alignment alignment = Alignment::New();
123
124     // Check default values
125     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
126
127     Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
128     alignment.SetAlignmentType(type);
129     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
130   }
131
132   // HorizontalLeft, VerticalCenter
133   {
134     Alignment alignment = Alignment::New();
135
136     // Check default values
137     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
138
139     Alignment::Type type(Alignment::HorizontalLeft);
140     alignment.SetAlignmentType(type);
141     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
142   }
143
144   // HorizontalRight, VerticalCenter
145   {
146     Alignment alignment = Alignment::New();
147
148     // Check default values
149     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
150
151     Alignment::Type type(Alignment::HorizontalRight);
152     alignment.SetAlignmentType(type);
153     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
154   }
155
156   // HorizontalLeft, VerticalTop
157   {
158     Alignment alignment = Alignment::New();
159
160     // Check default values
161     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
162
163     Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
164     alignment.SetAlignmentType(type);
165     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
166   }
167
168   // HorizontalCenter, VerticalTop
169   {
170     Alignment alignment = Alignment::New();
171
172     // Check default values
173     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
174
175     Alignment::Type type(Alignment::VerticalTop);
176     alignment.SetAlignmentType(type);
177     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
178   }
179
180   // HorizontalRight, VerticalTop
181   {
182     Alignment alignment = Alignment::New();
183
184     // Check default values
185     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
186
187     Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
188     alignment.SetAlignmentType(type);
189     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
190   }
191
192   // HorizontalLeft, VerticalBottom
193   {
194     Alignment alignment = Alignment::New();
195
196     // Check default values
197     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
198
199     Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
200     alignment.SetAlignmentType(type);
201     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
202   }
203
204   // HorizontalCenter, VerticalBottom
205   {
206     Alignment alignment = Alignment::New();
207
208     // Check default values
209     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
210
211     Alignment::Type type(Alignment::VerticalBottom);
212     alignment.SetAlignmentType(type);
213     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
214   }
215
216   // HorizontalRight, VerticalBottom
217   {
218     Alignment alignment = Alignment::New();
219
220     // Check default values
221     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
222
223     Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
224     alignment.SetAlignmentType(type);
225     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
226   }
227   END_TEST;
228 }
229
230 int UtcDaliAlignmentSetAlignmentTypePositiveOnStage(void)
231 {
232   ToolkitTestApplication application;
233
234   // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
235   {
236     Alignment alignment = Alignment::New();
237     alignment.Add(RenderableActor::New());
238     Stage::GetCurrent().Add(alignment);
239     application.Render();
240     application.SendNotification();
241
242     // Check default values
243     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
244
245     Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
246     alignment.SetAlignmentType(type);
247     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
248
249     Stage::GetCurrent().Remove(alignment);
250     application.Render();
251     application.SendNotification();
252   }
253
254   // HorizontalLeft, VerticalCenter
255   {
256     Alignment alignment = Alignment::New();
257     alignment.Add(RenderableActor::New());
258     Stage::GetCurrent().Add(alignment);
259     application.Render();
260     application.SendNotification();
261
262     // Check default values
263     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
264
265     Alignment::Type type(Alignment::HorizontalLeft);
266     alignment.SetAlignmentType(type);
267     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
268
269     Stage::GetCurrent().Remove(alignment);
270     application.Render();
271     application.SendNotification();
272   }
273
274   // HorizontalRight, VerticalCenter
275   {
276     Alignment alignment = Alignment::New();
277     alignment.Add(RenderableActor::New());
278     Stage::GetCurrent().Add(alignment);
279     application.Render();
280     application.SendNotification();
281
282     // Check default values
283     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
284
285     Alignment::Type type(Alignment::HorizontalRight);
286     alignment.SetAlignmentType(type);
287     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
288
289     Stage::GetCurrent().Remove(alignment);
290     application.Render();
291     application.SendNotification();
292   }
293
294   // HorizontalLeft, VerticalTop
295   {
296     Alignment alignment = Alignment::New();
297     alignment.Add(RenderableActor::New());
298     Stage::GetCurrent().Add(alignment);
299     application.Render();
300     application.SendNotification();
301
302     // Check default values
303     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
304
305     Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
306     alignment.SetAlignmentType(type);
307     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
308
309     Stage::GetCurrent().Remove(alignment);
310     application.Render();
311     application.SendNotification();
312   }
313
314   // HorizontalCenter, VerticalTop
315   {
316     Alignment alignment = Alignment::New();
317     alignment.Add(RenderableActor::New());
318     Stage::GetCurrent().Add(alignment);
319     application.Render();
320     application.SendNotification();
321
322     // Check default values
323     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
324
325     Alignment::Type type(Alignment::VerticalTop);
326     alignment.SetAlignmentType(type);
327     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
328
329     Stage::GetCurrent().Remove(alignment);
330     application.Render();
331     application.SendNotification();
332   }
333
334   // HorizontalRight, VerticalTop
335   {
336     Alignment alignment = Alignment::New();
337     alignment.Add(RenderableActor::New());
338     Stage::GetCurrent().Add(alignment);
339     application.Render();
340     application.SendNotification();
341
342     // Check default values
343     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
344
345     Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
346     alignment.SetAlignmentType(type);
347     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
348
349     Stage::GetCurrent().Remove(alignment);
350     application.Render();
351     application.SendNotification();
352   }
353
354   // HorizontalLeft, VerticalBottom
355   {
356     Alignment alignment = Alignment::New();
357     alignment.Add(RenderableActor::New());
358     Stage::GetCurrent().Add(alignment);
359     application.Render();
360     application.SendNotification();
361
362     // Check default values
363     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
364
365     Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
366     alignment.SetAlignmentType(type);
367     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
368
369     Stage::GetCurrent().Remove(alignment);
370     application.Render();
371     application.SendNotification();
372   }
373
374   // HorizontalCenter, VerticalBottom
375   {
376     Alignment alignment = Alignment::New();
377     alignment.Add(RenderableActor::New());
378     Stage::GetCurrent().Add(alignment);
379     application.Render();
380     application.SendNotification();
381
382     // Check default values
383     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
384
385     Alignment::Type type(Alignment::VerticalBottom);
386     alignment.SetAlignmentType(type);
387     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
388
389     Stage::GetCurrent().Remove(alignment);
390     application.Render();
391     application.SendNotification();
392   }
393
394   // HorizontalRight, VerticalBottom
395   {
396     Alignment alignment = Alignment::New();
397     alignment.Add(RenderableActor::New());
398     Stage::GetCurrent().Add(alignment);
399     application.Render();
400     application.SendNotification();
401
402     // Check default values
403     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
404
405     Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
406     alignment.SetAlignmentType(type);
407     DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
408
409     Stage::GetCurrent().Remove(alignment);
410     application.Render();
411     application.SendNotification();
412   }
413   END_TEST;
414 }
415
416 int UtcDaliAlignmentSetAlignmentTypeNegative(void)
417 {
418   ToolkitTestApplication application;
419
420   // Setting HorizontalLeft, HorizontalCenter
421   {
422     Alignment alignment = Alignment::New();
423     Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
424
425     try
426     {
427       alignment.SetAlignmentType(type);
428       tet_result(TET_FAIL);
429     }
430     catch (DaliException& exception)
431     {
432       if (exception.mCondition == "!horizontalSet")
433       {
434         tet_result(TET_PASS);
435       }
436     }
437   }
438
439   // Setting HorizontalCenter, HorizontalRight
440   {
441     Alignment alignment = Alignment::New();
442     Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
443
444     try
445     {
446       alignment.SetAlignmentType(type);
447       tet_result(TET_FAIL);
448     }
449     catch (DaliException& exception)
450     {
451       if (exception.mCondition == "!horizontalSet")
452       {
453         tet_result(TET_PASS);
454       }
455     }
456   }
457
458   // Setting VerticalTop, VerticalCenter
459   {
460     Alignment alignment = Alignment::New();
461     Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
462
463     try
464     {
465       alignment.SetAlignmentType(type);
466       tet_result(TET_FAIL);
467     }
468     catch (DaliException& exception)
469     {
470       if (exception.mCondition == "!verticalSet")
471       {
472         tet_result(TET_PASS);
473       }
474     }
475   }
476
477   // Setting VerticalCenter, VerticalBottom
478   {
479     Alignment alignment = Alignment::New();
480     Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
481
482     try
483     {
484       alignment.SetAlignmentType(type);
485       tet_result(TET_FAIL);
486     }
487     catch (DaliException& exception)
488     {
489       if (exception.mCondition == "!veritcalSet")
490       {
491         tet_result(TET_PASS);
492       }
493     }
494   }
495   END_TEST;
496 }
497
498 int UtcDaliAlignmentGetAlignmentType(void)
499 {
500   ToolkitTestApplication application;
501
502   // Default, HorizonalCenter, VerticalCenter
503   {
504     Alignment alignment = Alignment::New();
505     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
506     alignment.Add(RenderableActor::New());
507     Stage::GetCurrent().Add(alignment);
508     application.Render();
509     application.SendNotification();
510     Stage::GetCurrent().Remove(alignment);
511     application.Render();
512     application.SendNotification();
513   }
514
515   // HorizontalLeft, VerticalCenter
516   {
517     Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
518     DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
519     alignment.Add(RenderableActor::New());
520     Stage::GetCurrent().Add(alignment);
521     application.Render();
522     application.SendNotification();
523     Stage::GetCurrent().Remove(alignment);
524     application.Render();
525     application.SendNotification();
526   }
527
528   // HorizontalRight, VerticalCenter
529   {
530     Alignment alignment = Alignment::New(Alignment::HorizontalRight);
531     DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
532     alignment.Add(RenderableActor::New());
533     Stage::GetCurrent().Add(alignment);
534     application.Render();
535     application.SendNotification();
536     Stage::GetCurrent().Remove(alignment);
537     application.Render();
538     application.SendNotification();
539   }
540
541   // HorizontalLeft, VerticalTop
542   {
543     Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
544     DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
545     alignment.Add(RenderableActor::New());
546     Stage::GetCurrent().Add(alignment);
547     application.Render();
548     application.SendNotification();
549     Stage::GetCurrent().Remove(alignment);
550     application.Render();
551     application.SendNotification();
552   }
553
554   // HorizontalCenter, VerticalTop
555   {
556     Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
557     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
558     alignment.Add(RenderableActor::New());
559     Stage::GetCurrent().Add(alignment);
560     application.Render();
561     application.SendNotification();
562     Stage::GetCurrent().Remove(alignment);
563     application.Render();
564     application.SendNotification();
565   }
566
567   // HorizontalRight, VerticalTop
568   {
569     Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
570     DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
571     alignment.Add(RenderableActor::New());
572     Stage::GetCurrent().Add(alignment);
573     application.Render();
574     application.SendNotification();
575     Stage::GetCurrent().Remove(alignment);
576     application.Render();
577     application.SendNotification();
578   }
579
580   // HorizontalLeft, VerticalBottom
581   {
582     Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
583     DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
584     alignment.Add(RenderableActor::New());
585     Stage::GetCurrent().Add(alignment);
586     application.Render();
587     application.SendNotification();
588     Stage::GetCurrent().Remove(alignment);
589     application.Render();
590     application.SendNotification();
591   }
592
593   // HorizontalCenter, VerticalBottom
594   {
595     Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
596     DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
597     alignment.Add(RenderableActor::New());
598     Stage::GetCurrent().Add(alignment);
599     application.Render();
600     application.SendNotification();
601     Stage::GetCurrent().Remove(alignment);
602     application.Render();
603     application.SendNotification();
604   }
605
606   // HorizontalRight, VerticalBottom
607   {
608     Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
609     DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
610     alignment.Add(RenderableActor::New());
611     Stage::GetCurrent().Add(alignment);
612     application.Render();
613     application.SendNotification();
614     Stage::GetCurrent().Remove(alignment);
615     application.Render();
616     application.SendNotification();
617   }
618   END_TEST;
619 }
620
621 int UtcDaliAlignmentSetScaling(void)
622 {
623   ToolkitTestApplication application;
624
625   // ScaleToFill
626   {
627     Alignment alignment = Alignment::New();
628     alignment.Add(RenderableActor::New());
629     Stage::GetCurrent().Add(alignment);
630     application.Render();
631     application.SendNotification();
632
633     DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
634     alignment.SetScaling(Alignment::ScaleToFill);
635     DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
636     application.Render();
637     application.SendNotification();
638
639     // For complete line coverage
640     alignment.SetAlignmentType(Alignment::HorizontalLeft);
641     application.Render();
642     application.SendNotification();
643     alignment.SetAlignmentType(Alignment::HorizontalRight);
644     application.Render();
645     application.SendNotification();
646     alignment.SetAlignmentType(Alignment::VerticalTop);
647     application.Render();
648     application.SendNotification();
649     alignment.SetAlignmentType(Alignment::VerticalBottom);
650     application.Render();
651     application.SendNotification();
652
653     Stage::GetCurrent().Remove(alignment);
654     application.Render();
655     application.SendNotification();
656   }
657
658   // ScaleToFitKeepAspect
659   {
660     Alignment alignment = Alignment::New();
661     alignment.Add(RenderableActor::New());
662     Stage::GetCurrent().Add(alignment);
663     application.Render();
664     application.SendNotification();
665
666     DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
667     alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
668     DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
669     application.Render();
670     application.SendNotification();
671
672     // For complete line coverage
673     alignment.SetAlignmentType(Alignment::HorizontalLeft);
674     application.Render();
675     application.SendNotification();
676     alignment.SetAlignmentType(Alignment::HorizontalRight);
677     application.Render();
678     application.SendNotification();
679     alignment.SetAlignmentType(Alignment::VerticalTop);
680     application.Render();
681     application.SendNotification();
682     alignment.SetAlignmentType(Alignment::VerticalBottom);
683     application.Render();
684     application.SendNotification();
685
686     Stage::GetCurrent().Remove(alignment);
687     application.Render();
688     application.SendNotification();
689   }
690
691   // ScaleToFillKeepAspect
692   {
693     Alignment alignment = Alignment::New();
694     alignment.Add(RenderableActor::New());
695     Stage::GetCurrent().Add(alignment);
696     application.Render();
697     application.SendNotification();
698
699     DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
700     alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
701     DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
702     application.Render();
703     application.SendNotification();
704
705     // For complete line coverage
706     alignment.SetAlignmentType(Alignment::HorizontalLeft);
707     application.Render();
708     application.SendNotification();
709     alignment.SetAlignmentType(Alignment::HorizontalRight);
710     application.Render();
711     application.SendNotification();
712     alignment.SetAlignmentType(Alignment::VerticalTop);
713     application.Render();
714     application.SendNotification();
715     alignment.SetAlignmentType(Alignment::VerticalBottom);
716     application.Render();
717     application.SendNotification();
718
719     Stage::GetCurrent().Remove(alignment);
720     application.Render();
721     application.SendNotification();
722   }
723
724   // ShrinkToFit
725   {
726     Alignment alignment = Alignment::New();
727     alignment.Add(RenderableActor::New());
728     Stage::GetCurrent().Add(alignment);
729     application.Render();
730     application.SendNotification();
731
732     DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
733     alignment.SetScaling(Alignment::ShrinkToFit);
734     DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
735     application.Render();
736     application.SendNotification();
737
738     // For complete line coverage
739     alignment.SetAlignmentType(Alignment::HorizontalLeft);
740     application.Render();
741     application.SendNotification();
742     alignment.SetAlignmentType(Alignment::HorizontalRight);
743     application.Render();
744     application.SendNotification();
745     alignment.SetAlignmentType(Alignment::VerticalTop);
746     application.Render();
747     application.SendNotification();
748     alignment.SetAlignmentType(Alignment::VerticalBottom);
749     application.Render();
750     application.SendNotification();
751
752     Stage::GetCurrent().Remove(alignment);
753     application.Render();
754     application.SendNotification();
755   }
756
757   // ShrinkToFitKeepAspect
758   {
759     Alignment alignment = Alignment::New();
760     alignment.Add(RenderableActor::New());
761     Stage::GetCurrent().Add(alignment);
762     application.Render();
763     application.SendNotification();
764
765     DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
766     alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
767     DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
768     application.Render();
769     application.SendNotification();
770
771     // For complete line coverage
772     alignment.SetAlignmentType(Alignment::HorizontalLeft);
773     application.Render();
774     application.SendNotification();
775     alignment.SetAlignmentType(Alignment::HorizontalRight);
776     application.Render();
777     application.SendNotification();
778     alignment.SetAlignmentType(Alignment::VerticalTop);
779     application.Render();
780     application.SendNotification();
781     alignment.SetAlignmentType(Alignment::VerticalBottom);
782     application.Render();
783     application.SendNotification();
784
785     Stage::GetCurrent().Remove(alignment);
786     application.Render();
787     application.SendNotification();
788   }
789   END_TEST;
790 }
791
792 int UtcDaliAlignmentGetScaling(void)
793 {
794   ToolkitTestApplication application;
795
796   // ScaleToFill
797   {
798     Alignment alignment = Alignment::New();
799     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
800
801     alignment.SetScaling(Alignment::ScaleToFill);
802     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
803   }
804
805   // ScaleToFitKeepAspect
806   {
807     Alignment alignment = Alignment::New();
808     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
809
810     alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
811     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
812   }
813
814   // ScaleToFillKeepAspect
815   {
816     Alignment alignment = Alignment::New();
817     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
818
819     alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
820     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
821   }
822
823   // ShrinkToFit
824   {
825     Alignment alignment = Alignment::New();
826     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
827
828     alignment.SetScaling(Alignment::ShrinkToFit);
829     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
830   }
831
832   // ShrinkToFitKeepAspect
833   {
834     Alignment alignment = Alignment::New();
835     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
836
837     alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
838     DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
839   }
840
841   END_TEST;
842 }
843
844 int UtcDaliAlignmentSetPaddingPositive(void)
845 {
846   ToolkitTestApplication application;
847
848   Alignment alignment = Alignment::New();
849
850   Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
851   DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
852   DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
853   DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
854   DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
855
856   alignment.SetPadding(padding);
857   DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
858   DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
859   DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
860   DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
861   END_TEST;
862 }
863
864 int UtcDaliAlignmentSetPaddingNegative(void)
865 {
866   ToolkitTestApplication application;
867
868   Alignment alignment = Alignment::New();
869
870   try
871   {
872     Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
873     alignment.SetPadding(padding);
874     tet_result(TET_FAIL);
875   }
876   catch (DaliException& exception)
877   {
878     if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
879     {
880       tet_result(TET_PASS);
881     }
882   }
883
884   try
885   {
886     Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
887     alignment.SetPadding(padding);
888     tet_result(TET_FAIL);
889   }
890   catch (DaliException& exception)
891   {
892     if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
893     {
894       tet_result(TET_PASS);
895     }
896   }
897
898   try
899   {
900     Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
901     alignment.SetPadding(padding);
902     tet_result(TET_FAIL);
903   }
904   catch (DaliException& exception)
905   {
906     if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
907     {
908       tet_result(TET_PASS);
909     }
910   }
911
912   try
913   {
914     Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
915     alignment.SetPadding(padding);
916     tet_result(TET_FAIL);
917   }
918   catch (DaliException& exception)
919   {
920     if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
921     {
922       tet_result(TET_PASS);
923     }
924   }
925   END_TEST;
926 }
927
928 int UtcDaliAlignmentGetPadding(void)
929 {
930   ToolkitTestApplication application;
931
932   Alignment alignment = Alignment::New();
933   DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
934   DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
935   DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
936   DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
937
938   Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
939   alignment.SetPadding(padding);
940   DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
941   DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
942   DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
943   DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
944   END_TEST;
945 }
946
947 int UtcDaliAlignmentChildAddAndRemove(void)
948 {
949   ToolkitTestApplication application;
950
951   Alignment alignment = Alignment::New();
952   Stage::GetCurrent().Add(alignment);
953
954   application.Render();
955   application.SendNotification();
956
957   Actor actor = RenderableActor::New();
958   alignment.Add(actor);
959
960   DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
961
962   application.Render();
963   application.SendNotification();
964
965   alignment.Remove(actor);
966
967   DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
968
969   application.Render();
970   application.SendNotification();
971
972   Stage::GetCurrent().Remove(alignment);
973   END_TEST;
974 }
975
976 int UtcDaliAlignmentOnSizeSet(void)
977 {
978   ToolkitTestApplication application;
979
980   Alignment alignment = Alignment::New();
981   Stage::GetCurrent().Add(alignment);
982
983   application.Render();
984   application.SendNotification();
985
986   Vector3 size(100.0f, 200.0f, 0.0f);
987   alignment.SetSize(size);
988
989   application.Render();
990   application.SendNotification();
991   application.Render();
992   application.SendNotification();
993
994   DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
995
996   Stage::GetCurrent().Remove(alignment);
997   END_TEST;
998 }
999
1000 ///////////////////////////////////////////////////////////////////////////////
1001 static bool TouchEventCallback(Actor actor, const TouchEvent& event)
1002 {
1003   return false;
1004 }
1005
1006 ///////////////////////////////////////////////////////////////////////////////
1007
1008 int UtcDaliAlignmentOnTouchEvent(void)
1009 {
1010   ToolkitTestApplication application;
1011
1012   Alignment alignment = Alignment::New();
1013   alignment.SetSize(100.0f, 100.0f);
1014   alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1015   Stage::GetCurrent().Add(alignment);
1016
1017   alignment.TouchedSignal().Connect(&TouchEventCallback);
1018
1019   application.Render();
1020   application.SendNotification();
1021   application.Render();
1022   application.SendNotification();
1023
1024   Integration::TouchEvent touchEvent(1);
1025   TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
1026   touchEvent.AddPoint(point);
1027   application.ProcessEvent(touchEvent);
1028
1029   tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1030   END_TEST;
1031 }
1032
1033 int UtcDaliAlignmentOnKeyEvent(void)
1034 {
1035   ToolkitTestApplication application;
1036
1037   Alignment alignment = Alignment::New();
1038   Stage::GetCurrent().Add(alignment);
1039
1040   alignment.SetKeyInputFocus();
1041
1042   application.Render();
1043   application.SendNotification();
1044   application.Render();
1045   application.SendNotification();
1046
1047   Integration::KeyEvent keyEvent;
1048   application.ProcessEvent(keyEvent);
1049
1050   tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1051   END_TEST;
1052 }
1053
1054 int UtcDaliAlignmentOnSizeAnimation(void)
1055 {
1056   ToolkitTestApplication application;
1057
1058   Alignment alignment = Alignment::New();
1059   Stage::GetCurrent().Add(alignment);
1060
1061   Animation animation = Animation::New(100.0f);
1062   animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
1063   animation.Play();
1064
1065   application.Render();
1066   application.SendNotification();
1067   application.Render();
1068   application.SendNotification();
1069
1070   tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
1071   END_TEST;
1072 }
1073
1074 int UtcDaliAlignmentCopyAndAssignment(void)
1075 {
1076   ToolkitTestApplication application;
1077
1078   Alignment alignment = Alignment::New();
1079   Alignment emptyAlignment;
1080
1081   Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
1082   alignment.SetPadding(padding);
1083
1084   Alignment alignmentCopy(alignment);
1085   DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
1086   DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
1087   DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
1088   DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
1089
1090   Alignment alignmentEmptyCopy(emptyAlignment);
1091   DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
1092
1093   Alignment alignmentEquals;
1094   alignmentEquals = alignment;
1095   DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
1096   DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
1097   DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
1098   DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
1099
1100   Alignment alignmentEmptyEquals;
1101   alignmentEmptyEquals = emptyAlignment;
1102   DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
1103
1104   // Self assignment
1105   alignment = alignment;
1106   DALI_TEST_CHECK(alignment == alignmentCopy);
1107   END_TEST;
1108 }