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);
59 Dali::Integration::Point GetPointDown()
61 Dali::Integration::Point point;
62 point.SetState( PointState::DOWN );
63 point.SetScreenPosition( Vector2( 10, 10 ) );
67 Dali::Integration::Point GetPointUp()
69 Dali::Integration::Point point;
70 point.SetState( PointState::UP );
71 point.SetScreenPosition( Vector2( 10, 10 ) );
76 * Counts how many descendants root Actor has, including
79 * @param[in] root The root actor to count from.
80 * @return The number of descendants including root actor itself.
82 int DescendentCount( const Actor& root )
84 unsigned int numChildren = root.GetChildCount();
88 for( unsigned int i = 0; i < numChildren; ++i )
90 count += DescendentCount( root.GetChildAt( i ) );
96 bool HasAncestor( Actor child, Actor ancestor )
98 while( child && child != ancestor )
100 child = child.GetParent();
103 return ( child == ancestor );
106 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
107 static bool gTouchedOutside;
111 static void OnPopupTouchedOutside()
113 gTouchedOutside = true;
116 static void OnPopupShowing()
118 gPopupState = Toolkit::Popup::SHOWING;
121 static void OnPopupShown()
123 gPopupState = Toolkit::Popup::SHOWN;
126 static void OnPopupHiding()
128 gPopupState = Toolkit::Popup::HIDING;
131 static void OnPopupHidden()
133 gPopupState = Toolkit::Popup::HIDDEN;
136 void ConnectStateSignals( Toolkit::Popup popup )
138 popup.ShowingSignal().Connect( &OnPopupShowing );
139 popup.ShownSignal().Connect( &OnPopupShown );
140 popup.HidingSignal().Connect( &OnPopupHiding );
141 popup.HiddenSignal().Connect( &OnPopupHidden );
144 void WaitAnimation( ToolkitTestApplication& application )
146 // Wait for a while (allow animation to complete), and then check state.
147 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
149 application.SendNotification();
150 application.Render( RENDER_FRAME_INTERVAL );
155 * A connection tracker is required when connecting to a signal with a functor.
157 class TestConnectionTrackerObject : public ConnectionTracker
162 * This functor is used to test the popup's signal connection.
164 struct PopupTestFunctor
175 // Generate a KeyEvent to send to Core.
176 Integration::KeyEvent GenerateKey( const std::string& keyName,
177 const std::string& keyString,
180 unsigned long timeStamp,
181 const Integration::KeyEvent::State& keyState )
183 return Integration::KeyEvent( keyName,
191 } // Anonymous namespace
194 * This test checks popup creation.
196 int UtcDaliPopupNewP( void )
198 ToolkitTestApplication application;
199 tet_infoline( " UtcDaliPopupNewP" );
201 // Create the Popup actor.
204 DALI_TEST_CHECK( !popup );
206 popup = Popup::New();
208 DALI_TEST_CHECK( popup );
210 Popup popup2( popup );
212 DALI_TEST_CHECK( popup2 == popup );
214 // Additional check to ensure object is created by checking if it's registered.
215 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
216 DALI_TEST_CHECK( registry );
218 gObjectCreatedCallBackCalled = false;
219 registry.ObjectCreatedSignal().Connect( &TestCallback );
221 Popup popup = Popup::New();
223 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
228 * This test checks popup destruction.
230 int UtcDaliPopupDestructorP( void )
232 ToolkitTestApplication application;
233 tet_infoline( " UtcDaliPopupDestructorP" );
235 Popup* popup = new Popup();
238 DALI_TEST_CHECK( true );
242 int UtcDaliPopupDownCastP(void)
244 ToolkitTestApplication application;
245 tet_infoline( " UtcDaliPopupDownCastP" );
247 Handle handle = Popup::New();
249 Popup popup = Popup::DownCast( handle );
251 DALI_TEST_CHECK( popup == handle );
255 int UtcDaliPopupSetPropertyP(void)
257 ToolkitTestApplication application;
258 tet_infoline( " UtcDaliPopupSetProperty" );
260 Popup popup = Popup::New();
263 std::string testString = "Hello World";
265 TextLabel textActorIn = TextLabel::New( testString );
267 Scripting::CreatePropertyMap( textActorIn, map );
268 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
269 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
270 std::string resultText;
271 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
272 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
277 int UtcDaliPopupSetTitleP(void)
279 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
280 tet_infoline( " UtcDaliPopupSetTitleP" );
282 // Create the Popup actor
283 Popup popup = Popup::New();
285 // Put in show state so it's layer is connected to popup (for ancestor check).
286 popup.SetDisplayState( Popup::SHOWN );
288 TextLabel titleActor = TextLabel::New();
289 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
291 DALI_TEST_CHECK( !popup.GetTitle() );
292 popup.SetTitle( titleActor );
293 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
294 DALI_TEST_CHECK( textActor == titleActor );
296 std::string resultText;
297 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
299 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
300 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
301 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
303 TextLabel titleActor2 = TextLabel::New();
304 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
305 popup.SetTitle( titleActor2 );
306 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
307 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
308 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
310 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
312 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
313 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
317 int UtcDaliPopupSetTitleN(void)
319 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
320 tet_infoline( " UtcDaliPopupSetTitleN" );
322 // Create the Popup actor
323 Popup popup = Popup::New();
325 TextLabel titleActor = TextLabel::New( "text" );
326 popup.SetTitle( titleActor );
328 DALI_TEST_CHECK( popup.GetTitle() );
330 // Set a bad title value.
331 // Confirm this has disabled the title.
333 popup.SetTitle( badActor );
335 DALI_TEST_CHECK( !popup.GetTitle() );
340 int UtcDaliPopupSetContentP(void)
342 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
343 tet_infoline( " UtcDaliPopupSetContentP" );
345 // Create the Popup actor
346 Popup popup = Popup::New();
347 Stage::GetCurrent().Add( popup );
348 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
350 // Put in show state so it's layer is connected to popup (for ancestor check).
351 popup.SetDisplayState( Popup::SHOWN );
353 PushButton button = PushButton::New();
354 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
355 popup.SetFooter( button );
356 // Hide and then re-show popup to cause button to be rearranged and added to popup.
357 popup.SetDisplayState( Popup::HIDDEN );
358 popup.SetDisplayState( Popup::SHOWN );
359 DALI_TEST_CHECK( HasAncestor( button, popup ) );
363 int UtcDaliPopupSetContentN(void)
365 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
366 tet_infoline( " UtcDaliPopupSetContentN" );
368 // Create the Popup actor
369 Popup popup = Popup::New();
371 TextLabel content = TextLabel::New( "text" );
372 popup.SetContent( content );
374 DALI_TEST_CHECK( popup.GetContent() );
376 // Set a bad title value.
378 popup.SetContent( badActor );
380 DALI_TEST_CHECK( !popup.GetContent() );
385 int UtcDaliPopupSetFooterP(void)
387 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
388 tet_infoline(" UtcDaliPopupSetFooterP");
390 // Create the Popup actor
391 Popup popup = Popup::New();
392 Stage::GetCurrent().Add( popup );
393 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
394 // Put in show state so it's layer is connected to popup (for ancestor check).
395 popup.SetDisplayState( Popup::SHOWN );
397 PushButton button = PushButton::New();
398 DALI_TEST_CHECK( !HasAncestor(button, popup) );
399 popup.SetFooter( button );
400 // Hide and then re-show popup to cause button to be rearranged and added to popup.
401 popup.SetDisplayState( Popup::HIDDEN );
402 popup.SetDisplayState( Popup::SHOWN );
403 DALI_TEST_CHECK( HasAncestor( button, popup ) );
407 int UtcDaliPopupSetFooterN(void)
409 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
410 tet_infoline(" UtcDaliPopupSetFooterN");
412 // Create the Popup actor
413 Popup popup = Popup::New();
415 PushButton button = PushButton::New();
416 popup.SetFooter( button );
418 DALI_TEST_CHECK( popup.GetFooter() );
420 // Set a bad title value.
422 popup.SetFooter( badActor );
424 DALI_TEST_CHECK( !popup.GetFooter() );
429 int UtcDaliPopupSetControlFooterMultiple(void)
431 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
432 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
434 // Create the Popup actor
435 Popup popup = Popup::New();
436 Stage::GetCurrent().Add( popup );
437 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
438 // Put in show state so it's layer is connected to popup (for ancestor check).
439 popup.SetDisplayState( Popup::SHOWN );
441 Actor container = Actor::New();
442 PushButton button1 = PushButton::New();
443 PushButton button2 = PushButton::New();
444 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
445 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
446 container.Add( button1 );
447 container.Add( button2 );
448 popup.SetFooter( container );
450 // Hide and then re-show popup to cause button to be rearranged and added to popup.
451 popup.SetDisplayState( Popup::HIDDEN );
452 popup.SetDisplayState( Popup::SHOWN );
453 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
454 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
458 int UtcDaliPopupSetStateP(void)
460 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
461 tet_infoline(" UtcDaliPopupSetStateP");
463 // Create the Popup actor
464 Popup popup = Popup::New();
466 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
468 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
470 popup.SetDisplayState( Popup::SHOWN );
471 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
473 popup.SetDisplayState( Popup::HIDDEN );
474 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
478 int UtcDaliPopupSetStateN(void)
480 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
481 tet_infoline(" UtcDaliPopupSetStateN");
483 // Create the Popup actor
484 Popup popup = Popup::New();
486 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
488 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
490 popup.SetDisplayState( Popup::SHOWN );
491 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
493 // Test cancelling a show before it has finished.
494 popup.SetDisplayState( Popup::HIDDEN );
495 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
499 int UtcDaliPopupDisplayStateSignal(void)
501 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
502 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
504 // Create the Popup actor
505 Popup popup = Popup::New();
506 ConnectStateSignals( popup );
508 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
509 popup.SetDisplayState( Popup::SHOWN );
510 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
511 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
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++)
516 application.SendNotification();
517 application.Render( RENDER_FRAME_INTERVAL );
520 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
521 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
524 popup.SetDisplayState( Popup::HIDDEN );
525 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
526 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
528 // Wait for a while (allow animation to complete), and then check state.
529 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
531 application.SendNotification();
532 application.Render( RENDER_FRAME_INTERVAL );
535 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
536 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
541 int UtcDaliPopupShowHide(void)
543 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
544 tet_infoline(" UtcDaliPopupShowHide");
546 // Create the Popup actor
547 Popup popup = Popup::New();
548 ConnectStateSignals( popup );
550 Actor container = Actor::New();
551 PushButton button1 = PushButton::New();
552 PushButton button2 = PushButton::New();
553 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
554 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
555 container.Add( button1 );
556 container.Add( button2 );
557 popup.SetFooter( container );
560 // Note: in most popup animation implementations show would result in
561 // popup being onstage immediately following Show(). However we can't
562 // assume for all. e.g. If one creates a animation with a delay.
563 popup.SetDisplayState( Popup::SHOWN );
565 // Wait for a while (allow animation to complete), and then check state.
566 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
568 application.SendNotification();
569 application.Render( RENDER_FRAME_INTERVAL );
573 popup.SetDisplayState( Popup::HIDDEN );
575 // Wait for a while (allow animation to complete), and then check state.
576 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
578 application.SendNotification();
579 application.Render(RENDER_FRAME_INTERVAL);
582 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
586 int UtcDaliPopupPropertyTailVisibility(void)
588 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
589 tet_infoline(" UtcDaliPopupShowHideTail");
591 // Create the Popup actor
592 Popup popup = Popup::New();
593 Stage::GetCurrent().Add( popup );
595 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
596 popup.SetDisplayState( Popup::SHOWN );
598 int withoutTailCount = DescendentCount( popup );
600 popup.SetDisplayState( Popup::HIDDEN );
602 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
603 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
604 popup.SetDisplayState( Popup::SHOWN );
606 int withTailCount = DescendentCount( popup );
608 // There should be more actors if the Tail has been added.
609 DALI_TEST_CHECK( withTailCount > withoutTailCount );
612 popup.SetDisplayState( Popup::HIDDEN );
613 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
614 popup.SetDisplayState( Popup::SHOWN );
615 int withoutTailCount2 = DescendentCount(popup);
617 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
621 int UtcDaliPopupOnTouchedOutsideSignal(void)
623 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
624 tet_infoline(" UtcDaliPopupOnTouchedOutside");
626 // Create the Popup actor
627 Popup popup = Popup::New();
628 popup.SetParentOrigin( ParentOrigin::CENTER );
629 popup.SetAnchorPoint( ParentOrigin::CENTER );
630 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
631 popup.SetSize( 50.0f, 50.0f );
632 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
633 Stage::GetCurrent().Add( popup );
634 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
635 popup.SetDisplayState( Popup::SHOWN );
637 application.SendNotification();
638 application.Render();
640 gTouchedOutside = false;
641 Dali::Integration::TouchEvent event;
643 event = Dali::Integration::TouchEvent();
644 event.AddPoint( GetPointDown() );
645 application.ProcessEvent( event );
647 application.SendNotification();
648 application.Render();
650 event = Dali::Integration::TouchEvent();
651 event.AddPoint( GetPointUp() );
652 application.ProcessEvent( event );
654 application.SendNotification();
655 application.Render();
657 // Confirm the signal is ignored if touch_transparent.
658 gTouchedOutside = false;
659 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
661 event = Dali::Integration::TouchEvent();
662 event.AddPoint( GetPointDown() );
663 application.ProcessEvent( event );
665 application.SendNotification();
666 application.Render();
668 event = Dali::Integration::TouchEvent();
669 event.AddPoint( GetPointUp() );
670 application.ProcessEvent( event );
672 application.SendNotification();
673 application.Render();
675 DALI_TEST_CHECK( !gTouchedOutside );
680 int UtcDaliPopupPropertyAutoHide(void)
682 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
683 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
685 // Create the Popup actor
686 Popup popup = Popup::New();
687 ConnectStateSignals( popup );
689 Actor container = Actor::New();
690 PushButton button1 = PushButton::New();
691 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
692 container.Add( button1 );
693 popup.SetFooter( container );
695 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
696 float getAnimationDuration = 0.0f;
697 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
698 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
700 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
701 int getAutoHideDelay = 0;
702 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
703 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
705 Stage::GetCurrent().Add( popup );
707 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
710 // Note: in most popup animation implementations show would result in
711 // popup being onstage immediately following Show(). However we can't
712 // assume for all. e.g. If one creates a animation with a delay.
713 popup.SetDisplayState( Popup::SHOWN );
715 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
717 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
719 application.SendNotification();
720 application.Render( RENDER_FRAME_INTERVAL );
723 // Force the timer used by the popup to expire,
724 // this will cause the popup to hide automatically.
725 Dali::Timer timer = Timer::New( 0 );
726 timer.MockEmitSignal();
728 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
734 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
736 int UtcDaliPopupPropertyAnimationMode(void)
738 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
739 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
741 // Create the Popup actor
742 Popup popup = Popup::New();
743 ConnectStateSignals( popup );
744 popup.SetTitle( TextLabel::New( "Title" ) );
745 Stage::GetCurrent().Add( popup );
747 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
749 // Try both default and zero animation duration, as zero has a special case for some animation types.
750 for( int j = 0; j <= 1; j++ )
752 // On the second loop, set duration to zero.
755 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
758 // Loop through 4 animation modes.
759 for( int i = 0; i < 4; i++ )
761 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
763 std::string checkMode;
764 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
766 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
768 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
769 std::string resultState;
771 // Only wait for animation if it isn't instant.
774 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
775 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
776 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
777 WaitAnimation( application );
780 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
781 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
782 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
783 popup.SetDisplayState( Popup::HIDDEN );
787 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
788 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
789 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
790 WaitAnimation( application );
793 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
794 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
795 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
802 int UtcDaliPopupPropertyTitle(void)
804 ToolkitTestApplication application;
805 tet_infoline( " UtcDaliPopupPropertyTitle" );
807 // Create the Popup actor
808 Popup popup = Popup::New();
810 std::string testLabelText = "TitleTest";
811 TextLabel titleLabel = TextLabel::New();
812 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
813 Actor title = titleLabel;
815 Scripting::CreatePropertyMap( title, map );
816 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
818 Property::Map resultMap;
819 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
821 Property::Value* resultProperty = resultMap.Find( "text" );
822 DALI_TEST_CHECK( resultProperty );
824 std::string resultText;
825 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
827 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
832 int UtcDaliPopupPropertyContent(void)
834 ToolkitTestApplication application;
835 tet_infoline( " UtcDaliPopupPropertyContent" );
837 // Create the Popup actor
838 Popup popup = Popup::New();
840 std::string testLabelText = "ContentTest";
841 TextLabel contentLabel = TextLabel::New();
842 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
843 Actor content = contentLabel;
845 Scripting::CreatePropertyMap( content, map );
846 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
848 Property::Map resultMap;
849 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
851 Property::Value* resultProperty = resultMap.Find( "text" );
852 DALI_TEST_CHECK( resultProperty );
854 std::string resultText;
855 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
857 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
862 int UtcDaliPopupPropertyFooter(void)
864 ToolkitTestApplication application;
865 tet_infoline( " UtcDaliPopupPropertyFooter" );
867 // Create the Popup actor
868 Popup popup = Popup::New();
870 std::string testLabelText = "FooterTest";
871 TextLabel footerLabel = TextLabel::New();
872 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
873 Actor footer = footerLabel;
875 Scripting::CreatePropertyMap( footer, map );
876 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
878 Property::Map resultMap;
879 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
881 Property::Value* resultProperty = resultMap.Find( "text" );
882 DALI_TEST_CHECK( resultProperty );
884 std::string resultText;
885 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
887 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
892 int UtcDaliPopupPropertyContextualMode(void)
894 ToolkitTestApplication application;
895 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
897 // Create the Popup actor
898 Popup popup = Popup::New();
899 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
900 std::string testLabelText = "ContentTest";
902 TextLabel contentLabel = TextLabel::New();
904 popup.SetContent( contentLabel );
906 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
907 Actor placement = Actor::New();
908 placement.SetParentOrigin( ParentOrigin::CENTER );
909 placement.SetAnchorPoint( AnchorPoint::CENTER );
910 placement.SetSize( 1.0f, 1.0f );
911 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
912 Stage::GetCurrent().Add( placement );
914 placement.Add( popup );
916 // Test all contextual modes.
917 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
918 Vector2 offsetValues[5];
919 offsetValues[0] = Vector2( 0.0f, 0.0f );
920 offsetValues[1] = Vector2( 0.0f, -10.0f );
921 offsetValues[2] = Vector2( 10.0f, 0.0f );
922 offsetValues[3] = Vector2( 0.0f, 10.0f );
923 offsetValues[4] = Vector2( -10.0f, 0.0f );
925 for( int i = 0; i < 5; ++i )
927 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
929 std::string propertyResult;
930 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
931 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
933 popup.SetDisplayState( Popup::SHOWN );
934 application.SendNotification();
935 application.Render();
937 // Check the position of the label within the popup.
938 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
940 popup.SetDisplayState( Popup::HIDDEN );
941 application.SendNotification();
942 application.Render();
948 int UtcDaliPopupPropertyBacking(void)
950 ToolkitTestApplication application;
951 tet_infoline( " UtcDaliPopupPropertyBacking" );
953 // Create the Popup actor
954 Popup popup = Popup::New();
955 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
956 Stage::GetCurrent().Add( popup );
958 Actor backing = popup.FindChildByName( "popupBacking" );
959 DALI_TEST_CHECK( backing );
961 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
963 // Check enabled property.
964 popup.SetDisplayState( Popup::SHOWN );
965 application.SendNotification();
966 application.Render();
968 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
970 popup.SetDisplayState( Popup::HIDDEN );
971 application.SendNotification();
972 application.Render();
974 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
976 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
978 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
979 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
981 popup.SetDisplayState( Popup::SHOWN );
982 application.SendNotification();
983 application.Render();
985 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
987 popup.SetDisplayState( Popup::HIDDEN );
988 application.SendNotification();
989 application.Render();
991 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
993 // Check color property.
994 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
995 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
997 popup.SetDisplayState( Popup::SHOWN );
998 application.SendNotification();
999 application.Render();
1001 Vector4 resultColor;
1002 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1003 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1008 int UtcDaliPopupPropertyBackgroundImage(void)
1010 ToolkitTestApplication application;
1011 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1013 // Create the Popup actor
1014 Popup popup = Popup::New();
1015 Stage::GetCurrent().Add( popup );
1017 // Check setting an image
1018 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1019 std::string resultString;
1020 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1021 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1026 int UtcDaliPopupPropertyCustomAnimation(void)
1028 ToolkitTestApplication application;
1029 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1031 // Create the Popup actor
1032 Popup popup = Popup::New();
1033 TextLabel content = TextLabel::New( "text" );
1034 popup.SetContent( content );
1036 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1037 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1039 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1040 DALI_TEST_CHECK( popupContainer );
1042 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1043 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1045 Property::Map animationMapEntry;
1046 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1047 animationMapEntry.Insert( "property", "position" );
1048 animationMapEntry.Insert( "value", entryAnimationDestination );
1049 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1051 Property::Array timePeriodMapEntry;
1052 timePeriodMapEntry.PushBack( 0.0f );
1053 timePeriodMapEntry.PushBack( 1.0f );
1055 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1057 Property::Map animationMapExit;
1058 animationMapExit.Insert( "actor", "customAnimationPopup" );
1059 animationMapExit.Insert( "property", "position" );
1060 animationMapExit.Insert( "value", exitAnimationDestination );
1061 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1063 Property::Array timePeriodMapExit;
1064 timePeriodMapExit.PushBack( 0.0f );
1065 timePeriodMapExit.PushBack( 1.0f );
1067 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1069 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1070 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1072 Property::Map resultMap;
1073 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1074 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1075 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1076 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1078 Stage::GetCurrent().Add( popup );
1079 popup.SetDisplayState( Popup::SHOWN );
1081 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1083 application.SendNotification();
1084 application.Render( RENDER_FRAME_INTERVAL );
1087 // Test the popup has animated to it's entry-transition destination.
1088 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1090 popup.SetDisplayState( Popup::HIDDEN );
1092 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1094 application.SendNotification();
1095 application.Render( RENDER_FRAME_INTERVAL );
1098 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1103 static bool gPushButtonClicked;
1104 static bool PushButtonClicked( Button button )
1106 gPushButtonClicked = true;
1110 int UtcDaliPopupPropertyTouchTransparent(void)
1112 ToolkitTestApplication application;
1113 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1115 // Create the Popup actor
1116 Popup popup = Popup::New();
1117 TextLabel content = TextLabel::New( "text" );
1118 popup.SetContent( content );
1119 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1120 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1121 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1122 popup.SetSize( 100, 100 );
1123 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1125 // Create a button (to go underneath the popup).
1126 PushButton button = Toolkit::PushButton::New();
1127 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1128 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1129 button.SetSize( 100, 100 );
1130 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1132 button.ClickedSignal().Connect( &PushButtonClicked );
1134 Stage::GetCurrent().Add( button );
1136 button.Add( popup );
1138 popup.SetDisplayState( Popup::SHOWN );
1139 application.SendNotification();
1140 application.Render();
1142 gPushButtonClicked = false;
1143 Dali::Integration::TouchEvent event;
1145 // Perform a click, the popup should block the click from hitting the button.
1146 event = Dali::Integration::TouchEvent();
1147 event.AddPoint( GetPointDown() );
1148 application.ProcessEvent( event );
1149 application.SendNotification();
1150 application.Render();
1152 event = Dali::Integration::TouchEvent();
1153 event.AddPoint( GetPointUp() );
1154 application.ProcessEvent( event );
1155 application.SendNotification();
1156 application.Render();
1158 DALI_TEST_CHECK( !gPushButtonClicked );
1160 // Enable touch transparency.
1161 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1162 bool propertyResult;
1163 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1164 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1166 // Perform a click, the popup should allow the click to travel through to the button.
1167 event = Dali::Integration::TouchEvent();
1168 event.AddPoint( GetPointDown() );
1169 application.ProcessEvent( event );
1170 application.SendNotification();
1171 application.Render();
1173 event = Dali::Integration::TouchEvent();
1174 event.AddPoint( GetPointUp() );
1175 application.ProcessEvent( event );
1176 application.SendNotification();
1177 application.Render();
1179 DALI_TEST_CHECK( gPushButtonClicked );
1184 int UtcDaliPopupPropertyTail(void)
1186 ToolkitTestApplication application;
1187 tet_infoline( " UtcDaliPopupPropertyTail" );
1189 // Create the Popup actor
1190 Popup popup = Popup::New();
1191 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1192 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1193 popup.SetSize( 100, 100 );
1194 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1195 TextLabel content = TextLabel::New( "text" );
1196 popup.SetContent( content );
1198 std::string imageFilename = "invalid-image.jpg";
1199 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1200 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1201 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1202 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1204 std::string resultString;
1205 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1206 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1207 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1208 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1209 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1210 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1211 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1212 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1214 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1216 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1217 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1220 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1222 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1223 Vector3 vectorResult;
1224 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1225 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1227 Stage::GetCurrent().Add( popup );
1229 popup.SetDisplayState( Popup::SHOWN );
1230 application.SendNotification();
1231 application.Render();
1232 tailActor = popup.FindChildByName( "tailImage" );
1233 DALI_TEST_CHECK( tailActor );
1235 float baseValX = tailActor.GetCurrentWorldPosition().x;
1237 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1239 popup.SetDisplayState( Popup::HIDDEN );
1240 application.SendNotification();
1241 application.Render();
1243 tailPosition = ParentOrigin::CENTER_LEFT;
1244 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1246 popup.SetDisplayState( Popup::SHOWN );
1247 application.SendNotification();
1248 application.Render();
1249 tailActor = popup.FindChildByName( "tailImage" );
1250 DALI_TEST_CHECK( tailActor );
1252 float baseValY = tailActor.GetCurrentWorldPosition().y;
1253 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1255 popup.SetDisplayState( Popup::HIDDEN );
1256 application.SendNotification();
1257 application.Render();
1259 tailPosition = ParentOrigin::BOTTOM_CENTER;
1260 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1262 popup.SetDisplayState( Popup::SHOWN );
1263 application.SendNotification();
1264 application.Render();
1265 tailActor = popup.FindChildByName( "tailImage" );
1266 DALI_TEST_CHECK( tailActor );
1267 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1268 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1270 popup.SetDisplayState( Popup::HIDDEN );
1271 application.SendNotification();
1272 application.Render();
1274 tailPosition = ParentOrigin::CENTER_RIGHT;
1275 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1277 popup.SetDisplayState( Popup::SHOWN );
1278 application.SendNotification();
1279 application.Render();
1280 tailActor = popup.FindChildByName( "tailImage" );
1281 DALI_TEST_CHECK( tailActor );
1282 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1283 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1285 popup.SetDisplayState( Popup::HIDDEN );
1286 application.SendNotification();
1287 application.Render();
1292 int UtcDaliPopupTypeToast(void)
1294 ToolkitTestApplication application;
1295 tet_infoline( " UtcDaliPopupTypeToast" );
1297 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1298 DALI_TEST_CHECK( typeInfo )
1300 BaseHandle baseHandle = typeInfo.CreateInstance();
1301 DALI_TEST_CHECK( baseHandle )
1303 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1304 gPopupState = Toolkit::Popup::HIDDEN;
1305 ConnectStateSignals( popup );
1306 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1308 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1309 Stage::GetCurrent().Add( popup );
1310 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1312 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1314 application.SendNotification();
1315 application.Render( RENDER_FRAME_INTERVAL );
1318 // Check the toast popup is shown.
1319 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1321 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1323 application.SendNotification();
1324 application.Render( RENDER_FRAME_INTERVAL );
1327 // Check the toast popup hides.
1328 Dali::Timer timer = Timer::New( 0 );
1329 timer.MockEmitSignal();
1331 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1333 application.SendNotification();
1334 application.Render( RENDER_FRAME_INTERVAL );
1337 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1342 int UtcDaliPopupTypeRegistryCreation(void)
1344 ToolkitTestApplication application;
1345 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1347 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1348 DALI_TEST_CHECK( typeInfo )
1350 BaseHandle baseHandle = typeInfo.CreateInstance();
1351 DALI_TEST_CHECK( baseHandle )
1353 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1354 gPopupState = Toolkit::Popup::HIDDEN;
1355 ConnectStateSignals( popup );
1356 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1358 Stage::GetCurrent().Add( popup );
1359 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1361 application.SendNotification();
1362 application.Render();
1364 // Check the popup is shown.
1365 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1370 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1372 ToolkitTestApplication application;
1373 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1375 // Create the Popup actor
1376 Popup popup = Popup::New();
1378 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1379 // Note: The emmision of this signals has already been tested in other tests.
1380 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1381 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1382 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1383 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1384 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1386 // Test connecting to an invalid signal does not work.
1387 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1392 int UtcDaliPopupOnControlChildAdd(void)
1394 ToolkitTestApplication application;
1395 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1397 // Create the Popup actor
1398 Popup popup = Popup::New();
1399 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1400 std::string testLabelText = "ContentTest";
1401 TextLabel contentLabel = TextLabel::New( testLabelText );
1403 popup.Add( contentLabel );
1405 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1410 int UtcDaliPopupOnKeyEvent(void)
1412 ToolkitTestApplication application;
1413 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1415 // Create the Popup actor
1416 Popup popup = Popup::New();
1417 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1418 Stage::GetCurrent().Add( popup );
1420 popup.SetDisplayState( Popup::SHOWN );
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1426 popup.SetKeyInputFocus();
1428 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down ) );
1429 application.SendNotification();
1430 application.Render();
1432 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );