2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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"
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/devel-api/scripting/scripting.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/popup/popup.h>
33 using namespace Toolkit;
35 void utc_dali_toolkit_popup_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_popup_cleanup(void)
42 test_return_value = TET_PASS;
47 static bool gObjectCreatedCallBackCalled;
49 static void TestCallback(BaseHandle handle)
51 gObjectCreatedCallBackCalled = true;
54 const int RENDER_FRAME_INTERVAL = 10; ///< Duration of each frame in ms.
55 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation.
56 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
57 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
58 const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10.0f, 10.0f );
59 const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10.0f, 10.0f );
62 * Counts how many descendants root Actor has, including
65 * @param[in] root The root actor to count from.
66 * @return The number of descendants including root actor itself.
68 int DescendentCount( const Actor& root )
70 unsigned int numChildren = root.GetChildCount();
74 for( unsigned int i = 0; i < numChildren; ++i )
76 count += DescendentCount( root.GetChildAt( i ) );
82 bool HasAncestor( Actor child, Actor ancestor )
84 while( child && child != ancestor )
86 child = child.GetParent();
89 return ( child == ancestor );
92 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
93 static bool gTouchedOutside;
97 static void OnPopupTouchedOutside()
99 gTouchedOutside = true;
102 static void OnPopupShowing()
104 gPopupState = Toolkit::Popup::SHOWING;
107 static void OnPopupShown()
109 gPopupState = Toolkit::Popup::SHOWN;
112 static void OnPopupHiding()
114 gPopupState = Toolkit::Popup::HIDING;
117 static void OnPopupHidden()
119 gPopupState = Toolkit::Popup::HIDDEN;
122 void ConnectStateSignals( Toolkit::Popup popup )
124 popup.ShowingSignal().Connect( &OnPopupShowing );
125 popup.ShownSignal().Connect( &OnPopupShown );
126 popup.HidingSignal().Connect( &OnPopupHiding );
127 popup.HiddenSignal().Connect( &OnPopupHidden );
130 void WaitAnimation( ToolkitTestApplication& application )
132 // Wait for a while (allow animation to complete), and then check state.
133 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
135 application.SendNotification();
136 application.Render( RENDER_FRAME_INTERVAL );
141 * A connection tracker is required when connecting to a signal with a functor.
143 class TestConnectionTrackerObject : public ConnectionTracker
148 * This functor is used to test the popup's signal connection.
150 struct PopupTestFunctor
161 // Generate a KeyEvent to send to Core.
162 Integration::KeyEvent GenerateKey( const std::string& keyName,
163 const std::string& keyString,
166 unsigned long timeStamp,
167 const Integration::KeyEvent::State& keyState )
169 return Integration::KeyEvent( keyName,
177 } // Anonymous namespace
180 * This test checks popup creation.
182 int UtcDaliPopupNewP( void )
184 ToolkitTestApplication application;
185 tet_infoline( " UtcDaliPopupNewP" );
187 // Create the Popup actor.
190 DALI_TEST_CHECK( !popup );
192 popup = Popup::New();
194 DALI_TEST_CHECK( popup );
196 Popup popup2( popup );
198 DALI_TEST_CHECK( popup2 == popup );
200 // Additional check to ensure object is created by checking if it's registered.
201 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
202 DALI_TEST_CHECK( registry );
204 gObjectCreatedCallBackCalled = false;
205 registry.ObjectCreatedSignal().Connect( &TestCallback );
207 Popup popup = Popup::New();
209 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
214 * This test checks popup destruction.
216 int UtcDaliPopupDestructorP( void )
218 ToolkitTestApplication application;
219 tet_infoline( " UtcDaliPopupDestructorP" );
221 Popup* popup = new Popup();
224 DALI_TEST_CHECK( true );
228 int UtcDaliPopupDownCastP(void)
230 ToolkitTestApplication application;
231 tet_infoline( " UtcDaliPopupDownCastP" );
233 Handle handle = Popup::New();
235 Popup popup = Popup::DownCast( handle );
237 DALI_TEST_CHECK( popup == handle );
241 int UtcDaliPopupSetPropertyP(void)
243 ToolkitTestApplication application;
244 tet_infoline( " UtcDaliPopupSetProperty" );
246 Popup popup = Popup::New();
249 std::string testString = "Hello World";
251 TextLabel textActorIn = TextLabel::New( testString );
253 Scripting::CreatePropertyMap( textActorIn, map );
254 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
255 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
256 std::string resultText;
257 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
258 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
263 int UtcDaliPopupSetTitleP(void)
265 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
266 tet_infoline( " UtcDaliPopupSetTitleP" );
268 // Create the Popup actor
269 Popup popup = Popup::New();
271 // Put in show state so it's layer is connected to popup (for ancestor check).
272 popup.SetDisplayState( Popup::SHOWN );
274 TextLabel titleActor = TextLabel::New();
275 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
277 DALI_TEST_CHECK( !popup.GetTitle() );
278 popup.SetTitle( titleActor );
279 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
280 DALI_TEST_CHECK( textActor == titleActor );
282 std::string resultText;
283 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
285 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
286 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
287 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
289 TextLabel titleActor2 = TextLabel::New();
290 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
291 popup.SetTitle( titleActor2 );
292 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
293 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
294 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
296 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
298 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
299 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
303 int UtcDaliPopupSetTitleN(void)
305 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
306 tet_infoline( " UtcDaliPopupSetTitleN" );
308 // Create the Popup actor
309 Popup popup = Popup::New();
311 TextLabel titleActor = TextLabel::New( "text" );
312 popup.SetTitle( titleActor );
314 DALI_TEST_CHECK( popup.GetTitle() );
316 // Set a bad title value.
317 // Confirm this has disabled the title.
319 popup.SetTitle( badActor );
321 DALI_TEST_CHECK( !popup.GetTitle() );
326 int UtcDaliPopupSetContentP(void)
328 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
329 tet_infoline( " UtcDaliPopupSetContentP" );
331 // Create the Popup actor
332 Popup popup = Popup::New();
333 Stage::GetCurrent().Add( popup );
334 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
336 // Put in show state so it's layer is connected to popup (for ancestor check).
337 popup.SetDisplayState( Popup::SHOWN );
339 PushButton button = PushButton::New();
340 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
341 popup.SetFooter( button );
342 // Hide and then re-show popup to cause button to be rearranged and added to popup.
343 popup.SetDisplayState( Popup::HIDDEN );
344 popup.SetDisplayState( Popup::SHOWN );
345 DALI_TEST_CHECK( HasAncestor( button, popup ) );
349 int UtcDaliPopupSetContentN(void)
351 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
352 tet_infoline( " UtcDaliPopupSetContentN" );
354 // Create the Popup actor
355 Popup popup = Popup::New();
357 TextLabel content = TextLabel::New( "text" );
358 popup.SetContent( content );
360 DALI_TEST_CHECK( popup.GetContent() );
362 // Set a bad title value.
364 popup.SetContent( badActor );
366 DALI_TEST_CHECK( !popup.GetContent() );
371 int UtcDaliPopupSetFooterP(void)
373 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
374 tet_infoline(" UtcDaliPopupSetFooterP");
376 // Create the Popup actor
377 Popup popup = Popup::New();
378 Stage::GetCurrent().Add( popup );
379 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
380 // Put in show state so it's layer is connected to popup (for ancestor check).
381 popup.SetDisplayState( Popup::SHOWN );
383 PushButton button = PushButton::New();
384 DALI_TEST_CHECK( !HasAncestor(button, popup) );
385 popup.SetFooter( button );
386 // Hide and then re-show popup to cause button to be rearranged and added to popup.
387 popup.SetDisplayState( Popup::HIDDEN );
388 popup.SetDisplayState( Popup::SHOWN );
389 DALI_TEST_CHECK( HasAncestor( button, popup ) );
393 int UtcDaliPopupSetFooterN(void)
395 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
396 tet_infoline(" UtcDaliPopupSetFooterN");
398 // Create the Popup actor
399 Popup popup = Popup::New();
401 PushButton button = PushButton::New();
402 popup.SetFooter( button );
404 DALI_TEST_CHECK( popup.GetFooter() );
406 // Set a bad title value.
408 popup.SetFooter( badActor );
410 DALI_TEST_CHECK( !popup.GetFooter() );
415 int UtcDaliPopupSetControlFooterMultiple(void)
417 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
418 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
420 // Create the Popup actor
421 Popup popup = Popup::New();
422 Stage::GetCurrent().Add( popup );
423 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
424 // Put in show state so it's layer is connected to popup (for ancestor check).
425 popup.SetDisplayState( Popup::SHOWN );
427 Actor container = Actor::New();
428 PushButton button1 = PushButton::New();
429 PushButton button2 = PushButton::New();
430 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
431 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
432 container.Add( button1 );
433 container.Add( button2 );
434 popup.SetFooter( container );
436 // Hide and then re-show popup to cause button to be rearranged and added to popup.
437 popup.SetDisplayState( Popup::HIDDEN );
438 popup.SetDisplayState( Popup::SHOWN );
439 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
440 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
444 int UtcDaliPopupSetStateP(void)
446 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
447 tet_infoline(" UtcDaliPopupSetStateP");
449 // Create the Popup actor
450 Popup popup = Popup::New();
452 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
454 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
456 popup.SetDisplayState( Popup::SHOWN );
457 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
459 popup.SetDisplayState( Popup::HIDDEN );
460 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
464 int UtcDaliPopupSetStateN(void)
466 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
467 tet_infoline(" UtcDaliPopupSetStateN");
469 // Create the Popup actor
470 Popup popup = Popup::New();
472 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
474 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
476 popup.SetDisplayState( Popup::SHOWN );
477 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
479 // Test cancelling a show before it has finished.
480 popup.SetDisplayState( Popup::HIDDEN );
481 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
485 int UtcDaliPopupDisplayStateSignal(void)
487 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
488 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
490 // Create the Popup actor
491 Popup popup = Popup::New();
492 ConnectStateSignals( popup );
494 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
495 popup.SetDisplayState( Popup::SHOWN );
496 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
497 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
499 // Wait for a while (allow animation to complete), and then check state.
500 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
502 application.SendNotification();
503 application.Render( RENDER_FRAME_INTERVAL );
506 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
507 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
510 popup.SetDisplayState( Popup::HIDDEN );
511 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
512 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
514 // Wait for a while (allow animation to complete), and then check state.
515 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
517 application.SendNotification();
518 application.Render( RENDER_FRAME_INTERVAL );
521 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
522 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
527 int UtcDaliPopupShowHide(void)
529 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
530 tet_infoline(" UtcDaliPopupShowHide");
532 // Create the Popup actor
533 Popup popup = Popup::New();
534 ConnectStateSignals( popup );
536 Actor container = Actor::New();
537 PushButton button1 = PushButton::New();
538 PushButton button2 = PushButton::New();
539 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
540 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
541 container.Add( button1 );
542 container.Add( button2 );
543 popup.SetFooter( container );
546 // Note: in most popup animation implementations show would result in
547 // popup being onstage immediately following Show(). However we can't
548 // assume for all. e.g. If one creates a animation with a delay.
549 popup.SetDisplayState( Popup::SHOWN );
551 // Wait for a while (allow animation to complete), and then check state.
552 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
554 application.SendNotification();
555 application.Render( RENDER_FRAME_INTERVAL );
559 popup.SetDisplayState( Popup::HIDDEN );
561 // Wait for a while (allow animation to complete), and then check state.
562 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
564 application.SendNotification();
565 application.Render(RENDER_FRAME_INTERVAL);
568 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
572 int UtcDaliPopupPropertyTailVisibility(void)
574 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
575 tet_infoline(" UtcDaliPopupShowHideTail");
577 // Create the Popup actor
578 Popup popup = Popup::New();
579 Stage::GetCurrent().Add( popup );
581 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
582 popup.SetDisplayState( Popup::SHOWN );
584 int withoutTailCount = DescendentCount( popup );
586 popup.SetDisplayState( Popup::HIDDEN );
588 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
589 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
590 popup.SetDisplayState( Popup::SHOWN );
592 int withTailCount = DescendentCount( popup );
594 // There should be more actors if the Tail has been added.
595 DALI_TEST_CHECK( withTailCount > withoutTailCount );
598 popup.SetDisplayState( Popup::HIDDEN );
599 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
600 popup.SetDisplayState( Popup::SHOWN );
601 int withoutTailCount2 = DescendentCount(popup);
603 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
607 int UtcDaliPopupOnTouchedOutsideSignal(void)
609 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
610 tet_infoline(" UtcDaliPopupOnTouchedOutside");
612 // Create the Popup actor
613 Popup popup = Popup::New();
614 popup.SetParentOrigin( ParentOrigin::CENTER );
615 popup.SetAnchorPoint( ParentOrigin::CENTER );
616 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
617 popup.SetSize( 50.0f, 50.0f );
618 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
619 Stage::GetCurrent().Add( popup );
620 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
621 popup.SetDisplayState( Popup::SHOWN );
623 application.SendNotification();
624 application.Render();
626 gTouchedOutside = false;
627 Dali::Integration::TouchEvent event;
629 event = Dali::Integration::TouchEvent();
630 event.AddPoint( pointDownOutside );
631 application.ProcessEvent( event );
633 application.SendNotification();
634 application.Render();
636 event = Dali::Integration::TouchEvent();
637 event.AddPoint( pointUpOutside );
638 application.ProcessEvent( event );
640 application.SendNotification();
641 application.Render();
643 // Confirm the signal is ignored if touch_transparent.
644 gTouchedOutside = false;
645 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
647 event = Dali::Integration::TouchEvent();
648 event.AddPoint( pointDownOutside );
649 application.ProcessEvent( event );
651 application.SendNotification();
652 application.Render();
654 event = Dali::Integration::TouchEvent();
655 event.AddPoint( pointUpOutside );
656 application.ProcessEvent( event );
658 application.SendNotification();
659 application.Render();
661 DALI_TEST_CHECK( !gTouchedOutside );
666 int UtcDaliPopupPropertyAutoHide(void)
668 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
669 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
671 // Create the Popup actor
672 Popup popup = Popup::New();
673 ConnectStateSignals( popup );
675 Actor container = Actor::New();
676 PushButton button1 = PushButton::New();
677 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
678 container.Add( button1 );
679 popup.SetFooter( container );
681 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
682 float getAnimationDuration = 0.0f;
683 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
684 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
686 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
687 int getAutoHideDelay = 0;
688 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
689 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
691 Stage::GetCurrent().Add( popup );
693 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
696 // Note: in most popup animation implementations show would result in
697 // popup being onstage immediately following Show(). However we can't
698 // assume for all. e.g. If one creates a animation with a delay.
699 popup.SetDisplayState( Popup::SHOWN );
701 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
703 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
705 application.SendNotification();
706 application.Render( RENDER_FRAME_INTERVAL );
709 // Force the timer used by the popup to expire,
710 // this will cause the popup to hide automatically.
711 Dali::Timer timer = Timer::New( 0 );
712 timer.MockEmitSignal();
714 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
720 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
722 int UtcDaliPopupPropertyAnimationMode(void)
724 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
725 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
727 // Create the Popup actor
728 Popup popup = Popup::New();
729 ConnectStateSignals( popup );
730 popup.SetTitle( TextLabel::New( "Title" ) );
731 Stage::GetCurrent().Add( popup );
733 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
735 // Try both default and zero animation duration, as zero has a special case for some animation types.
736 for( int j = 0; j <= 1; j++ )
738 // On the second loop, set duration to zero.
741 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
744 // Loop through 4 animation modes.
745 for( int i = 0; i < 4; i++ )
747 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
749 std::string checkMode;
750 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
752 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
754 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
755 std::string resultState;
757 // Only wait for animation if it isn't instant.
760 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
761 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
762 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
763 WaitAnimation( application );
766 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
767 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
768 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
769 popup.SetDisplayState( Popup::HIDDEN );
773 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
774 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
775 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
776 WaitAnimation( application );
779 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
780 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
781 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
788 int UtcDaliPopupPropertyTitle(void)
790 ToolkitTestApplication application;
791 tet_infoline( " UtcDaliPopupPropertyTitle" );
793 // Create the Popup actor
794 Popup popup = Popup::New();
796 std::string testLabelText = "TitleTest";
797 TextLabel titleLabel = TextLabel::New();
798 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
799 Actor title = titleLabel;
801 Scripting::CreatePropertyMap( title, map );
802 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
804 Property::Map resultMap;
805 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
807 Property::Value* resultProperty = resultMap.Find( "text" );
808 DALI_TEST_CHECK( resultProperty );
810 std::string resultText;
811 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
813 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
818 int UtcDaliPopupPropertyContent(void)
820 ToolkitTestApplication application;
821 tet_infoline( " UtcDaliPopupPropertyContent" );
823 // Create the Popup actor
824 Popup popup = Popup::New();
826 std::string testLabelText = "ContentTest";
827 TextLabel contentLabel = TextLabel::New();
828 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
829 Actor content = contentLabel;
831 Scripting::CreatePropertyMap( content, map );
832 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
834 Property::Map resultMap;
835 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
837 Property::Value* resultProperty = resultMap.Find( "text" );
838 DALI_TEST_CHECK( resultProperty );
840 std::string resultText;
841 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
843 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
848 int UtcDaliPopupPropertyFooter(void)
850 ToolkitTestApplication application;
851 tet_infoline( " UtcDaliPopupPropertyFooter" );
853 // Create the Popup actor
854 Popup popup = Popup::New();
856 std::string testLabelText = "FooterTest";
857 TextLabel footerLabel = TextLabel::New();
858 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
859 Actor footer = footerLabel;
861 Scripting::CreatePropertyMap( footer, map );
862 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
864 Property::Map resultMap;
865 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
867 Property::Value* resultProperty = resultMap.Find( "text" );
868 DALI_TEST_CHECK( resultProperty );
870 std::string resultText;
871 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
873 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
878 int UtcDaliPopupPropertyContextualMode(void)
880 ToolkitTestApplication application;
881 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
883 // Create the Popup actor
884 Popup popup = Popup::New();
885 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
886 std::string testLabelText = "ContentTest";
888 TextLabel contentLabel = TextLabel::New();
890 popup.SetContent( contentLabel );
892 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
893 Actor placement = Actor::New();
894 placement.SetParentOrigin( ParentOrigin::CENTER );
895 placement.SetAnchorPoint( AnchorPoint::CENTER );
896 placement.SetSize( 1.0f, 1.0f );
897 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
898 Stage::GetCurrent().Add( placement );
900 placement.Add( popup );
902 // Test all contextual modes.
903 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
904 Vector2 offsetValues[5];
905 offsetValues[0] = Vector2( 0.0f, 0.0f );
906 offsetValues[1] = Vector2( 0.0f, -10.0f );
907 offsetValues[2] = Vector2( 10.0f, 0.0f );
908 offsetValues[3] = Vector2( 0.0f, 10.0f );
909 offsetValues[4] = Vector2( -10.0f, 0.0f );
911 for( int i = 0; i < 5; ++i )
913 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
915 std::string propertyResult;
916 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
917 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
919 popup.SetDisplayState( Popup::SHOWN );
920 application.SendNotification();
921 application.Render();
923 // Check the position of the label within the popup.
924 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
926 popup.SetDisplayState( Popup::HIDDEN );
927 application.SendNotification();
928 application.Render();
934 int UtcDaliPopupPropertyBacking(void)
936 ToolkitTestApplication application;
937 tet_infoline( " UtcDaliPopupPropertyBacking" );
939 // Create the Popup actor
940 Popup popup = Popup::New();
941 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
942 Stage::GetCurrent().Add( popup );
944 Actor backing = popup.FindChildByName( "popupBacking" );
945 DALI_TEST_CHECK( backing );
947 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
949 // Check enabled property.
950 popup.SetDisplayState( Popup::SHOWN );
951 application.SendNotification();
952 application.Render();
954 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
956 popup.SetDisplayState( Popup::HIDDEN );
957 application.SendNotification();
958 application.Render();
960 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
962 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
964 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
965 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
967 popup.SetDisplayState( Popup::SHOWN );
968 application.SendNotification();
969 application.Render();
971 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
973 popup.SetDisplayState( Popup::HIDDEN );
974 application.SendNotification();
975 application.Render();
977 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
979 // Check color property.
980 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
981 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
983 popup.SetDisplayState( Popup::SHOWN );
984 application.SendNotification();
985 application.Render();
988 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
989 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
994 int UtcDaliPopupPropertyBackgroundImage(void)
996 ToolkitTestApplication application;
997 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
999 // Create the Popup actor
1000 Popup popup = Popup::New();
1001 Stage::GetCurrent().Add( popup );
1003 // Check setting an invalid image.
1004 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1005 std::string resultString;
1006 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1007 DALI_TEST_EQUALS( resultString, std::string(""), TEST_LOCATION );
1012 int UtcDaliPopupPropertyCustomAnimation(void)
1014 ToolkitTestApplication application;
1015 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1017 // Create the Popup actor
1018 Popup popup = Popup::New();
1019 TextLabel content = TextLabel::New( "text" );
1020 popup.SetContent( content );
1022 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1023 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1025 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1026 DALI_TEST_CHECK( popupContainer );
1028 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1029 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1031 Property::Map animationMapEntry;
1032 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1033 animationMapEntry.Insert( "property", "position" );
1034 animationMapEntry.Insert( "value", entryAnimationDestination );
1035 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1037 Property::Array timePeriodMapEntry;
1038 timePeriodMapEntry.PushBack( 0.0f );
1039 timePeriodMapEntry.PushBack( 1.0f );
1041 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1043 Property::Map animationMapExit;
1044 animationMapExit.Insert( "actor", "customAnimationPopup" );
1045 animationMapExit.Insert( "property", "position" );
1046 animationMapExit.Insert( "value", exitAnimationDestination );
1047 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1049 Property::Array timePeriodMapExit;
1050 timePeriodMapExit.PushBack( 0.0f );
1051 timePeriodMapExit.PushBack( 1.0f );
1053 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1055 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1056 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1058 Property::Map resultMap;
1059 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1060 DALI_TEST_EQUALS( resultMap.Count(), 0, TEST_LOCATION );
1061 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1062 DALI_TEST_EQUALS( resultMap.Count(), 0, TEST_LOCATION );
1064 Stage::GetCurrent().Add( popup );
1065 popup.SetDisplayState( Popup::SHOWN );
1067 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1069 application.SendNotification();
1070 application.Render( RENDER_FRAME_INTERVAL );
1073 // Test the popup has animated to it's entry-transition destination.
1074 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1076 popup.SetDisplayState( Popup::HIDDEN );
1078 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1080 application.SendNotification();
1081 application.Render( RENDER_FRAME_INTERVAL );
1084 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1089 static bool gPushButtonClicked;
1090 static bool PushButtonClicked( Button button )
1092 gPushButtonClicked = true;
1096 int UtcDaliPopupPropertyTouchTransparent(void)
1098 ToolkitTestApplication application;
1099 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1101 // Create the Popup actor
1102 Popup popup = Popup::New();
1103 TextLabel content = TextLabel::New( "text" );
1104 popup.SetContent( content );
1105 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1106 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1107 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1108 popup.SetSize( 100, 100 );
1109 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1111 // Create a button (to go underneath the popup).
1112 PushButton button = Toolkit::PushButton::New();
1113 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1114 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1115 button.SetSize( 100, 100 );
1116 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1118 button.ClickedSignal().Connect( &PushButtonClicked );
1120 Stage::GetCurrent().Add( button );
1122 button.Add( popup );
1124 popup.SetDisplayState( Popup::SHOWN );
1125 application.SendNotification();
1126 application.Render();
1128 gPushButtonClicked = false;
1129 Dali::Integration::TouchEvent event;
1130 const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
1131 const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
1133 // Perform a click, the popup should block the click from hitting the button.
1134 event = Dali::Integration::TouchEvent();
1135 event.AddPoint( pointDown );
1136 application.ProcessEvent( event );
1137 application.SendNotification();
1138 application.Render();
1140 event = Dali::Integration::TouchEvent();
1141 event.AddPoint( pointUp );
1142 application.ProcessEvent( event );
1143 application.SendNotification();
1144 application.Render();
1146 DALI_TEST_CHECK( !gPushButtonClicked );
1148 // Enable touch transparency.
1149 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1150 bool propertyResult;
1151 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1152 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1154 // Perform a click, the popup should allow the click to travel through to the button.
1155 event = Dali::Integration::TouchEvent();
1156 event.AddPoint( pointDown );
1157 application.ProcessEvent( event );
1158 application.SendNotification();
1159 application.Render();
1161 event = Dali::Integration::TouchEvent();
1162 event.AddPoint( pointUp );
1163 application.ProcessEvent( event );
1164 application.SendNotification();
1165 application.Render();
1167 DALI_TEST_CHECK( gPushButtonClicked );
1172 int UtcDaliPopupPropertyTail(void)
1174 ToolkitTestApplication application;
1175 tet_infoline( " UtcDaliPopupPropertyTail" );
1177 // Create the Popup actor
1178 Popup popup = Popup::New();
1179 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1180 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1181 popup.SetSize( 100, 100 );
1182 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1183 TextLabel content = TextLabel::New( "text" );
1184 popup.SetContent( content );
1186 std::string imageFilename = "invalid-image.jpg";
1187 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1188 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1189 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1190 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1192 std::string resultString;
1193 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1194 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1195 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1196 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1197 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1198 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1199 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1200 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1202 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1204 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1205 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1208 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1210 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1211 Vector3 vectorResult;
1212 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1213 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1215 Stage::GetCurrent().Add( popup );
1217 popup.SetDisplayState( Popup::SHOWN );
1218 application.SendNotification();
1219 application.Render();
1220 tailActor = popup.FindChildByName( "tailImage" );
1221 DALI_TEST_CHECK( tailActor );
1223 float baseValX = tailActor.GetCurrentWorldPosition().x;
1225 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1227 popup.SetDisplayState( Popup::HIDDEN );
1228 application.SendNotification();
1229 application.Render();
1231 tailPosition = ParentOrigin::CENTER_LEFT;
1232 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1234 popup.SetDisplayState( Popup::SHOWN );
1235 application.SendNotification();
1236 application.Render();
1237 tailActor = popup.FindChildByName( "tailImage" );
1238 DALI_TEST_CHECK( tailActor );
1240 float baseValY = tailActor.GetCurrentWorldPosition().y;
1241 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1243 popup.SetDisplayState( Popup::HIDDEN );
1244 application.SendNotification();
1245 application.Render();
1247 tailPosition = ParentOrigin::BOTTOM_CENTER;
1248 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1250 popup.SetDisplayState( Popup::SHOWN );
1251 application.SendNotification();
1252 application.Render();
1253 tailActor = popup.FindChildByName( "tailImage" );
1254 DALI_TEST_CHECK( tailActor );
1255 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1256 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1258 popup.SetDisplayState( Popup::HIDDEN );
1259 application.SendNotification();
1260 application.Render();
1262 tailPosition = ParentOrigin::CENTER_RIGHT;
1263 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1265 popup.SetDisplayState( Popup::SHOWN );
1266 application.SendNotification();
1267 application.Render();
1268 tailActor = popup.FindChildByName( "tailImage" );
1269 DALI_TEST_CHECK( tailActor );
1270 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1271 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1273 popup.SetDisplayState( Popup::HIDDEN );
1274 application.SendNotification();
1275 application.Render();
1280 int UtcDaliPopupTypeToast(void)
1282 ToolkitTestApplication application;
1283 tet_infoline( " UtcDaliPopupTypeToast" );
1285 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1286 DALI_TEST_CHECK( typeInfo )
1288 BaseHandle baseHandle = typeInfo.CreateInstance();
1289 DALI_TEST_CHECK( baseHandle )
1291 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1292 gPopupState = Toolkit::Popup::HIDDEN;
1293 ConnectStateSignals( popup );
1294 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1296 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1297 Stage::GetCurrent().Add( popup );
1298 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1300 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1302 application.SendNotification();
1303 application.Render( RENDER_FRAME_INTERVAL );
1306 // Check the toast popup is shown.
1307 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1309 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1311 application.SendNotification();
1312 application.Render( RENDER_FRAME_INTERVAL );
1315 // Check the toast popup hides.
1316 Dali::Timer timer = Timer::New( 0 );
1317 timer.MockEmitSignal();
1319 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1321 application.SendNotification();
1322 application.Render( RENDER_FRAME_INTERVAL );
1325 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1330 int UtcDaliPopupTypeRegistryCreation(void)
1332 ToolkitTestApplication application;
1333 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1335 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1336 DALI_TEST_CHECK( typeInfo )
1338 BaseHandle baseHandle = typeInfo.CreateInstance();
1339 DALI_TEST_CHECK( baseHandle )
1341 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1342 gPopupState = Toolkit::Popup::HIDDEN;
1343 ConnectStateSignals( popup );
1344 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1346 Stage::GetCurrent().Add( popup );
1347 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1349 application.SendNotification();
1350 application.Render();
1352 // Check the popup is shown.
1353 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1358 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1360 ToolkitTestApplication application;
1361 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1363 // Create the Popup actor
1364 Popup popup = Popup::New();
1366 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1367 // Note: The emmision of this signals has already been tested in other tests.
1368 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1369 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1370 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1371 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1372 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1374 // Test connecting to an invalid signal does not work.
1375 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1380 int UtcDaliPopupOnControlChildAdd(void)
1382 ToolkitTestApplication application;
1383 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1385 // Create the Popup actor
1386 Popup popup = Popup::New();
1387 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1388 std::string testLabelText = "ContentTest";
1389 TextLabel contentLabel = TextLabel::New( testLabelText );
1391 popup.Add( contentLabel );
1393 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1398 int UtcDaliPopupOnKeyEvent(void)
1400 ToolkitTestApplication application;
1401 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1403 // Create the Popup actor
1404 Popup popup = Popup::New();
1405 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1406 Stage::GetCurrent().Add( popup );
1408 popup.SetDisplayState( Popup::SHOWN );
1409 application.SendNotification();
1410 application.Render();
1412 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1414 popup.SetKeyInputFocus();
1416 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down ) );
1417 application.SendNotification();
1418 application.Render();
1420 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );