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,
183 const DevelKeyEvent::DeviceClass::Type& deviceClass
186 return Integration::KeyEvent( keyName,
196 } // Anonymous namespace
199 * This test checks popup creation.
201 int UtcDaliPopupNewP( void )
203 ToolkitTestApplication application;
204 tet_infoline( " UtcDaliPopupNewP" );
206 // Create the Popup actor.
209 DALI_TEST_CHECK( !popup );
211 popup = Popup::New();
213 DALI_TEST_CHECK( popup );
215 Popup popup2( popup );
217 DALI_TEST_CHECK( popup2 == popup );
219 // Additional check to ensure object is created by checking if it's registered.
220 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
221 DALI_TEST_CHECK( registry );
223 gObjectCreatedCallBackCalled = false;
224 registry.ObjectCreatedSignal().Connect( &TestCallback );
226 Popup popup = Popup::New();
228 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
233 * This test checks popup destruction.
235 int UtcDaliPopupDestructorP( void )
237 ToolkitTestApplication application;
238 tet_infoline( " UtcDaliPopupDestructorP" );
240 Popup* popup = new Popup();
243 DALI_TEST_CHECK( true );
247 int UtcDaliPopupDownCastP(void)
249 ToolkitTestApplication application;
250 tet_infoline( " UtcDaliPopupDownCastP" );
252 Handle handle = Popup::New();
254 Popup popup = Popup::DownCast( handle );
256 DALI_TEST_CHECK( popup == handle );
260 int UtcDaliPopupSetPropertyP(void)
262 ToolkitTestApplication application;
263 tet_infoline( " UtcDaliPopupSetProperty" );
265 Popup popup = Popup::New();
268 std::string testString = "Hello World";
270 TextLabel textActorIn = TextLabel::New( testString );
272 Scripting::CreatePropertyMap( textActorIn, map );
273 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
274 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
275 std::string resultText;
276 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
277 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
282 int UtcDaliPopupSetTitleP(void)
284 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
285 tet_infoline( " UtcDaliPopupSetTitleP" );
287 // Create the Popup actor
288 Popup popup = Popup::New();
290 // Put in show state so it's layer is connected to popup (for ancestor check).
291 popup.SetDisplayState( Popup::SHOWN );
293 TextLabel titleActor = TextLabel::New();
294 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
296 DALI_TEST_CHECK( !popup.GetTitle() );
297 popup.SetTitle( titleActor );
298 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
299 DALI_TEST_CHECK( textActor == titleActor );
301 std::string resultText;
302 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
304 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
305 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
306 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
308 TextLabel titleActor2 = TextLabel::New();
309 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
310 popup.SetTitle( titleActor2 );
311 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
312 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
313 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
315 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
317 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
318 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
322 int UtcDaliPopupSetTitleN(void)
324 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
325 tet_infoline( " UtcDaliPopupSetTitleN" );
327 // Create the Popup actor
328 Popup popup = Popup::New();
330 TextLabel titleActor = TextLabel::New( "text" );
331 popup.SetTitle( titleActor );
333 DALI_TEST_CHECK( popup.GetTitle() );
335 // Set a bad title value.
336 // Confirm this has disabled the title.
338 popup.SetTitle( badActor );
340 DALI_TEST_CHECK( !popup.GetTitle() );
345 int UtcDaliPopupSetContentP(void)
347 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
348 tet_infoline( " UtcDaliPopupSetContentP" );
350 // Create the Popup actor
351 Popup popup = Popup::New();
352 Stage::GetCurrent().Add( popup );
353 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
355 // Put in show state so it's layer is connected to popup (for ancestor check).
356 popup.SetDisplayState( Popup::SHOWN );
358 PushButton button = PushButton::New();
359 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
360 popup.SetFooter( button );
361 // Hide and then re-show popup to cause button to be rearranged and added to popup.
362 popup.SetDisplayState( Popup::HIDDEN );
363 popup.SetDisplayState( Popup::SHOWN );
364 DALI_TEST_CHECK( HasAncestor( button, popup ) );
368 int UtcDaliPopupSetContentN(void)
370 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
371 tet_infoline( " UtcDaliPopupSetContentN" );
373 // Create the Popup actor
374 Popup popup = Popup::New();
376 TextLabel content = TextLabel::New( "text" );
377 popup.SetContent( content );
379 DALI_TEST_CHECK( popup.GetContent() );
381 // Set a bad title value.
383 popup.SetContent( badActor );
385 DALI_TEST_CHECK( !popup.GetContent() );
390 int UtcDaliPopupSetFooterP(void)
392 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
393 tet_infoline(" UtcDaliPopupSetFooterP");
395 // Create the Popup actor
396 Popup popup = Popup::New();
397 Stage::GetCurrent().Add( popup );
398 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
399 // Put in show state so it's layer is connected to popup (for ancestor check).
400 popup.SetDisplayState( Popup::SHOWN );
402 PushButton button = PushButton::New();
403 DALI_TEST_CHECK( !HasAncestor(button, popup) );
404 popup.SetFooter( button );
405 // Hide and then re-show popup to cause button to be rearranged and added to popup.
406 popup.SetDisplayState( Popup::HIDDEN );
407 popup.SetDisplayState( Popup::SHOWN );
408 DALI_TEST_CHECK( HasAncestor( button, popup ) );
412 int UtcDaliPopupSetFooterN(void)
414 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
415 tet_infoline(" UtcDaliPopupSetFooterN");
417 // Create the Popup actor
418 Popup popup = Popup::New();
420 PushButton button = PushButton::New();
421 popup.SetFooter( button );
423 DALI_TEST_CHECK( popup.GetFooter() );
425 // Set a bad title value.
427 popup.SetFooter( badActor );
429 DALI_TEST_CHECK( !popup.GetFooter() );
434 int UtcDaliPopupSetControlFooterMultiple(void)
436 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
437 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
439 // Create the Popup actor
440 Popup popup = Popup::New();
441 Stage::GetCurrent().Add( popup );
442 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
443 // Put in show state so it's layer is connected to popup (for ancestor check).
444 popup.SetDisplayState( Popup::SHOWN );
446 Actor container = Actor::New();
447 PushButton button1 = PushButton::New();
448 PushButton button2 = PushButton::New();
449 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
450 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
451 container.Add( button1 );
452 container.Add( button2 );
453 popup.SetFooter( container );
455 // Hide and then re-show popup to cause button to be rearranged and added to popup.
456 popup.SetDisplayState( Popup::HIDDEN );
457 popup.SetDisplayState( Popup::SHOWN );
458 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
459 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
463 int UtcDaliPopupSetStateP(void)
465 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
466 tet_infoline(" UtcDaliPopupSetStateP");
468 // Create the Popup actor
469 Popup popup = Popup::New();
471 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
473 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
475 popup.SetDisplayState( Popup::SHOWN );
476 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
478 popup.SetDisplayState( Popup::HIDDEN );
479 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
483 int UtcDaliPopupSetStateN(void)
485 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
486 tet_infoline(" UtcDaliPopupSetStateN");
488 // Create the Popup actor
489 Popup popup = Popup::New();
491 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
493 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
495 popup.SetDisplayState( Popup::SHOWN );
496 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
498 // Test cancelling a show before it has finished.
499 popup.SetDisplayState( Popup::HIDDEN );
500 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
504 int UtcDaliPopupDisplayStateSignal(void)
506 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
507 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
509 // Create the Popup actor
510 Popup popup = Popup::New();
511 ConnectStateSignals( popup );
513 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
514 popup.SetDisplayState( Popup::SHOWN );
515 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
516 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
518 // Wait for a while (allow animation to complete), and then check state.
519 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
521 application.SendNotification();
522 application.Render( RENDER_FRAME_INTERVAL );
525 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
526 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
529 popup.SetDisplayState( Popup::HIDDEN );
530 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
531 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
533 // Wait for a while (allow animation to complete), and then check state.
534 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
536 application.SendNotification();
537 application.Render( RENDER_FRAME_INTERVAL );
540 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
541 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
546 int UtcDaliPopupShowHide(void)
548 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
549 tet_infoline(" UtcDaliPopupShowHide");
551 // Create the Popup actor
552 Popup popup = Popup::New();
553 ConnectStateSignals( popup );
555 Actor container = Actor::New();
556 PushButton button1 = PushButton::New();
557 PushButton button2 = PushButton::New();
558 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
559 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
560 container.Add( button1 );
561 container.Add( button2 );
562 popup.SetFooter( container );
565 // Note: in most popup animation implementations show would result in
566 // popup being onstage immediately following Show(). However we can't
567 // assume for all. e.g. If one creates a animation with a delay.
568 popup.SetDisplayState( Popup::SHOWN );
570 // Wait for a while (allow animation to complete), and then check state.
571 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
573 application.SendNotification();
574 application.Render( RENDER_FRAME_INTERVAL );
578 popup.SetDisplayState( Popup::HIDDEN );
580 // Wait for a while (allow animation to complete), and then check state.
581 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
583 application.SendNotification();
584 application.Render(RENDER_FRAME_INTERVAL);
587 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
591 int UtcDaliPopupPropertyTailVisibility(void)
593 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
594 tet_infoline(" UtcDaliPopupShowHideTail");
596 // Create the Popup actor
597 Popup popup = Popup::New();
598 Stage::GetCurrent().Add( popup );
600 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
601 popup.SetDisplayState( Popup::SHOWN );
603 int withoutTailCount = DescendentCount( popup );
605 popup.SetDisplayState( Popup::HIDDEN );
607 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
608 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
609 popup.SetDisplayState( Popup::SHOWN );
611 int withTailCount = DescendentCount( popup );
613 // There should be more actors if the Tail has been added.
614 DALI_TEST_CHECK( withTailCount > withoutTailCount );
617 popup.SetDisplayState( Popup::HIDDEN );
618 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
619 popup.SetDisplayState( Popup::SHOWN );
620 int withoutTailCount2 = DescendentCount(popup);
622 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
626 int UtcDaliPopupOnTouchedOutsideSignal(void)
628 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
629 tet_infoline(" UtcDaliPopupOnTouchedOutside");
631 // Create the Popup actor
632 Popup popup = Popup::New();
633 popup.SetParentOrigin( ParentOrigin::CENTER );
634 popup.SetAnchorPoint( ParentOrigin::CENTER );
635 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
636 popup.SetSize( 50.0f, 50.0f );
637 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
638 Stage::GetCurrent().Add( popup );
639 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
640 popup.SetDisplayState( Popup::SHOWN );
642 application.SendNotification();
643 application.Render();
645 gTouchedOutside = false;
646 Dali::Integration::TouchEvent event;
648 event = Dali::Integration::TouchEvent();
649 event.AddPoint( GetPointDown() );
650 application.ProcessEvent( event );
652 application.SendNotification();
653 application.Render();
655 event = Dali::Integration::TouchEvent();
656 event.AddPoint( GetPointUp() );
657 application.ProcessEvent( event );
659 application.SendNotification();
660 application.Render();
662 // Confirm the signal is ignored if touch_transparent.
663 gTouchedOutside = false;
664 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
666 event = Dali::Integration::TouchEvent();
667 event.AddPoint( GetPointDown() );
668 application.ProcessEvent( event );
670 application.SendNotification();
671 application.Render();
673 event = Dali::Integration::TouchEvent();
674 event.AddPoint( GetPointUp() );
675 application.ProcessEvent( event );
677 application.SendNotification();
678 application.Render();
680 DALI_TEST_CHECK( !gTouchedOutside );
685 int UtcDaliPopupPropertyAutoHide(void)
687 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
688 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
690 // Create the Popup actor
691 Popup popup = Popup::New();
692 ConnectStateSignals( popup );
694 Actor container = Actor::New();
695 PushButton button1 = PushButton::New();
696 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
697 container.Add( button1 );
698 popup.SetFooter( container );
700 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
701 float getAnimationDuration = 0.0f;
702 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
703 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
705 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
706 int getAutoHideDelay = 0;
707 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
708 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
710 Stage::GetCurrent().Add( popup );
712 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
715 // Note: in most popup animation implementations show would result in
716 // popup being onstage immediately following Show(). However we can't
717 // assume for all. e.g. If one creates a animation with a delay.
718 popup.SetDisplayState( Popup::SHOWN );
720 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
722 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
724 application.SendNotification();
725 application.Render( RENDER_FRAME_INTERVAL );
728 // Force the timer used by the popup to expire,
729 // this will cause the popup to hide automatically.
730 Dali::Timer timer = Timer::New( 0 );
731 timer.MockEmitSignal();
733 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
739 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
741 int UtcDaliPopupPropertyAnimationMode(void)
743 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
744 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
746 // Create the Popup actor
747 Popup popup = Popup::New();
748 ConnectStateSignals( popup );
749 popup.SetTitle( TextLabel::New( "Title" ) );
750 Stage::GetCurrent().Add( popup );
752 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
754 // Try both default and zero animation duration, as zero has a special case for some animation types.
755 for( int j = 0; j <= 1; j++ )
757 // On the second loop, set duration to zero.
760 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
763 // Loop through 4 animation modes.
764 for( int i = 0; i < 4; i++ )
766 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
768 std::string checkMode;
769 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
771 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
773 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
774 std::string resultState;
776 // Only wait for animation if it isn't instant.
779 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
780 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
781 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
782 WaitAnimation( application );
785 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
786 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
787 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
788 popup.SetDisplayState( Popup::HIDDEN );
792 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
793 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
794 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
795 WaitAnimation( application );
798 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
799 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
800 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
807 int UtcDaliPopupPropertyTitle(void)
809 ToolkitTestApplication application;
810 tet_infoline( " UtcDaliPopupPropertyTitle" );
812 // Create the Popup actor
813 Popup popup = Popup::New();
815 std::string testLabelText = "TitleTest";
816 TextLabel titleLabel = TextLabel::New();
817 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
818 Actor title = titleLabel;
820 Scripting::CreatePropertyMap( title, map );
821 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
823 Property::Map resultMap;
824 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
826 Property::Value* resultProperty = resultMap.Find( "text" );
827 DALI_TEST_CHECK( resultProperty );
829 std::string resultText;
830 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
832 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
837 int UtcDaliPopupPropertyContent(void)
839 ToolkitTestApplication application;
840 tet_infoline( " UtcDaliPopupPropertyContent" );
842 // Create the Popup actor
843 Popup popup = Popup::New();
845 std::string testLabelText = "ContentTest";
846 TextLabel contentLabel = TextLabel::New();
847 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
848 Actor content = contentLabel;
850 Scripting::CreatePropertyMap( content, map );
851 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
853 Property::Map resultMap;
854 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
856 Property::Value* resultProperty = resultMap.Find( "text" );
857 DALI_TEST_CHECK( resultProperty );
859 std::string resultText;
860 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
862 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
867 int UtcDaliPopupPropertyFooter(void)
869 ToolkitTestApplication application;
870 tet_infoline( " UtcDaliPopupPropertyFooter" );
872 // Create the Popup actor
873 Popup popup = Popup::New();
875 std::string testLabelText = "FooterTest";
876 TextLabel footerLabel = TextLabel::New();
877 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
878 Actor footer = footerLabel;
880 Scripting::CreatePropertyMap( footer, map );
881 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
883 Property::Map resultMap;
884 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
886 Property::Value* resultProperty = resultMap.Find( "text" );
887 DALI_TEST_CHECK( resultProperty );
889 std::string resultText;
890 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
892 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
897 int UtcDaliPopupPropertyContextualMode(void)
899 ToolkitTestApplication application;
900 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
902 // Create the Popup actor
903 Popup popup = Popup::New();
904 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
905 std::string testLabelText = "ContentTest";
907 TextLabel contentLabel = TextLabel::New();
909 popup.SetContent( contentLabel );
911 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
912 Actor placement = Actor::New();
913 placement.SetParentOrigin( ParentOrigin::CENTER );
914 placement.SetAnchorPoint( AnchorPoint::CENTER );
915 placement.SetSize( 1.0f, 1.0f );
916 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
917 Stage::GetCurrent().Add( placement );
919 placement.Add( popup );
921 // Test all contextual modes.
922 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
923 Vector2 offsetValues[5];
924 offsetValues[0] = Vector2( 0.375f, 0.0f );
925 offsetValues[1] = Vector2( -0.125f, -10.5f );
926 offsetValues[2] = Vector2( 10.875f, -0.5f );
927 offsetValues[3] = Vector2( -0.125f, 10.5f );
928 offsetValues[4] = Vector2( -10.875f, -0.5f );
930 for( int i = 0; i < 5; ++i )
932 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
934 std::string propertyResult;
935 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
936 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
938 popup.SetDisplayState( Popup::SHOWN );
939 application.SendNotification();
940 application.Render();
942 // Check the position of the label within the popup.
943 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
945 popup.SetDisplayState( Popup::HIDDEN );
946 application.SendNotification();
947 application.Render();
953 int UtcDaliPopupPropertyBacking(void)
955 ToolkitTestApplication application;
956 tet_infoline( " UtcDaliPopupPropertyBacking" );
958 // Create the Popup actor
959 Popup popup = Popup::New();
960 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
961 Stage::GetCurrent().Add( popup );
963 Actor backing = popup.FindChildByName( "popupBacking" );
964 DALI_TEST_CHECK( backing );
966 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
968 // Check enabled property.
969 popup.SetDisplayState( Popup::SHOWN );
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 popup.SetDisplayState( Popup::HIDDEN );
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
981 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
983 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
984 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
986 popup.SetDisplayState( Popup::SHOWN );
987 application.SendNotification();
988 application.Render();
990 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
992 popup.SetDisplayState( Popup::HIDDEN );
993 application.SendNotification();
994 application.Render();
996 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
998 // Check color property.
999 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1000 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1002 popup.SetDisplayState( Popup::SHOWN );
1003 application.SendNotification();
1004 application.Render();
1006 Vector4 resultColor;
1007 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1008 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1013 int UtcDaliPopupPropertyBackgroundImage(void)
1015 ToolkitTestApplication application;
1016 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1018 // Create the Popup actor
1019 Popup popup = Popup::New();
1020 Stage::GetCurrent().Add( popup );
1022 // Check setting an image
1023 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1024 std::string resultString;
1025 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1026 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1031 int UtcDaliPopupPropertyCustomAnimation(void)
1033 ToolkitTestApplication application;
1034 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1036 // Create the Popup actor
1037 Popup popup = Popup::New();
1038 TextLabel content = TextLabel::New( "text" );
1039 popup.SetContent( content );
1041 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1042 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1044 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1045 DALI_TEST_CHECK( popupContainer );
1047 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1048 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1050 Property::Map animationMapEntry;
1051 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1052 animationMapEntry.Insert( "property", "position" );
1053 animationMapEntry.Insert( "value", entryAnimationDestination );
1054 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1056 Property::Array timePeriodMapEntry;
1057 timePeriodMapEntry.PushBack( 0.0f );
1058 timePeriodMapEntry.PushBack( 1.0f );
1060 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1062 Property::Map animationMapExit;
1063 animationMapExit.Insert( "actor", "customAnimationPopup" );
1064 animationMapExit.Insert( "property", "position" );
1065 animationMapExit.Insert( "value", exitAnimationDestination );
1066 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1068 Property::Array timePeriodMapExit;
1069 timePeriodMapExit.PushBack( 0.0f );
1070 timePeriodMapExit.PushBack( 1.0f );
1072 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1074 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1075 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1077 Property::Map resultMap;
1078 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1079 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1080 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1081 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1083 Stage::GetCurrent().Add( popup );
1084 popup.SetDisplayState( Popup::SHOWN );
1086 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1088 application.SendNotification();
1089 application.Render( RENDER_FRAME_INTERVAL );
1092 // Test the popup has animated to it's entry-transition destination.
1093 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1095 popup.SetDisplayState( Popup::HIDDEN );
1097 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1099 application.SendNotification();
1100 application.Render( RENDER_FRAME_INTERVAL );
1103 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1108 static bool gPushButtonClicked;
1109 static bool PushButtonClicked( Button button )
1111 gPushButtonClicked = true;
1115 int UtcDaliPopupPropertyTouchTransparent(void)
1117 ToolkitTestApplication application;
1118 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1120 // Create the Popup actor
1121 Popup popup = Popup::New();
1122 TextLabel content = TextLabel::New( "text" );
1123 popup.SetContent( content );
1124 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1125 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1126 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1127 popup.SetSize( 100, 100 );
1128 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1130 // Create a button (to go underneath the popup).
1131 PushButton button = Toolkit::PushButton::New();
1132 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1133 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1134 button.SetSize( 100, 100 );
1135 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1137 button.ClickedSignal().Connect( &PushButtonClicked );
1139 Stage::GetCurrent().Add( button );
1141 button.Add( popup );
1143 popup.SetDisplayState( Popup::SHOWN );
1144 application.SendNotification();
1145 application.Render();
1147 gPushButtonClicked = false;
1148 Dali::Integration::TouchEvent event;
1150 // Perform a click, the popup should block the click from hitting the button.
1151 event = Dali::Integration::TouchEvent();
1152 event.AddPoint( GetPointDown() );
1153 application.ProcessEvent( event );
1154 application.SendNotification();
1155 application.Render();
1157 event = Dali::Integration::TouchEvent();
1158 event.AddPoint( GetPointUp() );
1159 application.ProcessEvent( event );
1160 application.SendNotification();
1161 application.Render();
1163 DALI_TEST_CHECK( !gPushButtonClicked );
1165 // Enable touch transparency.
1166 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1167 bool propertyResult;
1168 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1169 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1171 // Perform a click, the popup should allow the click to travel through to the button.
1172 event = Dali::Integration::TouchEvent();
1173 event.AddPoint( GetPointDown() );
1174 application.ProcessEvent( event );
1175 application.SendNotification();
1176 application.Render();
1178 event = Dali::Integration::TouchEvent();
1179 event.AddPoint( GetPointUp() );
1180 application.ProcessEvent( event );
1181 application.SendNotification();
1182 application.Render();
1184 DALI_TEST_CHECK( gPushButtonClicked );
1189 int UtcDaliPopupPropertyTail(void)
1191 ToolkitTestApplication application;
1192 tet_infoline( " UtcDaliPopupPropertyTail" );
1194 // Create the Popup actor
1195 Popup popup = Popup::New();
1196 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1197 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1198 popup.SetSize( 100, 100 );
1199 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1200 TextLabel content = TextLabel::New( "text" );
1201 popup.SetContent( content );
1203 std::string imageFilename = "invalid-image.jpg";
1204 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1205 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1206 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1207 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1209 std::string resultString;
1210 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1211 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1212 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1213 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1214 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1215 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1216 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1217 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1219 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1221 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1222 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1225 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1227 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1228 Vector3 vectorResult;
1229 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1230 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1232 Stage::GetCurrent().Add( popup );
1234 popup.SetDisplayState( Popup::SHOWN );
1235 application.SendNotification();
1236 application.Render();
1237 tailActor = popup.FindChildByName( "tailImage" );
1238 DALI_TEST_CHECK( tailActor );
1240 float baseValX = tailActor.GetCurrentWorldPosition().x;
1242 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1244 popup.SetDisplayState( Popup::HIDDEN );
1245 application.SendNotification();
1246 application.Render();
1248 tailPosition = ParentOrigin::CENTER_LEFT;
1249 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1251 popup.SetDisplayState( Popup::SHOWN );
1252 application.SendNotification();
1253 application.Render();
1254 tailActor = popup.FindChildByName( "tailImage" );
1255 DALI_TEST_CHECK( tailActor );
1257 float baseValY = tailActor.GetCurrentWorldPosition().y;
1258 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1260 popup.SetDisplayState( Popup::HIDDEN );
1261 application.SendNotification();
1262 application.Render();
1264 tailPosition = ParentOrigin::BOTTOM_CENTER;
1265 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1267 popup.SetDisplayState( Popup::SHOWN );
1268 application.SendNotification();
1269 application.Render();
1270 tailActor = popup.FindChildByName( "tailImage" );
1271 DALI_TEST_CHECK( tailActor );
1272 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1273 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1275 popup.SetDisplayState( Popup::HIDDEN );
1276 application.SendNotification();
1277 application.Render();
1279 tailPosition = ParentOrigin::CENTER_RIGHT;
1280 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1282 popup.SetDisplayState( Popup::SHOWN );
1283 application.SendNotification();
1284 application.Render();
1285 tailActor = popup.FindChildByName( "tailImage" );
1286 DALI_TEST_CHECK( tailActor );
1287 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1288 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1290 popup.SetDisplayState( Popup::HIDDEN );
1291 application.SendNotification();
1292 application.Render();
1297 int UtcDaliPopupTypeToast(void)
1299 ToolkitTestApplication application;
1300 tet_infoline( " UtcDaliPopupTypeToast" );
1302 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1303 DALI_TEST_CHECK( typeInfo )
1305 BaseHandle baseHandle = typeInfo.CreateInstance();
1306 DALI_TEST_CHECK( baseHandle )
1308 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1309 gPopupState = Toolkit::Popup::HIDDEN;
1310 ConnectStateSignals( popup );
1311 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1313 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1314 Stage::GetCurrent().Add( popup );
1315 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1317 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1319 application.SendNotification();
1320 application.Render( RENDER_FRAME_INTERVAL );
1323 // Check the toast popup is shown.
1324 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1326 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1328 application.SendNotification();
1329 application.Render( RENDER_FRAME_INTERVAL );
1332 // Check the toast popup hides.
1333 Dali::Timer timer = Timer::New( 0 );
1334 timer.MockEmitSignal();
1336 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1338 application.SendNotification();
1339 application.Render( RENDER_FRAME_INTERVAL );
1342 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1347 int UtcDaliPopupTypeRegistryCreation(void)
1349 ToolkitTestApplication application;
1350 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1352 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1353 DALI_TEST_CHECK( typeInfo )
1355 BaseHandle baseHandle = typeInfo.CreateInstance();
1356 DALI_TEST_CHECK( baseHandle )
1358 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1359 gPopupState = Toolkit::Popup::HIDDEN;
1360 ConnectStateSignals( popup );
1361 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1363 Stage::GetCurrent().Add( popup );
1364 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1366 application.SendNotification();
1367 application.Render();
1369 // Check the popup is shown.
1370 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1375 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1377 ToolkitTestApplication application;
1378 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1380 // Create the Popup actor
1381 Popup popup = Popup::New();
1383 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1384 // Note: The emmision of this signals has already been tested in other tests.
1385 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1386 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1387 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1388 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1389 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1391 // Test connecting to an invalid signal does not work.
1392 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1397 int UtcDaliPopupOnControlChildAdd(void)
1399 ToolkitTestApplication application;
1400 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1402 // Create the Popup actor
1403 Popup popup = Popup::New();
1404 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1405 std::string testLabelText = "ContentTest";
1406 TextLabel contentLabel = TextLabel::New( testLabelText );
1408 popup.Add( contentLabel );
1410 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1415 int UtcDaliPopupOnKeyEvent(void)
1417 ToolkitTestApplication application;
1418 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1420 // Create the Popup actor
1421 Popup popup = Popup::New();
1422 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1423 Stage::GetCurrent().Add( popup );
1425 popup.SetDisplayState( Popup::SHOWN );
1426 application.SendNotification();
1427 application.Render();
1429 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1431 popup.SetKeyInputFocus();
1433 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DevelKeyEvent::DeviceClass::TOUCH ) );
1434 application.SendNotification();
1435 application.Render();
1437 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1442 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1444 ToolkitTestApplication application;
1446 tet_infoline( "Set the background border property of a popup & retrieve it" );
1447 Popup popup = Popup::New();
1449 Rect< int > rect( 40, 30, 20, 10 );
1450 tet_infoline( "Ensure value we want to set is different from what is already set" );
1451 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1453 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1454 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1455 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1457 tet_infoline( "Set a vector4 as well which should also work" );
1458 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1459 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1460 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );