2 * Copyright (c) 2017 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& logicalKey,
178 const std::string& keyString,
181 unsigned long timeStamp,
182 const Integration::KeyEvent::State& keyState,
183 const std::string& compose = "",
184 const std::string& deviceName = "",
185 const Device::Class::Type& deviceClass = Device::Class::NONE,
186 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE
189 return Integration::KeyEvent( keyName,
202 } // Anonymous namespace
205 * This test checks popup creation.
207 int UtcDaliPopupNewP( void )
209 ToolkitTestApplication application;
210 tet_infoline( " UtcDaliPopupNewP" );
212 // Create the Popup actor.
215 DALI_TEST_CHECK( !popup );
217 popup = Popup::New();
219 DALI_TEST_CHECK( popup );
221 Popup popup2( popup );
223 DALI_TEST_CHECK( popup2 == popup );
225 // Additional check to ensure object is created by checking if it's registered.
226 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
227 DALI_TEST_CHECK( registry );
229 gObjectCreatedCallBackCalled = false;
230 registry.ObjectCreatedSignal().Connect( &TestCallback );
232 Popup popup = Popup::New();
234 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
239 * This test checks popup destruction.
241 int UtcDaliPopupDestructorP( void )
243 ToolkitTestApplication application;
244 tet_infoline( " UtcDaliPopupDestructorP" );
246 Popup* popup = new Popup();
249 DALI_TEST_CHECK( true );
253 int UtcDaliPopupDownCastP(void)
255 ToolkitTestApplication application;
256 tet_infoline( " UtcDaliPopupDownCastP" );
258 Handle handle = Popup::New();
260 Popup popup = Popup::DownCast( handle );
262 DALI_TEST_CHECK( popup == handle );
266 int UtcDaliPopupSetPropertyP(void)
268 ToolkitTestApplication application;
269 tet_infoline( " UtcDaliPopupSetProperty" );
271 Popup popup = Popup::New();
274 std::string testString = "Hello World";
276 TextLabel textActorIn = TextLabel::New( testString );
278 Scripting::CreatePropertyMap( textActorIn, map );
279 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
280 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
281 std::string resultText;
282 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
283 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
288 int UtcDaliPopupSetTitleP(void)
290 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
291 tet_infoline( " UtcDaliPopupSetTitleP" );
293 // Create the Popup actor
294 Popup popup = Popup::New();
296 // Put in show state so it's layer is connected to popup (for ancestor check).
297 popup.SetDisplayState( Popup::SHOWN );
299 TextLabel titleActor = TextLabel::New();
300 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
302 DALI_TEST_CHECK( !popup.GetTitle() );
303 popup.SetTitle( titleActor );
304 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
305 DALI_TEST_CHECK( textActor == titleActor );
307 std::string resultText;
308 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
310 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
311 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
312 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
314 TextLabel titleActor2 = TextLabel::New();
315 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
316 popup.SetTitle( titleActor2 );
317 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
318 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
319 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
321 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
323 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
324 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
328 int UtcDaliPopupSetTitleN(void)
330 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
331 tet_infoline( " UtcDaliPopupSetTitleN" );
333 // Create the Popup actor
334 Popup popup = Popup::New();
336 TextLabel titleActor = TextLabel::New( "text" );
337 popup.SetTitle( titleActor );
339 DALI_TEST_CHECK( popup.GetTitle() );
341 // Set a bad title value.
342 // Confirm this has disabled the title.
344 popup.SetTitle( badActor );
346 DALI_TEST_CHECK( !popup.GetTitle() );
351 int UtcDaliPopupSetContentP(void)
353 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
354 tet_infoline( " UtcDaliPopupSetContentP" );
356 // Create the Popup actor
357 Popup popup = Popup::New();
358 Stage::GetCurrent().Add( popup );
359 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
361 // Put in show state so it's layer is connected to popup (for ancestor check).
362 popup.SetDisplayState( Popup::SHOWN );
364 PushButton button = PushButton::New();
365 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
366 popup.SetFooter( button );
367 // Hide and then re-show popup to cause button to be rearranged and added to popup.
368 popup.SetDisplayState( Popup::HIDDEN );
369 popup.SetDisplayState( Popup::SHOWN );
370 DALI_TEST_CHECK( HasAncestor( button, popup ) );
374 int UtcDaliPopupSetContentN(void)
376 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
377 tet_infoline( " UtcDaliPopupSetContentN" );
379 // Create the Popup actor
380 Popup popup = Popup::New();
382 TextLabel content = TextLabel::New( "text" );
383 popup.SetContent( content );
385 DALI_TEST_CHECK( popup.GetContent() );
387 // Set a bad title value.
389 popup.SetContent( badActor );
391 DALI_TEST_CHECK( !popup.GetContent() );
396 int UtcDaliPopupSetFooterP(void)
398 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
399 tet_infoline(" UtcDaliPopupSetFooterP");
401 // Create the Popup actor
402 Popup popup = Popup::New();
403 Stage::GetCurrent().Add( popup );
404 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
405 // Put in show state so it's layer is connected to popup (for ancestor check).
406 popup.SetDisplayState( Popup::SHOWN );
408 PushButton button = PushButton::New();
409 DALI_TEST_CHECK( !HasAncestor(button, popup) );
410 popup.SetFooter( button );
411 // Hide and then re-show popup to cause button to be rearranged and added to popup.
412 popup.SetDisplayState( Popup::HIDDEN );
413 popup.SetDisplayState( Popup::SHOWN );
414 DALI_TEST_CHECK( HasAncestor( button, popup ) );
418 int UtcDaliPopupSetFooterN(void)
420 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
421 tet_infoline(" UtcDaliPopupSetFooterN");
423 // Create the Popup actor
424 Popup popup = Popup::New();
426 PushButton button = PushButton::New();
427 popup.SetFooter( button );
429 DALI_TEST_CHECK( popup.GetFooter() );
431 // Set a bad title value.
433 popup.SetFooter( badActor );
435 DALI_TEST_CHECK( !popup.GetFooter() );
440 int UtcDaliPopupSetControlFooterMultiple(void)
442 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
443 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
445 // Create the Popup actor
446 Popup popup = Popup::New();
447 Stage::GetCurrent().Add( popup );
448 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
449 // Put in show state so it's layer is connected to popup (for ancestor check).
450 popup.SetDisplayState( Popup::SHOWN );
452 Actor container = Actor::New();
453 PushButton button1 = PushButton::New();
454 PushButton button2 = PushButton::New();
455 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
456 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
457 container.Add( button1 );
458 container.Add( button2 );
459 popup.SetFooter( container );
461 // Hide and then re-show popup to cause button to be rearranged and added to popup.
462 popup.SetDisplayState( Popup::HIDDEN );
463 popup.SetDisplayState( Popup::SHOWN );
464 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
465 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
469 int UtcDaliPopupSetStateP(void)
471 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
472 tet_infoline(" UtcDaliPopupSetStateP");
474 // Create the Popup actor
475 Popup popup = Popup::New();
477 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
479 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
481 popup.SetDisplayState( Popup::SHOWN );
482 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
484 popup.SetDisplayState( Popup::HIDDEN );
485 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
489 int UtcDaliPopupSetStateN(void)
491 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
492 tet_infoline(" UtcDaliPopupSetStateN");
494 // Create the Popup actor
495 Popup popup = Popup::New();
497 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
499 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
501 popup.SetDisplayState( Popup::SHOWN );
502 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
504 // Test cancelling a show before it has finished.
505 popup.SetDisplayState( Popup::HIDDEN );
506 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
510 int UtcDaliPopupDisplayStateSignal(void)
512 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
513 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
515 // Create the Popup actor
516 Popup popup = Popup::New();
517 ConnectStateSignals( popup );
519 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
520 popup.SetDisplayState( Popup::SHOWN );
521 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
522 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
524 // Wait for a while (allow animation to complete), and then check state.
525 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
527 application.SendNotification();
528 application.Render( RENDER_FRAME_INTERVAL );
531 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
532 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
535 popup.SetDisplayState( Popup::HIDDEN );
536 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
537 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
539 // Wait for a while (allow animation to complete), and then check state.
540 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
542 application.SendNotification();
543 application.Render( RENDER_FRAME_INTERVAL );
546 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
547 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
552 int UtcDaliPopupShowHide(void)
554 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
555 tet_infoline(" UtcDaliPopupShowHide");
557 // Create the Popup actor
558 Popup popup = Popup::New();
559 ConnectStateSignals( popup );
561 Actor container = Actor::New();
562 PushButton button1 = PushButton::New();
563 PushButton button2 = PushButton::New();
564 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
565 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
566 container.Add( button1 );
567 container.Add( button2 );
568 popup.SetFooter( container );
571 // Note: in most popup animation implementations show would result in
572 // popup being onstage immediately following Show(). However we can't
573 // assume for all. e.g. If one creates a animation with a delay.
574 popup.SetDisplayState( Popup::SHOWN );
576 // Wait for a while (allow animation to complete), and then check state.
577 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
579 application.SendNotification();
580 application.Render( RENDER_FRAME_INTERVAL );
584 popup.SetDisplayState( Popup::HIDDEN );
586 // Wait for a while (allow animation to complete), and then check state.
587 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
589 application.SendNotification();
590 application.Render(RENDER_FRAME_INTERVAL);
593 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
597 int UtcDaliPopupPropertyTailVisibility(void)
599 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
600 tet_infoline(" UtcDaliPopupShowHideTail");
602 // Create the Popup actor
603 Popup popup = Popup::New();
604 Stage::GetCurrent().Add( popup );
606 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
607 popup.SetDisplayState( Popup::SHOWN );
609 int withoutTailCount = DescendentCount( popup );
611 popup.SetDisplayState( Popup::HIDDEN );
613 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
614 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
615 popup.SetDisplayState( Popup::SHOWN );
617 int withTailCount = DescendentCount( popup );
619 // There should be more actors if the Tail has been added.
620 DALI_TEST_CHECK( withTailCount > withoutTailCount );
623 popup.SetDisplayState( Popup::HIDDEN );
624 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
625 popup.SetDisplayState( Popup::SHOWN );
626 int withoutTailCount2 = DescendentCount(popup);
628 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
632 int UtcDaliPopupOnTouchedOutsideSignal(void)
634 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
635 tet_infoline(" UtcDaliPopupOnTouchedOutside");
637 // Create the Popup actor
638 Popup popup = Popup::New();
639 popup.SetParentOrigin( ParentOrigin::CENTER );
640 popup.SetAnchorPoint( ParentOrigin::CENTER );
641 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
642 popup.SetSize( 50.0f, 50.0f );
643 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
644 Stage::GetCurrent().Add( popup );
645 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
646 popup.SetDisplayState( Popup::SHOWN );
648 application.SendNotification();
649 application.Render();
651 gTouchedOutside = false;
652 Dali::Integration::TouchEvent event;
654 event = Dali::Integration::TouchEvent();
655 event.AddPoint( GetPointDown() );
656 application.ProcessEvent( event );
658 application.SendNotification();
659 application.Render();
661 event = Dali::Integration::TouchEvent();
662 event.AddPoint( GetPointUp() );
663 application.ProcessEvent( event );
665 application.SendNotification();
666 application.Render();
668 // Confirm the signal is ignored if touch_transparent.
669 gTouchedOutside = false;
670 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
672 event = Dali::Integration::TouchEvent();
673 event.AddPoint( GetPointDown() );
674 application.ProcessEvent( event );
676 application.SendNotification();
677 application.Render();
679 event = Dali::Integration::TouchEvent();
680 event.AddPoint( GetPointUp() );
681 application.ProcessEvent( event );
683 application.SendNotification();
684 application.Render();
686 DALI_TEST_CHECK( !gTouchedOutside );
691 int UtcDaliPopupPropertyAutoHide(void)
693 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
694 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
696 // Create the Popup actor
697 Popup popup = Popup::New();
698 ConnectStateSignals( popup );
700 Actor container = Actor::New();
701 PushButton button1 = PushButton::New();
702 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
703 container.Add( button1 );
704 popup.SetFooter( container );
706 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
707 float getAnimationDuration = 0.0f;
708 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
709 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
711 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
712 int getAutoHideDelay = 0;
713 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
714 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
716 Stage::GetCurrent().Add( popup );
718 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
721 // Note: in most popup animation implementations show would result in
722 // popup being onstage immediately following Show(). However we can't
723 // assume for all. e.g. If one creates a animation with a delay.
724 popup.SetDisplayState( Popup::SHOWN );
726 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
728 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
730 application.SendNotification();
731 application.Render( RENDER_FRAME_INTERVAL );
734 // Force the timer used by the popup to expire,
735 // this will cause the popup to hide automatically.
736 Dali::Timer timer = Timer::New( 0 );
737 timer.MockEmitSignal();
739 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
745 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
747 int UtcDaliPopupPropertyAnimationMode(void)
749 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
750 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
752 // Create the Popup actor
753 Popup popup = Popup::New();
754 ConnectStateSignals( popup );
755 popup.SetTitle( TextLabel::New( "Title" ) );
756 Stage::GetCurrent().Add( popup );
758 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
760 // Try both default and zero animation duration, as zero has a special case for some animation types.
761 for( int j = 0; j <= 1; j++ )
763 // On the second loop, set duration to zero.
766 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
769 // Loop through 4 animation modes.
770 for( int i = 0; i < 4; i++ )
772 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
774 std::string checkMode;
775 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
777 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
779 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
780 std::string resultState;
782 // Only wait for animation if it isn't instant.
785 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
786 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
787 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
788 WaitAnimation( application );
791 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
792 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
793 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
794 popup.SetDisplayState( Popup::HIDDEN );
798 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
799 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
800 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
801 WaitAnimation( application );
804 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
805 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
806 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
813 int UtcDaliPopupPropertyTitle(void)
815 ToolkitTestApplication application;
816 tet_infoline( " UtcDaliPopupPropertyTitle" );
818 // Create the Popup actor
819 Popup popup = Popup::New();
821 std::string testLabelText = "TitleTest";
822 TextLabel titleLabel = TextLabel::New();
823 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
824 Actor title = titleLabel;
826 Scripting::CreatePropertyMap( title, map );
827 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
829 Property::Map resultMap;
830 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
832 Property::Value* resultProperty = resultMap.Find( "text" );
833 DALI_TEST_CHECK( resultProperty );
835 std::string resultText;
836 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
838 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
843 int UtcDaliPopupPropertyContent(void)
845 ToolkitTestApplication application;
846 tet_infoline( " UtcDaliPopupPropertyContent" );
848 // Create the Popup actor
849 Popup popup = Popup::New();
851 std::string testLabelText = "ContentTest";
852 TextLabel contentLabel = TextLabel::New();
853 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
854 Actor content = contentLabel;
856 Scripting::CreatePropertyMap( content, map );
857 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
859 Property::Map resultMap;
860 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
862 Property::Value* resultProperty = resultMap.Find( "text" );
863 DALI_TEST_CHECK( resultProperty );
865 std::string resultText;
866 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
868 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
873 int UtcDaliPopupPropertyFooter(void)
875 ToolkitTestApplication application;
876 tet_infoline( " UtcDaliPopupPropertyFooter" );
878 // Create the Popup actor
879 Popup popup = Popup::New();
881 std::string testLabelText = "FooterTest";
882 TextLabel footerLabel = TextLabel::New();
883 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
884 Actor footer = footerLabel;
886 Scripting::CreatePropertyMap( footer, map );
887 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
889 Property::Map resultMap;
890 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
892 Property::Value* resultProperty = resultMap.Find( "text" );
893 DALI_TEST_CHECK( resultProperty );
895 std::string resultText;
896 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
898 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
903 int UtcDaliPopupPropertyContextualMode(void)
905 ToolkitTestApplication application;
906 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
908 // Create the Popup actor
909 Popup popup = Popup::New();
910 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
911 std::string testLabelText = "ContentTest";
913 TextLabel contentLabel = TextLabel::New();
915 popup.SetContent( contentLabel );
917 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
918 Actor placement = Actor::New();
919 placement.SetParentOrigin( ParentOrigin::CENTER );
920 placement.SetAnchorPoint( AnchorPoint::CENTER );
921 placement.SetSize( 1.0f, 1.0f );
922 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
923 Stage::GetCurrent().Add( placement );
925 placement.Add( popup );
927 // Test all contextual modes.
928 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
929 Vector2 offsetValues[5];
930 offsetValues[0] = Vector2( 0.375f, 0.0f );
931 offsetValues[1] = Vector2( -0.125f, -10.5f );
932 offsetValues[2] = Vector2( 10.875f, -0.5f );
933 offsetValues[3] = Vector2( -0.125f, 10.5f );
934 offsetValues[4] = Vector2( -10.875f, -0.5f );
936 for( int i = 0; i < 5; ++i )
938 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
940 std::string propertyResult;
941 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
942 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
944 popup.SetDisplayState( Popup::SHOWN );
945 application.SendNotification();
946 application.Render();
948 // Check the position of the label within the popup.
949 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
951 popup.SetDisplayState( Popup::HIDDEN );
952 application.SendNotification();
953 application.Render();
959 int UtcDaliPopupPropertyBacking(void)
961 ToolkitTestApplication application;
962 tet_infoline( " UtcDaliPopupPropertyBacking" );
964 // Create the Popup actor
965 Popup popup = Popup::New();
966 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
967 Stage::GetCurrent().Add( popup );
969 Actor backing = popup.FindChildByName( "popupBacking" );
970 DALI_TEST_CHECK( backing );
972 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
974 // Check enabled property.
975 popup.SetDisplayState( Popup::SHOWN );
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
981 popup.SetDisplayState( Popup::HIDDEN );
982 application.SendNotification();
983 application.Render();
985 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
987 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
989 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
990 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
992 popup.SetDisplayState( Popup::SHOWN );
993 application.SendNotification();
994 application.Render();
996 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
998 popup.SetDisplayState( Popup::HIDDEN );
999 application.SendNotification();
1000 application.Render();
1002 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1004 // Check color property.
1005 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1006 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1008 popup.SetDisplayState( Popup::SHOWN );
1009 application.SendNotification();
1010 application.Render();
1012 Vector4 resultColor;
1013 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1014 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1019 int UtcDaliPopupPropertyBackgroundImage(void)
1021 ToolkitTestApplication application;
1022 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1024 // Create the Popup actor
1025 Popup popup = Popup::New();
1026 Stage::GetCurrent().Add( popup );
1028 // Check setting an image
1029 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1030 std::string resultString;
1031 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1032 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1037 int UtcDaliPopupPropertyCustomAnimation(void)
1039 ToolkitTestApplication application;
1040 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1042 // Create the Popup actor
1043 Popup popup = Popup::New();
1044 TextLabel content = TextLabel::New( "text" );
1045 popup.SetContent( content );
1047 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1048 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1050 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1051 DALI_TEST_CHECK( popupContainer );
1053 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1054 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1056 Property::Map animationMapEntry;
1057 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1058 animationMapEntry.Insert( "property", "position" );
1059 animationMapEntry.Insert( "value", entryAnimationDestination );
1060 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1062 Property::Array timePeriodMapEntry;
1063 timePeriodMapEntry.PushBack( 0.0f );
1064 timePeriodMapEntry.PushBack( 1.0f );
1066 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1068 Property::Map animationMapExit;
1069 animationMapExit.Insert( "actor", "customAnimationPopup" );
1070 animationMapExit.Insert( "property", "position" );
1071 animationMapExit.Insert( "value", exitAnimationDestination );
1072 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1074 Property::Array timePeriodMapExit;
1075 timePeriodMapExit.PushBack( 0.0f );
1076 timePeriodMapExit.PushBack( 1.0f );
1078 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1080 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1081 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1083 Property::Map resultMap;
1084 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1085 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1086 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1087 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1089 Stage::GetCurrent().Add( popup );
1090 popup.SetDisplayState( Popup::SHOWN );
1092 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1094 application.SendNotification();
1095 application.Render( RENDER_FRAME_INTERVAL );
1098 // Test the popup has animated to it's entry-transition destination.
1099 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1101 popup.SetDisplayState( Popup::HIDDEN );
1103 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1105 application.SendNotification();
1106 application.Render( RENDER_FRAME_INTERVAL );
1109 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1114 static bool gPushButtonClicked;
1115 static bool PushButtonClicked( Button button )
1117 gPushButtonClicked = true;
1121 int UtcDaliPopupPropertyTouchTransparent(void)
1123 ToolkitTestApplication application;
1124 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1126 // Create the Popup actor
1127 Popup popup = Popup::New();
1128 TextLabel content = TextLabel::New( "text" );
1129 popup.SetContent( content );
1130 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1131 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1132 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1133 popup.SetSize( 100, 100 );
1134 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1136 // Create a button (to go underneath the popup).
1137 PushButton button = Toolkit::PushButton::New();
1138 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1139 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1140 button.SetSize( 100, 100 );
1141 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1143 button.ClickedSignal().Connect( &PushButtonClicked );
1145 Stage::GetCurrent().Add( button );
1147 button.Add( popup );
1149 popup.SetDisplayState( Popup::SHOWN );
1150 application.SendNotification();
1151 application.Render();
1153 gPushButtonClicked = false;
1154 Dali::Integration::TouchEvent event;
1156 // Perform a click, the popup should block the click from hitting the button.
1157 event = Dali::Integration::TouchEvent();
1158 event.AddPoint( GetPointDown() );
1159 application.ProcessEvent( event );
1160 application.SendNotification();
1161 application.Render();
1163 event = Dali::Integration::TouchEvent();
1164 event.AddPoint( GetPointUp() );
1165 application.ProcessEvent( event );
1166 application.SendNotification();
1167 application.Render();
1169 DALI_TEST_CHECK( !gPushButtonClicked );
1171 // Enable touch transparency.
1172 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1173 bool propertyResult;
1174 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1175 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1177 // Perform a click, the popup should allow the click to travel through to the button.
1178 event = Dali::Integration::TouchEvent();
1179 event.AddPoint( GetPointDown() );
1180 application.ProcessEvent( event );
1181 application.SendNotification();
1182 application.Render();
1184 event = Dali::Integration::TouchEvent();
1185 event.AddPoint( GetPointUp() );
1186 application.ProcessEvent( event );
1187 application.SendNotification();
1188 application.Render();
1190 DALI_TEST_CHECK( gPushButtonClicked );
1195 int UtcDaliPopupPropertyTail(void)
1197 ToolkitTestApplication application;
1198 tet_infoline( " UtcDaliPopupPropertyTail" );
1200 // Create the Popup actor
1201 Popup popup = Popup::New();
1202 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1203 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1204 popup.SetSize( 100, 100 );
1205 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1206 TextLabel content = TextLabel::New( "text" );
1207 popup.SetContent( content );
1209 std::string imageFilename = "invalid-image.jpg";
1210 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1211 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1212 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1213 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1215 std::string resultString;
1216 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1217 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1218 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1219 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1220 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1221 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1222 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1223 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1225 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1227 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1228 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1231 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1233 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1234 Vector3 vectorResult;
1235 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1236 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1238 Stage::GetCurrent().Add( popup );
1240 popup.SetDisplayState( Popup::SHOWN );
1241 application.SendNotification();
1242 application.Render();
1243 tailActor = popup.FindChildByName( "tailImage" );
1244 DALI_TEST_CHECK( tailActor );
1246 float baseValX = tailActor.GetCurrentWorldPosition().x;
1248 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1250 popup.SetDisplayState( Popup::HIDDEN );
1251 application.SendNotification();
1252 application.Render();
1254 tailPosition = ParentOrigin::CENTER_LEFT;
1255 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1257 popup.SetDisplayState( Popup::SHOWN );
1258 application.SendNotification();
1259 application.Render();
1260 tailActor = popup.FindChildByName( "tailImage" );
1261 DALI_TEST_CHECK( tailActor );
1263 float baseValY = tailActor.GetCurrentWorldPosition().y;
1264 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1266 popup.SetDisplayState( Popup::HIDDEN );
1267 application.SendNotification();
1268 application.Render();
1270 tailPosition = ParentOrigin::BOTTOM_CENTER;
1271 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1273 popup.SetDisplayState( Popup::SHOWN );
1274 application.SendNotification();
1275 application.Render();
1276 tailActor = popup.FindChildByName( "tailImage" );
1277 DALI_TEST_CHECK( tailActor );
1278 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1279 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1281 popup.SetDisplayState( Popup::HIDDEN );
1282 application.SendNotification();
1283 application.Render();
1285 tailPosition = ParentOrigin::CENTER_RIGHT;
1286 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1288 popup.SetDisplayState( Popup::SHOWN );
1289 application.SendNotification();
1290 application.Render();
1291 tailActor = popup.FindChildByName( "tailImage" );
1292 DALI_TEST_CHECK( tailActor );
1293 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1294 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1296 popup.SetDisplayState( Popup::HIDDEN );
1297 application.SendNotification();
1298 application.Render();
1303 int UtcDaliPopupTypeToast(void)
1305 ToolkitTestApplication application;
1306 tet_infoline( " UtcDaliPopupTypeToast" );
1308 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1309 DALI_TEST_CHECK( typeInfo )
1311 BaseHandle baseHandle = typeInfo.CreateInstance();
1312 DALI_TEST_CHECK( baseHandle )
1314 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1315 gPopupState = Toolkit::Popup::HIDDEN;
1316 ConnectStateSignals( popup );
1317 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1319 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1320 Stage::GetCurrent().Add( popup );
1321 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1323 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1325 application.SendNotification();
1326 application.Render( RENDER_FRAME_INTERVAL );
1329 // Check the toast popup is shown.
1330 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1332 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1334 application.SendNotification();
1335 application.Render( RENDER_FRAME_INTERVAL );
1338 // Check the toast popup hides.
1339 Dali::Timer timer = Timer::New( 0 );
1340 timer.MockEmitSignal();
1342 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1344 application.SendNotification();
1345 application.Render( RENDER_FRAME_INTERVAL );
1348 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1353 int UtcDaliPopupTypeRegistryCreation(void)
1355 ToolkitTestApplication application;
1356 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1358 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1359 DALI_TEST_CHECK( typeInfo )
1361 BaseHandle baseHandle = typeInfo.CreateInstance();
1362 DALI_TEST_CHECK( baseHandle )
1364 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1365 gPopupState = Toolkit::Popup::HIDDEN;
1366 ConnectStateSignals( popup );
1367 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1369 Stage::GetCurrent().Add( popup );
1370 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1372 application.SendNotification();
1373 application.Render();
1375 // Check the popup is shown.
1376 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1381 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1383 ToolkitTestApplication application;
1384 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1386 // Create the Popup actor
1387 Popup popup = Popup::New();
1389 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1390 // Note: The emmision of this signals has already been tested in other tests.
1391 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1392 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1393 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1394 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1395 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1397 // Test connecting to an invalid signal does not work.
1398 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1403 int UtcDaliPopupOnControlChildAdd(void)
1405 ToolkitTestApplication application;
1406 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1408 // Create the Popup actor
1409 Popup popup = Popup::New();
1410 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1411 std::string testLabelText = "ContentTest";
1412 TextLabel contentLabel = TextLabel::New( testLabelText );
1414 popup.Add( contentLabel );
1416 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1421 int UtcDaliPopupOnKeyEvent(void)
1423 ToolkitTestApplication application;
1424 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1426 // Create the Popup actor
1427 Popup popup = Popup::New();
1428 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1429 Stage::GetCurrent().Add( popup );
1431 popup.SetDisplayState( Popup::SHOWN );
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1437 popup.SetKeyInputFocus();
1439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1448 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1450 ToolkitTestApplication application;
1452 tet_infoline( "Set the background border property of a popup & retrieve it" );
1453 Popup popup = Popup::New();
1455 Rect< int > rect( 40, 30, 20, 10 );
1456 tet_infoline( "Ensure value we want to set is different from what is already set" );
1457 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1459 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1460 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1461 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1463 tet_infoline( "Set a vector4 as well which should also work" );
1464 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1465 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1466 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );