[dali_1.0.52] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Popup.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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
18 #include <stdlib.h>
19
20 // Need to override adaptor classes for toolkit test harness, so include
21 // test harness headers before dali headers.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include "dali-toolkit-test-utils/toolkit-timer.h"
24
25 #include <dali.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/devel-api/scripting/scripting.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/popup/popup.h>
30
31 using namespace Dali;
32 using namespace Toolkit;
33
34 void utc_dali_toolkit_popup_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_toolkit_popup_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 namespace
45 {
46 static bool gObjectCreatedCallBackCalled;
47
48 static void TestCallback(BaseHandle handle)
49 {
50   gObjectCreatedCallBackCalled = true;
51 }
52
53 const int RENDER_FRAME_INTERVAL = 10;                          ///< Duration of each frame in ms.
54 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000;            ///< 2000ms to test animation.
55 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
56 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
57 const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10.0f, 10.0f );
58 const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10.0f, 10.0f );
59
60 /**
61  * Counts how many descendants root Actor has, including
62  * itself.
63  *
64  * @param[in] root The root actor to count from.
65  * @return The number of descendants including root actor itself.
66  */
67 int DescendentCount(const Actor& root)
68 {
69   unsigned int numChildren = root.GetChildCount();
70
71   int count = 1;
72
73   for(unsigned int i=0; i<numChildren; ++i)
74   {
75     count += DescendentCount(root.GetChildAt(i));
76   }
77
78   return count;
79 }
80
81 bool HasAncestor(Actor child, Actor ancestor)
82 {
83   while(child && child != ancestor)
84   {
85     child = child.GetParent();
86   }
87
88   return (child == ancestor);
89 }
90
91 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
92 static bool gTouchedOutside;
93
94 // Signal callbacks
95
96 static void OnPopupTouchedOutside()
97 {
98   gTouchedOutside = true;
99 }
100
101 static void OnPopupShowing()
102 {
103   gPopupState = Toolkit::Popup::SHOWING;
104 }
105
106 static void OnPopupShown()
107 {
108   gPopupState = Toolkit::Popup::SHOWN;
109 }
110
111 static void OnPopupHiding()
112 {
113   gPopupState = Toolkit::Popup::HIDING;
114 }
115
116 static void OnPopupHidden()
117 {
118   gPopupState = Toolkit::Popup::HIDDEN;
119 }
120
121 void ConnectStateSignals( Toolkit::Popup popup )
122 {
123   popup.ShowingSignal().Connect( &OnPopupShowing );
124   popup.ShownSignal().Connect( &OnPopupShown );
125   popup.HidingSignal().Connect( &OnPopupHiding );
126   popup.HiddenSignal().Connect( &OnPopupHidden );
127 }
128
129 void WaitAnimation( ToolkitTestApplication& application )
130 {
131   // Wait for a while (allow animation to complete), and then check state.
132   for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
133   {
134     application.SendNotification();
135     application.Render( RENDER_FRAME_INTERVAL );
136   }
137 }
138
139 } // Anonymous namespace
140
141 /*
142  * This test checks popup creation.
143  */
144 int UtcDaliPopupNewP( void )
145 {
146   ToolkitTestApplication application;
147   tet_infoline( " UtcDaliPopupNewP" );
148
149   // Create the Popup actor.
150   Popup popup;
151
152   DALI_TEST_CHECK( !popup );
153
154   popup = Popup::New();
155
156   DALI_TEST_CHECK( popup );
157
158   Popup popup2( popup );
159
160   DALI_TEST_CHECK( popup2 == popup );
161
162   // Additional check to ensure object is created by checking if it's registered.
163   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
164   DALI_TEST_CHECK( registry );
165
166   gObjectCreatedCallBackCalled = false;
167   registry.ObjectCreatedSignal().Connect( &TestCallback );
168   {
169     Popup popup = Popup::New();
170   }
171   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
172   END_TEST;
173 }
174
175 /*
176  * This test checks popup destruction.
177  */
178 int UtcDaliPopupDestructorP( void )
179 {
180   ToolkitTestApplication application;
181   tet_infoline( " UtcDaliPopupDestructorP" );
182
183   Popup* popup = new Popup();
184   delete popup;
185
186   DALI_TEST_CHECK( true );
187   END_TEST;
188 }
189
190 int UtcDaliPopupDownCastP(void)
191 {
192   ToolkitTestApplication application;
193   tet_infoline( " UtcDaliPopupDownCastP" );
194
195   Handle handle = Popup::New();
196
197   Popup popup = Popup::DownCast( handle );
198
199   DALI_TEST_CHECK( popup == handle );
200   END_TEST;
201 }
202
203 int UtcDaliPopupSetPropertyP(void)
204 {
205   ToolkitTestApplication application;
206   tet_infoline( " UtcDaliPopupSetProperty" );
207
208   Popup popup = Popup::New();
209
210   //Test properties
211   std::string testString = "Hello World";
212
213   TextLabel textActorIn = TextLabel::New( testString );
214   Property::Map map;
215   Scripting::CreatePropertyMap( textActorIn, map );
216   popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
217   TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
218   std::string resultText;
219   DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
220   DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
221
222   END_TEST;
223 }
224
225 int UtcDaliPopupSetTitleP(void)
226 {
227   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
228   tet_infoline( " UtcDaliPopupSetTitleP" );
229
230   // Create the Popup actor
231   Popup popup = Popup::New();
232
233   // Put in show state so it's layer is connected to popup (for ancestor check).
234   popup.SetDisplayState( Popup::SHOWN );
235
236   TextLabel titleActor = TextLabel::New();
237   titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
238
239   DALI_TEST_CHECK( !popup.GetTitle() );
240   popup.SetTitle( titleActor );
241   TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
242   DALI_TEST_CHECK( textActor == titleActor );
243
244   std::string resultText;
245   DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
246
247   DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
248   // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
249   DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
250
251   TextLabel titleActor2 = TextLabel::New();
252   titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
253   popup.SetTitle( titleActor2 );
254   DALI_TEST_CHECK( popup.GetTitle() != titleActor );
255   DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
256   DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
257
258   DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
259
260   // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
261   DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
262   END_TEST;
263 }
264
265 int UtcDaliPopupSetTitleN(void)
266 {
267   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
268   tet_infoline( " UtcDaliPopupSetTitleN" );
269
270   // Create the Popup actor
271   Popup popup = Popup::New();
272
273   TextLabel titleActor = TextLabel::New( "text" );
274   popup.SetTitle( titleActor );
275
276   DALI_TEST_CHECK( popup.GetTitle() );
277
278   // Set a bad title value.
279   // Confirm this has disabled the title.
280   Actor badActor;
281   popup.SetTitle( badActor );
282
283   DALI_TEST_CHECK( !popup.GetTitle() );
284
285   END_TEST;
286 }
287
288 int UtcDaliPopupSetContentP(void)
289 {
290   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
291   tet_infoline( " UtcDaliPopupSetContentP" );
292
293   // Create the Popup actor
294   Popup popup = Popup::New();
295   Stage::GetCurrent().Add( popup );
296   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
297
298   // Put in show state so it's layer is connected to popup (for ancestor check).
299   popup.SetDisplayState( Popup::SHOWN );
300
301   PushButton button = PushButton::New();
302   DALI_TEST_CHECK( !HasAncestor( button, popup ) );
303   popup.SetFooter( button );
304   // Hide and then re-show popup to cause button to be rearranged and added to popup.
305   popup.SetDisplayState( Popup::HIDDEN );
306   popup.SetDisplayState( Popup::SHOWN );
307   DALI_TEST_CHECK( HasAncestor( button, popup ) );
308   END_TEST;
309 }
310
311 int UtcDaliPopupSetContentN(void)
312 {
313   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
314   tet_infoline( " UtcDaliPopupSetContentN" );
315
316   // Create the Popup actor
317   Popup popup = Popup::New();
318
319   TextLabel content = TextLabel::New( "text" );
320   popup.SetContent( content );
321
322   DALI_TEST_CHECK( popup.GetContent() );
323
324   // Set a bad title value.
325   Actor badActor;
326   popup.SetContent( badActor );
327
328   DALI_TEST_CHECK( !popup.GetContent() );
329
330   END_TEST;
331 }
332
333 int UtcDaliPopupSetFooterP(void)
334 {
335   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
336   tet_infoline(" UtcDaliPopupSetFooterP");
337
338   // Create the Popup actor
339   Popup popup = Popup::New();
340   Stage::GetCurrent().Add( popup );
341   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
342   // Put in show state so it's layer is connected to popup (for ancestor check).
343   popup.SetDisplayState( Popup::SHOWN );
344
345   PushButton button = PushButton::New();
346   DALI_TEST_CHECK( !HasAncestor(button, popup) );
347   popup.SetFooter( button );
348   // Hide and then re-show popup to cause button to be rearranged and added to popup.
349   popup.SetDisplayState( Popup::HIDDEN );
350   popup.SetDisplayState( Popup::SHOWN );
351   DALI_TEST_CHECK( HasAncestor( button, popup ) );
352   END_TEST;
353 }
354
355 int UtcDaliPopupSetFooterN(void)
356 {
357   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
358   tet_infoline(" UtcDaliPopupSetFooterN");
359
360   // Create the Popup actor
361   Popup popup = Popup::New();
362
363   PushButton button = PushButton::New();
364   popup.SetFooter( button );
365
366   DALI_TEST_CHECK( popup.GetFooter() );
367
368   // Set a bad title value.
369   Actor badActor;
370   popup.SetFooter( badActor );
371
372   DALI_TEST_CHECK( !popup.GetFooter() );
373
374   END_TEST;
375 }
376
377 int UtcDaliPopupSetControlFooterMultiple(void)
378 {
379   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
380   tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
381
382   // Create the Popup actor
383   Popup popup = Popup::New();
384   Stage::GetCurrent().Add( popup );
385   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
386   // Put in show state so it's layer is connected to popup (for ancestor check).
387   popup.SetDisplayState( Popup::SHOWN );
388
389   Actor container = Actor::New();
390   PushButton button1 = PushButton::New();
391   PushButton button2 = PushButton::New();
392   DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
393   DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
394   container.Add( button1 );
395   container.Add( button2 );
396   popup.SetFooter( container );
397
398   // Hide and then re-show popup to cause button to be rearranged and added to popup.
399   popup.SetDisplayState( Popup::HIDDEN );
400   popup.SetDisplayState( Popup::SHOWN );
401   DALI_TEST_CHECK( HasAncestor( button1, popup ) );
402   DALI_TEST_CHECK( HasAncestor( button2, popup ) );
403   END_TEST;
404 }
405
406 int UtcDaliPopupSetStateP(void)
407 {
408   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
409   tet_infoline(" UtcDaliPopupSetStateP");
410
411   // Create the Popup actor
412   Popup popup = Popup::New();
413
414   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
415
416   DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
417
418   popup.SetDisplayState( Popup::SHOWN );
419   DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
420
421   popup.SetDisplayState( Popup::HIDDEN );
422   DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
423   END_TEST;
424 }
425
426 int UtcDaliPopupSetStateN(void)
427 {
428   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
429   tet_infoline(" UtcDaliPopupSetStateN");
430
431   // Create the Popup actor
432   Popup popup = Popup::New();
433
434   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
435
436   DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
437
438   popup.SetDisplayState( Popup::SHOWN );
439   DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
440
441   // Test cancelling a show before it has finished.
442   popup.SetDisplayState( Popup::HIDDEN );
443   DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
444   END_TEST;
445 }
446
447 int UtcDaliPopupDisplayStateSignal(void)
448 {
449   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
450   tet_infoline( " UtcDaliPopupDisplayStateSignal" );
451
452   // Create the Popup actor
453   Popup popup = Popup::New();
454   ConnectStateSignals( popup );
455
456   popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
457   popup.SetDisplayState( Popup::SHOWN );
458   DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
459   DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
460
461   // Wait for a while (allow animation to complete), and then check state.
462   for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
463   {
464     application.SendNotification();
465     application.Render( RENDER_FRAME_INTERVAL );
466   }
467
468   DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
469   DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
470
471   // Hide slowly
472   popup.SetDisplayState( Popup::HIDDEN );
473   DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
474   DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
475
476   // Wait for a while (allow animation to complete), and then check state.
477   for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
478   {
479     application.SendNotification();
480     application.Render( RENDER_FRAME_INTERVAL );
481   }
482
483   DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
484   DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
485
486   END_TEST;
487 }
488
489 int UtcDaliPopupShowHide(void)
490 {
491   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
492   tet_infoline(" UtcDaliPopupShowHide");
493
494   // Create the Popup actor
495   Popup popup = Popup::New();
496   ConnectStateSignals( popup );
497
498   Actor container = Actor::New();
499   PushButton button1 = PushButton::New();
500   PushButton button2 = PushButton::New();
501   button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
502   button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
503   container.Add( button1 );
504   container.Add( button2 );
505   popup.SetFooter( container );
506
507   // Show
508   // Note: in most popup animation implementations show would result in
509   // popup being onstage immediately following Show(). However we can't
510   // assume for all. e.g. If one creates a animation with a delay.
511   popup.SetDisplayState( Popup::SHOWN );
512
513   // Wait for a while (allow animation to complete), and then check state.
514   for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
515   {
516     application.SendNotification();
517     application.Render( RENDER_FRAME_INTERVAL );
518   }
519
520   // Hide
521   popup.SetDisplayState( Popup::HIDDEN );
522
523   // Wait for a while (allow animation to complete), and then check state.
524   for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
525   {
526     application.SendNotification();
527     application.Render(RENDER_FRAME_INTERVAL);
528   }
529
530   DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
531   END_TEST;
532 }
533
534 int UtcDaliPopupPropertyTailVisibility(void)
535 {
536   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
537   tet_infoline(" UtcDaliPopupShowHideTail");
538
539   // Create the Popup actor
540   Popup popup = Popup::New();
541   Stage::GetCurrent().Add( popup );
542
543   popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
544   popup.SetDisplayState( Popup::SHOWN );
545
546   int withoutTailCount = DescendentCount( popup );
547
548   popup.SetDisplayState( Popup::HIDDEN );
549
550   popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
551   popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
552   popup.SetDisplayState( Popup::SHOWN );
553
554   int withTailCount = DescendentCount( popup );
555
556   // There should be more actors if the Tail has been added.
557   DALI_TEST_CHECK( withTailCount > withoutTailCount );
558
559   // Hide again
560   popup.SetDisplayState( Popup::HIDDEN );
561   popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
562   popup.SetDisplayState( Popup::SHOWN );
563   int withoutTailCount2 = DescendentCount(popup);
564
565   DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
566   END_TEST;
567 }
568
569 int UtcDaliPopupOnTouchedOutsideSignal(void)
570 {
571   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
572   tet_infoline(" UtcDaliPopupOnTouchedOutside");
573
574   // Create the Popup actor
575   Popup popup = Popup::New();
576   popup.SetParentOrigin( ParentOrigin::CENTER );
577   popup.SetAnchorPoint( ParentOrigin::CENTER );
578   popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
579   popup.SetSize( 50.0f, 50.0f );
580   popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
581   Stage::GetCurrent().Add( popup );
582   popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
583   popup.SetDisplayState( Popup::SHOWN );
584
585   application.SendNotification();
586   application.Render();
587
588   gTouchedOutside = false;
589   Dali::Integration::TouchEvent event;
590
591   event = Dali::Integration::TouchEvent();
592   event.AddPoint( pointDownOutside );
593   application.ProcessEvent( event );
594
595   application.SendNotification();
596   application.Render();
597
598   event = Dali::Integration::TouchEvent();
599   event.AddPoint( pointUpOutside );
600   application.ProcessEvent( event );
601
602   application.SendNotification();
603   application.Render();
604
605   DALI_TEST_CHECK( gTouchedOutside );
606   END_TEST;
607 }
608
609 int UtcDaliPopupPropertyAutoHide(void)
610 {
611   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
612   tet_infoline( " UtcDaliPopupPropertyAutoHide" );
613
614   // Create the Popup actor
615   Popup popup = Popup::New();
616   ConnectStateSignals( popup );
617
618   Actor container = Actor::New();
619   PushButton button1 = PushButton::New();
620   button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
621   container.Add( button1 );
622   popup.SetFooter( container );
623
624   popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
625   popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
626
627   Stage::GetCurrent().Add( popup );
628
629   DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
630
631   // Show
632   // Note: in most popup animation implementations show would result in
633   // popup being onstage immediately following Show(). However we can't
634   // assume for all. e.g. If one creates a animation with a delay.
635   popup.SetDisplayState( Popup::SHOWN );
636
637   DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
638
639   for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
640   {
641     application.SendNotification();
642     application.Render( RENDER_FRAME_INTERVAL );
643   }
644
645   // Force the timer used by the popup to expire,
646   // this will cause the popup to hide automatically.
647   Dali::Timer timer = Timer::New( 0 );
648   timer.MockEmitSignal();
649
650   DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
651
652   END_TEST;
653 }
654
655 /*
656  * This test checks all animation modes to confirm they all trigger all display states at the expected times.
657  */
658 int UtcDaliPopupPropertyAnimationMode(void)
659 {
660   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
661   tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
662
663   // Create the Popup actor
664   Popup popup = Popup::New();
665   ConnectStateSignals( popup );
666   popup.SetTitle( TextLabel::New( "Title" ) );
667   Stage::GetCurrent().Add( popup );
668
669   std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
670
671   // Try both default and zero animation duration, as zero has a special case for some animation types.
672   for( int j = 0; j <= 1; j++ )
673   {
674     // On the second loop, set duration to zero.
675     if( j == 1 )
676     {
677       popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
678     }
679
680     // Loop through 4 animation modes.
681     for( int i = 0; i < 4; i++ )
682     {
683       popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
684
685       std::string checkMode;
686       DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
687
688       DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
689
690       popup.SetDisplayState( Popup::SHOWN );
691
692       // Only wait for animation if it isn't instant.
693       if( j == 0 )
694       {
695         DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
696         WaitAnimation( application );
697       }
698
699       DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
700       popup.SetDisplayState( Popup::HIDDEN );
701
702       if( j == 0 )
703       {
704         DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
705         WaitAnimation( application );
706       }
707
708       DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
709     }
710   }
711
712   END_TEST;
713 }
714