2 * Copyright (c) 2016 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,
182 const std::string& deviceName
185 return Integration::KeyEvent( keyName,
194 } // Anonymous namespace
197 * This test checks popup creation.
199 int UtcDaliPopupNewP( void )
201 ToolkitTestApplication application;
202 tet_infoline( " UtcDaliPopupNewP" );
204 // Create the Popup actor.
207 DALI_TEST_CHECK( !popup );
209 popup = Popup::New();
211 DALI_TEST_CHECK( popup );
213 Popup popup2( popup );
215 DALI_TEST_CHECK( popup2 == popup );
217 // Additional check to ensure object is created by checking if it's registered.
218 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
219 DALI_TEST_CHECK( registry );
221 gObjectCreatedCallBackCalled = false;
222 registry.ObjectCreatedSignal().Connect( &TestCallback );
224 Popup popup = Popup::New();
226 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
231 * This test checks popup destruction.
233 int UtcDaliPopupDestructorP( void )
235 ToolkitTestApplication application;
236 tet_infoline( " UtcDaliPopupDestructorP" );
238 Popup* popup = new Popup();
241 DALI_TEST_CHECK( true );
245 int UtcDaliPopupDownCastP(void)
247 ToolkitTestApplication application;
248 tet_infoline( " UtcDaliPopupDownCastP" );
250 Handle handle = Popup::New();
252 Popup popup = Popup::DownCast( handle );
254 DALI_TEST_CHECK( popup == handle );
258 int UtcDaliPopupSetPropertyP(void)
260 ToolkitTestApplication application;
261 tet_infoline( " UtcDaliPopupSetProperty" );
263 Popup popup = Popup::New();
266 std::string testString = "Hello World";
268 TextLabel textActorIn = TextLabel::New( testString );
270 Scripting::CreatePropertyMap( textActorIn, map );
271 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
272 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
273 std::string resultText;
274 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
275 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
280 int UtcDaliPopupSetTitleP(void)
282 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
283 tet_infoline( " UtcDaliPopupSetTitleP" );
285 // Create the Popup actor
286 Popup popup = Popup::New();
288 // Put in show state so it's layer is connected to popup (for ancestor check).
289 popup.SetDisplayState( Popup::SHOWN );
291 TextLabel titleActor = TextLabel::New();
292 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
294 DALI_TEST_CHECK( !popup.GetTitle() );
295 popup.SetTitle( titleActor );
296 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
297 DALI_TEST_CHECK( textActor == titleActor );
299 std::string resultText;
300 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
302 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
303 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
304 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
306 TextLabel titleActor2 = TextLabel::New();
307 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
308 popup.SetTitle( titleActor2 );
309 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
310 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
311 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
313 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
315 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
316 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
320 int UtcDaliPopupSetTitleN(void)
322 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
323 tet_infoline( " UtcDaliPopupSetTitleN" );
325 // Create the Popup actor
326 Popup popup = Popup::New();
328 TextLabel titleActor = TextLabel::New( "text" );
329 popup.SetTitle( titleActor );
331 DALI_TEST_CHECK( popup.GetTitle() );
333 // Set a bad title value.
334 // Confirm this has disabled the title.
336 popup.SetTitle( badActor );
338 DALI_TEST_CHECK( !popup.GetTitle() );
343 int UtcDaliPopupSetContentP(void)
345 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
346 tet_infoline( " UtcDaliPopupSetContentP" );
348 // Create the Popup actor
349 Popup popup = Popup::New();
350 Stage::GetCurrent().Add( popup );
351 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
353 // Put in show state so it's layer is connected to popup (for ancestor check).
354 popup.SetDisplayState( Popup::SHOWN );
356 PushButton button = PushButton::New();
357 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
358 popup.SetFooter( button );
359 // Hide and then re-show popup to cause button to be rearranged and added to popup.
360 popup.SetDisplayState( Popup::HIDDEN );
361 popup.SetDisplayState( Popup::SHOWN );
362 DALI_TEST_CHECK( HasAncestor( button, popup ) );
366 int UtcDaliPopupSetContentN(void)
368 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
369 tet_infoline( " UtcDaliPopupSetContentN" );
371 // Create the Popup actor
372 Popup popup = Popup::New();
374 TextLabel content = TextLabel::New( "text" );
375 popup.SetContent( content );
377 DALI_TEST_CHECK( popup.GetContent() );
379 // Set a bad title value.
381 popup.SetContent( badActor );
383 DALI_TEST_CHECK( !popup.GetContent() );
388 int UtcDaliPopupSetFooterP(void)
390 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
391 tet_infoline(" UtcDaliPopupSetFooterP");
393 // Create the Popup actor
394 Popup popup = Popup::New();
395 Stage::GetCurrent().Add( popup );
396 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
397 // Put in show state so it's layer is connected to popup (for ancestor check).
398 popup.SetDisplayState( Popup::SHOWN );
400 PushButton button = PushButton::New();
401 DALI_TEST_CHECK( !HasAncestor(button, popup) );
402 popup.SetFooter( button );
403 // Hide and then re-show popup to cause button to be rearranged and added to popup.
404 popup.SetDisplayState( Popup::HIDDEN );
405 popup.SetDisplayState( Popup::SHOWN );
406 DALI_TEST_CHECK( HasAncestor( button, popup ) );
410 int UtcDaliPopupSetFooterN(void)
412 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
413 tet_infoline(" UtcDaliPopupSetFooterN");
415 // Create the Popup actor
416 Popup popup = Popup::New();
418 PushButton button = PushButton::New();
419 popup.SetFooter( button );
421 DALI_TEST_CHECK( popup.GetFooter() );
423 // Set a bad title value.
425 popup.SetFooter( badActor );
427 DALI_TEST_CHECK( !popup.GetFooter() );
432 int UtcDaliPopupSetControlFooterMultiple(void)
434 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
435 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
437 // Create the Popup actor
438 Popup popup = Popup::New();
439 Stage::GetCurrent().Add( popup );
440 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
441 // Put in show state so it's layer is connected to popup (for ancestor check).
442 popup.SetDisplayState( Popup::SHOWN );
444 Actor container = Actor::New();
445 PushButton button1 = PushButton::New();
446 PushButton button2 = PushButton::New();
447 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
448 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
449 container.Add( button1 );
450 container.Add( button2 );
451 popup.SetFooter( container );
453 // Hide and then re-show popup to cause button to be rearranged and added to popup.
454 popup.SetDisplayState( Popup::HIDDEN );
455 popup.SetDisplayState( Popup::SHOWN );
456 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
457 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
461 int UtcDaliPopupSetStateP(void)
463 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
464 tet_infoline(" UtcDaliPopupSetStateP");
466 // Create the Popup actor
467 Popup popup = Popup::New();
469 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
471 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
473 popup.SetDisplayState( Popup::SHOWN );
474 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
476 popup.SetDisplayState( Popup::HIDDEN );
477 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
481 int UtcDaliPopupSetStateN(void)
483 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
484 tet_infoline(" UtcDaliPopupSetStateN");
486 // Create the Popup actor
487 Popup popup = Popup::New();
489 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
491 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
493 popup.SetDisplayState( Popup::SHOWN );
494 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
496 // Test cancelling a show before it has finished.
497 popup.SetDisplayState( Popup::HIDDEN );
498 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
502 int UtcDaliPopupDisplayStateSignal(void)
504 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
505 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
507 // Create the Popup actor
508 Popup popup = Popup::New();
509 ConnectStateSignals( popup );
511 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
512 popup.SetDisplayState( Popup::SHOWN );
513 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
514 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
516 // Wait for a while (allow animation to complete), and then check state.
517 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
519 application.SendNotification();
520 application.Render( RENDER_FRAME_INTERVAL );
523 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
524 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
527 popup.SetDisplayState( Popup::HIDDEN );
528 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
529 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
531 // Wait for a while (allow animation to complete), and then check state.
532 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
534 application.SendNotification();
535 application.Render( RENDER_FRAME_INTERVAL );
538 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
539 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
544 int UtcDaliPopupShowHide(void)
546 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
547 tet_infoline(" UtcDaliPopupShowHide");
549 // Create the Popup actor
550 Popup popup = Popup::New();
551 ConnectStateSignals( popup );
553 Actor container = Actor::New();
554 PushButton button1 = PushButton::New();
555 PushButton button2 = PushButton::New();
556 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
557 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
558 container.Add( button1 );
559 container.Add( button2 );
560 popup.SetFooter( container );
563 // Note: in most popup animation implementations show would result in
564 // popup being onstage immediately following Show(). However we can't
565 // assume for all. e.g. If one creates a animation with a delay.
566 popup.SetDisplayState( Popup::SHOWN );
568 // Wait for a while (allow animation to complete), and then check state.
569 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
571 application.SendNotification();
572 application.Render( RENDER_FRAME_INTERVAL );
576 popup.SetDisplayState( Popup::HIDDEN );
578 // Wait for a while (allow animation to complete), and then check state.
579 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
581 application.SendNotification();
582 application.Render(RENDER_FRAME_INTERVAL);
585 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
589 int UtcDaliPopupPropertyTailVisibility(void)
591 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
592 tet_infoline(" UtcDaliPopupShowHideTail");
594 // Create the Popup actor
595 Popup popup = Popup::New();
596 Stage::GetCurrent().Add( popup );
598 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
599 popup.SetDisplayState( Popup::SHOWN );
601 int withoutTailCount = DescendentCount( popup );
603 popup.SetDisplayState( Popup::HIDDEN );
605 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
606 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
607 popup.SetDisplayState( Popup::SHOWN );
609 int withTailCount = DescendentCount( popup );
611 // There should be more actors if the Tail has been added.
612 DALI_TEST_CHECK( withTailCount > withoutTailCount );
615 popup.SetDisplayState( Popup::HIDDEN );
616 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
617 popup.SetDisplayState( Popup::SHOWN );
618 int withoutTailCount2 = DescendentCount(popup);
620 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
624 int UtcDaliPopupOnTouchedOutsideSignal(void)
626 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
627 tet_infoline(" UtcDaliPopupOnTouchedOutside");
629 // Create the Popup actor
630 Popup popup = Popup::New();
631 popup.SetParentOrigin( ParentOrigin::CENTER );
632 popup.SetAnchorPoint( ParentOrigin::CENTER );
633 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
634 popup.SetSize( 50.0f, 50.0f );
635 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
636 Stage::GetCurrent().Add( popup );
637 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
638 popup.SetDisplayState( Popup::SHOWN );
640 application.SendNotification();
641 application.Render();
643 gTouchedOutside = false;
644 Dali::Integration::TouchEvent event;
646 event = Dali::Integration::TouchEvent();
647 event.AddPoint( GetPointDown() );
648 application.ProcessEvent( event );
650 application.SendNotification();
651 application.Render();
653 event = Dali::Integration::TouchEvent();
654 event.AddPoint( GetPointUp() );
655 application.ProcessEvent( event );
657 application.SendNotification();
658 application.Render();
660 // Confirm the signal is ignored if touch_transparent.
661 gTouchedOutside = false;
662 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
664 event = Dali::Integration::TouchEvent();
665 event.AddPoint( GetPointDown() );
666 application.ProcessEvent( event );
668 application.SendNotification();
669 application.Render();
671 event = Dali::Integration::TouchEvent();
672 event.AddPoint( GetPointUp() );
673 application.ProcessEvent( event );
675 application.SendNotification();
676 application.Render();
678 DALI_TEST_CHECK( !gTouchedOutside );
683 int UtcDaliPopupPropertyAutoHide(void)
685 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
686 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
688 // Create the Popup actor
689 Popup popup = Popup::New();
690 ConnectStateSignals( popup );
692 Actor container = Actor::New();
693 PushButton button1 = PushButton::New();
694 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
695 container.Add( button1 );
696 popup.SetFooter( container );
698 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
699 float getAnimationDuration = 0.0f;
700 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
701 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
703 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
704 int getAutoHideDelay = 0;
705 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
706 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
708 Stage::GetCurrent().Add( popup );
710 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
713 // Note: in most popup animation implementations show would result in
714 // popup being onstage immediately following Show(). However we can't
715 // assume for all. e.g. If one creates a animation with a delay.
716 popup.SetDisplayState( Popup::SHOWN );
718 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
720 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
722 application.SendNotification();
723 application.Render( RENDER_FRAME_INTERVAL );
726 // Force the timer used by the popup to expire,
727 // this will cause the popup to hide automatically.
728 Dali::Timer timer = Timer::New( 0 );
729 timer.MockEmitSignal();
731 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
737 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
739 int UtcDaliPopupPropertyAnimationMode(void)
741 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
742 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
744 // Create the Popup actor
745 Popup popup = Popup::New();
746 ConnectStateSignals( popup );
747 popup.SetTitle( TextLabel::New( "Title" ) );
748 Stage::GetCurrent().Add( popup );
750 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
752 // Try both default and zero animation duration, as zero has a special case for some animation types.
753 for( int j = 0; j <= 1; j++ )
755 // On the second loop, set duration to zero.
758 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
761 // Loop through 4 animation modes.
762 for( int i = 0; i < 4; i++ )
764 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
766 std::string checkMode;
767 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
769 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
771 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
772 std::string resultState;
774 // Only wait for animation if it isn't instant.
777 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
778 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
779 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
780 WaitAnimation( application );
783 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
784 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
785 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
786 popup.SetDisplayState( Popup::HIDDEN );
790 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
791 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
792 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
793 WaitAnimation( application );
796 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
797 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
798 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
805 int UtcDaliPopupPropertyTitle(void)
807 ToolkitTestApplication application;
808 tet_infoline( " UtcDaliPopupPropertyTitle" );
810 // Create the Popup actor
811 Popup popup = Popup::New();
813 std::string testLabelText = "TitleTest";
814 TextLabel titleLabel = TextLabel::New();
815 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
816 Actor title = titleLabel;
818 Scripting::CreatePropertyMap( title, map );
819 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
821 Property::Map resultMap;
822 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
824 Property::Value* resultProperty = resultMap.Find( "text" );
825 DALI_TEST_CHECK( resultProperty );
827 std::string resultText;
828 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
830 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
835 int UtcDaliPopupPropertyContent(void)
837 ToolkitTestApplication application;
838 tet_infoline( " UtcDaliPopupPropertyContent" );
840 // Create the Popup actor
841 Popup popup = Popup::New();
843 std::string testLabelText = "ContentTest";
844 TextLabel contentLabel = TextLabel::New();
845 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
846 Actor content = contentLabel;
848 Scripting::CreatePropertyMap( content, map );
849 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
851 Property::Map resultMap;
852 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
854 Property::Value* resultProperty = resultMap.Find( "text" );
855 DALI_TEST_CHECK( resultProperty );
857 std::string resultText;
858 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
860 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
865 int UtcDaliPopupPropertyFooter(void)
867 ToolkitTestApplication application;
868 tet_infoline( " UtcDaliPopupPropertyFooter" );
870 // Create the Popup actor
871 Popup popup = Popup::New();
873 std::string testLabelText = "FooterTest";
874 TextLabel footerLabel = TextLabel::New();
875 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
876 Actor footer = footerLabel;
878 Scripting::CreatePropertyMap( footer, map );
879 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
881 Property::Map resultMap;
882 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
884 Property::Value* resultProperty = resultMap.Find( "text" );
885 DALI_TEST_CHECK( resultProperty );
887 std::string resultText;
888 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
890 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
895 int UtcDaliPopupPropertyContextualMode(void)
897 ToolkitTestApplication application;
898 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
900 // Create the Popup actor
901 Popup popup = Popup::New();
902 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
903 std::string testLabelText = "ContentTest";
905 TextLabel contentLabel = TextLabel::New();
907 popup.SetContent( contentLabel );
909 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
910 Actor placement = Actor::New();
911 placement.SetParentOrigin( ParentOrigin::CENTER );
912 placement.SetAnchorPoint( AnchorPoint::CENTER );
913 placement.SetSize( 1.0f, 1.0f );
914 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
915 Stage::GetCurrent().Add( placement );
917 placement.Add( popup );
919 // Test all contextual modes.
920 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
921 Vector2 offsetValues[5];
922 offsetValues[0] = Vector2( 0.375f, 0.0f );
923 offsetValues[1] = Vector2( -0.125f, -10.5f );
924 offsetValues[2] = Vector2( 10.875f, -0.5f );
925 offsetValues[3] = Vector2( -0.125f, 10.5f );
926 offsetValues[4] = Vector2( -10.875f, -0.5f );
928 for( int i = 0; i < 5; ++i )
930 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
932 std::string propertyResult;
933 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
934 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
936 popup.SetDisplayState( Popup::SHOWN );
937 application.SendNotification();
938 application.Render();
940 // Check the position of the label within the popup.
941 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
943 popup.SetDisplayState( Popup::HIDDEN );
944 application.SendNotification();
945 application.Render();
951 int UtcDaliPopupPropertyBacking(void)
953 ToolkitTestApplication application;
954 tet_infoline( " UtcDaliPopupPropertyBacking" );
956 // Create the Popup actor
957 Popup popup = Popup::New();
958 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
959 Stage::GetCurrent().Add( popup );
961 Actor backing = popup.FindChildByName( "popupBacking" );
962 DALI_TEST_CHECK( backing );
964 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
966 // Check enabled property.
967 popup.SetDisplayState( Popup::SHOWN );
968 application.SendNotification();
969 application.Render();
971 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, 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 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
981 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
982 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
984 popup.SetDisplayState( Popup::SHOWN );
985 application.SendNotification();
986 application.Render();
988 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
990 popup.SetDisplayState( Popup::HIDDEN );
991 application.SendNotification();
992 application.Render();
994 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996 // Check color property.
997 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
998 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1000 popup.SetDisplayState( Popup::SHOWN );
1001 application.SendNotification();
1002 application.Render();
1004 Vector4 resultColor;
1005 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1006 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1011 int UtcDaliPopupPropertyBackgroundImage(void)
1013 ToolkitTestApplication application;
1014 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1016 // Create the Popup actor
1017 Popup popup = Popup::New();
1018 Stage::GetCurrent().Add( popup );
1020 // Check setting an image
1021 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1022 std::string resultString;
1023 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1024 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1029 int UtcDaliPopupPropertyCustomAnimation(void)
1031 ToolkitTestApplication application;
1032 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1034 // Create the Popup actor
1035 Popup popup = Popup::New();
1036 TextLabel content = TextLabel::New( "text" );
1037 popup.SetContent( content );
1039 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1040 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1042 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1043 DALI_TEST_CHECK( popupContainer );
1045 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1046 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1048 Property::Map animationMapEntry;
1049 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1050 animationMapEntry.Insert( "property", "position" );
1051 animationMapEntry.Insert( "value", entryAnimationDestination );
1052 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1054 Property::Array timePeriodMapEntry;
1055 timePeriodMapEntry.PushBack( 0.0f );
1056 timePeriodMapEntry.PushBack( 1.0f );
1058 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1060 Property::Map animationMapExit;
1061 animationMapExit.Insert( "actor", "customAnimationPopup" );
1062 animationMapExit.Insert( "property", "position" );
1063 animationMapExit.Insert( "value", exitAnimationDestination );
1064 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1066 Property::Array timePeriodMapExit;
1067 timePeriodMapExit.PushBack( 0.0f );
1068 timePeriodMapExit.PushBack( 1.0f );
1070 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1072 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1073 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1075 Property::Map resultMap;
1076 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1077 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1078 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1079 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1081 Stage::GetCurrent().Add( popup );
1082 popup.SetDisplayState( Popup::SHOWN );
1084 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1086 application.SendNotification();
1087 application.Render( RENDER_FRAME_INTERVAL );
1090 // Test the popup has animated to it's entry-transition destination.
1091 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1093 popup.SetDisplayState( Popup::HIDDEN );
1095 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1097 application.SendNotification();
1098 application.Render( RENDER_FRAME_INTERVAL );
1101 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1106 static bool gPushButtonClicked;
1107 static bool PushButtonClicked( Button button )
1109 gPushButtonClicked = true;
1113 int UtcDaliPopupPropertyTouchTransparent(void)
1115 ToolkitTestApplication application;
1116 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1118 // Create the Popup actor
1119 Popup popup = Popup::New();
1120 TextLabel content = TextLabel::New( "text" );
1121 popup.SetContent( content );
1122 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1123 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1124 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1125 popup.SetSize( 100, 100 );
1126 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1128 // Create a button (to go underneath the popup).
1129 PushButton button = Toolkit::PushButton::New();
1130 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1131 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1132 button.SetSize( 100, 100 );
1133 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1135 button.ClickedSignal().Connect( &PushButtonClicked );
1137 Stage::GetCurrent().Add( button );
1139 button.Add( popup );
1141 popup.SetDisplayState( Popup::SHOWN );
1142 application.SendNotification();
1143 application.Render();
1145 gPushButtonClicked = false;
1146 Dali::Integration::TouchEvent event;
1148 // Perform a click, the popup should block the click from hitting the button.
1149 event = Dali::Integration::TouchEvent();
1150 event.AddPoint( GetPointDown() );
1151 application.ProcessEvent( event );
1152 application.SendNotification();
1153 application.Render();
1155 event = Dali::Integration::TouchEvent();
1156 event.AddPoint( GetPointUp() );
1157 application.ProcessEvent( event );
1158 application.SendNotification();
1159 application.Render();
1161 DALI_TEST_CHECK( !gPushButtonClicked );
1163 // Enable touch transparency.
1164 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1165 bool propertyResult;
1166 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1167 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1169 // Perform a click, the popup should allow the click to travel through to the button.
1170 event = Dali::Integration::TouchEvent();
1171 event.AddPoint( GetPointDown() );
1172 application.ProcessEvent( event );
1173 application.SendNotification();
1174 application.Render();
1176 event = Dali::Integration::TouchEvent();
1177 event.AddPoint( GetPointUp() );
1178 application.ProcessEvent( event );
1179 application.SendNotification();
1180 application.Render();
1182 DALI_TEST_CHECK( gPushButtonClicked );
1187 int UtcDaliPopupPropertyTail(void)
1189 ToolkitTestApplication application;
1190 tet_infoline( " UtcDaliPopupPropertyTail" );
1192 // Create the Popup actor
1193 Popup popup = Popup::New();
1194 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1195 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1196 popup.SetSize( 100, 100 );
1197 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1198 TextLabel content = TextLabel::New( "text" );
1199 popup.SetContent( content );
1201 std::string imageFilename = "invalid-image.jpg";
1202 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1203 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1204 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1205 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1207 std::string resultString;
1208 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1209 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1210 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1211 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1212 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1213 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1214 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1215 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1217 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1219 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1220 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1223 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1225 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1226 Vector3 vectorResult;
1227 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1228 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1230 Stage::GetCurrent().Add( popup );
1232 popup.SetDisplayState( Popup::SHOWN );
1233 application.SendNotification();
1234 application.Render();
1235 tailActor = popup.FindChildByName( "tailImage" );
1236 DALI_TEST_CHECK( tailActor );
1238 float baseValX = tailActor.GetCurrentWorldPosition().x;
1240 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1242 popup.SetDisplayState( Popup::HIDDEN );
1243 application.SendNotification();
1244 application.Render();
1246 tailPosition = ParentOrigin::CENTER_LEFT;
1247 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1249 popup.SetDisplayState( Popup::SHOWN );
1250 application.SendNotification();
1251 application.Render();
1252 tailActor = popup.FindChildByName( "tailImage" );
1253 DALI_TEST_CHECK( tailActor );
1255 float baseValY = tailActor.GetCurrentWorldPosition().y;
1256 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1258 popup.SetDisplayState( Popup::HIDDEN );
1259 application.SendNotification();
1260 application.Render();
1262 tailPosition = ParentOrigin::BOTTOM_CENTER;
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_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1271 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1273 popup.SetDisplayState( Popup::HIDDEN );
1274 application.SendNotification();
1275 application.Render();
1277 tailPosition = ParentOrigin::CENTER_RIGHT;
1278 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1280 popup.SetDisplayState( Popup::SHOWN );
1281 application.SendNotification();
1282 application.Render();
1283 tailActor = popup.FindChildByName( "tailImage" );
1284 DALI_TEST_CHECK( tailActor );
1285 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1286 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1288 popup.SetDisplayState( Popup::HIDDEN );
1289 application.SendNotification();
1290 application.Render();
1295 int UtcDaliPopupTypeToast(void)
1297 ToolkitTestApplication application;
1298 tet_infoline( " UtcDaliPopupTypeToast" );
1300 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1301 DALI_TEST_CHECK( typeInfo )
1303 BaseHandle baseHandle = typeInfo.CreateInstance();
1304 DALI_TEST_CHECK( baseHandle )
1306 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1307 gPopupState = Toolkit::Popup::HIDDEN;
1308 ConnectStateSignals( popup );
1309 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1311 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1312 Stage::GetCurrent().Add( popup );
1313 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1315 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1317 application.SendNotification();
1318 application.Render( RENDER_FRAME_INTERVAL );
1321 // Check the toast popup is shown.
1322 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1324 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1326 application.SendNotification();
1327 application.Render( RENDER_FRAME_INTERVAL );
1330 // Check the toast popup hides.
1331 Dali::Timer timer = Timer::New( 0 );
1332 timer.MockEmitSignal();
1334 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1336 application.SendNotification();
1337 application.Render( RENDER_FRAME_INTERVAL );
1340 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1345 int UtcDaliPopupTypeRegistryCreation(void)
1347 ToolkitTestApplication application;
1348 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1350 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1351 DALI_TEST_CHECK( typeInfo )
1353 BaseHandle baseHandle = typeInfo.CreateInstance();
1354 DALI_TEST_CHECK( baseHandle )
1356 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1357 gPopupState = Toolkit::Popup::HIDDEN;
1358 ConnectStateSignals( popup );
1359 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1361 Stage::GetCurrent().Add( popup );
1362 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1364 application.SendNotification();
1365 application.Render();
1367 // Check the popup is shown.
1368 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1373 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1375 ToolkitTestApplication application;
1376 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1378 // Create the Popup actor
1379 Popup popup = Popup::New();
1381 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1382 // Note: The emmision of this signals has already been tested in other tests.
1383 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1384 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1385 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1386 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1387 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1389 // Test connecting to an invalid signal does not work.
1390 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1395 int UtcDaliPopupOnControlChildAdd(void)
1397 ToolkitTestApplication application;
1398 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1400 // Create the Popup actor
1401 Popup popup = Popup::New();
1402 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1403 std::string testLabelText = "ContentTest";
1404 TextLabel contentLabel = TextLabel::New( testLabelText );
1406 popup.Add( contentLabel );
1408 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1413 int UtcDaliPopupOnKeyEvent(void)
1415 ToolkitTestApplication application;
1416 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1418 // Create the Popup actor
1419 Popup popup = Popup::New();
1420 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1421 Stage::GetCurrent().Add( popup );
1423 popup.SetDisplayState( Popup::SHOWN );
1424 application.SendNotification();
1425 application.Render();
1427 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1429 popup.SetKeyInputFocus();
1431 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "" ) );
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1440 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1442 ToolkitTestApplication application;
1444 tet_infoline( "Set the background border property of a popup & retrieve it" );
1445 Popup popup = Popup::New();
1447 Rect< int > rect( 40, 30, 20, 10 );
1448 tet_infoline( "Ensure value we want to set is different from what is already set" );
1449 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1451 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1452 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1453 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1455 tet_infoline( "Set a vector4 as well which should also work" );
1456 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1457 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1458 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );