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 DevelDevice::Class::Type& deviceClass = DevelDevice::Class::NONE,
184 const DevelDevice::Subclass::Type& deviceSubclass = DevelDevice::Subclass::NONE
187 return Integration::KeyEvent( keyName,
198 } // Anonymous namespace
201 * This test checks popup creation.
203 int UtcDaliPopupNewP( void )
205 ToolkitTestApplication application;
206 tet_infoline( " UtcDaliPopupNewP" );
208 // Create the Popup actor.
211 DALI_TEST_CHECK( !popup );
213 popup = Popup::New();
215 DALI_TEST_CHECK( popup );
217 Popup popup2( popup );
219 DALI_TEST_CHECK( popup2 == popup );
221 // Additional check to ensure object is created by checking if it's registered.
222 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
223 DALI_TEST_CHECK( registry );
225 gObjectCreatedCallBackCalled = false;
226 registry.ObjectCreatedSignal().Connect( &TestCallback );
228 Popup popup = Popup::New();
230 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
235 * This test checks popup destruction.
237 int UtcDaliPopupDestructorP( void )
239 ToolkitTestApplication application;
240 tet_infoline( " UtcDaliPopupDestructorP" );
242 Popup* popup = new Popup();
245 DALI_TEST_CHECK( true );
249 int UtcDaliPopupDownCastP(void)
251 ToolkitTestApplication application;
252 tet_infoline( " UtcDaliPopupDownCastP" );
254 Handle handle = Popup::New();
256 Popup popup = Popup::DownCast( handle );
258 DALI_TEST_CHECK( popup == handle );
262 int UtcDaliPopupSetPropertyP(void)
264 ToolkitTestApplication application;
265 tet_infoline( " UtcDaliPopupSetProperty" );
267 Popup popup = Popup::New();
270 std::string testString = "Hello World";
272 TextLabel textActorIn = TextLabel::New( testString );
274 Scripting::CreatePropertyMap( textActorIn, map );
275 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
276 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
277 std::string resultText;
278 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
279 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
284 int UtcDaliPopupSetTitleP(void)
286 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
287 tet_infoline( " UtcDaliPopupSetTitleP" );
289 // Create the Popup actor
290 Popup popup = Popup::New();
292 // Put in show state so it's layer is connected to popup (for ancestor check).
293 popup.SetDisplayState( Popup::SHOWN );
295 TextLabel titleActor = TextLabel::New();
296 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
298 DALI_TEST_CHECK( !popup.GetTitle() );
299 popup.SetTitle( titleActor );
300 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
301 DALI_TEST_CHECK( textActor == titleActor );
303 std::string resultText;
304 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
306 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
307 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
308 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
310 TextLabel titleActor2 = TextLabel::New();
311 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
312 popup.SetTitle( titleActor2 );
313 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
314 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
315 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
317 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
319 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
320 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
324 int UtcDaliPopupSetTitleN(void)
326 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
327 tet_infoline( " UtcDaliPopupSetTitleN" );
329 // Create the Popup actor
330 Popup popup = Popup::New();
332 TextLabel titleActor = TextLabel::New( "text" );
333 popup.SetTitle( titleActor );
335 DALI_TEST_CHECK( popup.GetTitle() );
337 // Set a bad title value.
338 // Confirm this has disabled the title.
340 popup.SetTitle( badActor );
342 DALI_TEST_CHECK( !popup.GetTitle() );
347 int UtcDaliPopupSetContentP(void)
349 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
350 tet_infoline( " UtcDaliPopupSetContentP" );
352 // Create the Popup actor
353 Popup popup = Popup::New();
354 Stage::GetCurrent().Add( popup );
355 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
357 // Put in show state so it's layer is connected to popup (for ancestor check).
358 popup.SetDisplayState( Popup::SHOWN );
360 PushButton button = PushButton::New();
361 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
362 popup.SetFooter( button );
363 // Hide and then re-show popup to cause button to be rearranged and added to popup.
364 popup.SetDisplayState( Popup::HIDDEN );
365 popup.SetDisplayState( Popup::SHOWN );
366 DALI_TEST_CHECK( HasAncestor( button, popup ) );
370 int UtcDaliPopupSetContentN(void)
372 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
373 tet_infoline( " UtcDaliPopupSetContentN" );
375 // Create the Popup actor
376 Popup popup = Popup::New();
378 TextLabel content = TextLabel::New( "text" );
379 popup.SetContent( content );
381 DALI_TEST_CHECK( popup.GetContent() );
383 // Set a bad title value.
385 popup.SetContent( badActor );
387 DALI_TEST_CHECK( !popup.GetContent() );
392 int UtcDaliPopupSetFooterP(void)
394 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
395 tet_infoline(" UtcDaliPopupSetFooterP");
397 // Create the Popup actor
398 Popup popup = Popup::New();
399 Stage::GetCurrent().Add( popup );
400 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
401 // Put in show state so it's layer is connected to popup (for ancestor check).
402 popup.SetDisplayState( Popup::SHOWN );
404 PushButton button = PushButton::New();
405 DALI_TEST_CHECK( !HasAncestor(button, popup) );
406 popup.SetFooter( button );
407 // Hide and then re-show popup to cause button to be rearranged and added to popup.
408 popup.SetDisplayState( Popup::HIDDEN );
409 popup.SetDisplayState( Popup::SHOWN );
410 DALI_TEST_CHECK( HasAncestor( button, popup ) );
414 int UtcDaliPopupSetFooterN(void)
416 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
417 tet_infoline(" UtcDaliPopupSetFooterN");
419 // Create the Popup actor
420 Popup popup = Popup::New();
422 PushButton button = PushButton::New();
423 popup.SetFooter( button );
425 DALI_TEST_CHECK( popup.GetFooter() );
427 // Set a bad title value.
429 popup.SetFooter( badActor );
431 DALI_TEST_CHECK( !popup.GetFooter() );
436 int UtcDaliPopupSetControlFooterMultiple(void)
438 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
439 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
441 // Create the Popup actor
442 Popup popup = Popup::New();
443 Stage::GetCurrent().Add( popup );
444 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
445 // Put in show state so it's layer is connected to popup (for ancestor check).
446 popup.SetDisplayState( Popup::SHOWN );
448 Actor container = Actor::New();
449 PushButton button1 = PushButton::New();
450 PushButton button2 = PushButton::New();
451 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
452 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
453 container.Add( button1 );
454 container.Add( button2 );
455 popup.SetFooter( container );
457 // Hide and then re-show popup to cause button to be rearranged and added to popup.
458 popup.SetDisplayState( Popup::HIDDEN );
459 popup.SetDisplayState( Popup::SHOWN );
460 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
461 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
465 int UtcDaliPopupSetStateP(void)
467 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
468 tet_infoline(" UtcDaliPopupSetStateP");
470 // Create the Popup actor
471 Popup popup = Popup::New();
473 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
475 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
477 popup.SetDisplayState( Popup::SHOWN );
478 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
480 popup.SetDisplayState( Popup::HIDDEN );
481 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
485 int UtcDaliPopupSetStateN(void)
487 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
488 tet_infoline(" UtcDaliPopupSetStateN");
490 // Create the Popup actor
491 Popup popup = Popup::New();
493 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
495 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
497 popup.SetDisplayState( Popup::SHOWN );
498 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
500 // Test cancelling a show before it has finished.
501 popup.SetDisplayState( Popup::HIDDEN );
502 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
506 int UtcDaliPopupDisplayStateSignal(void)
508 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
509 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
511 // Create the Popup actor
512 Popup popup = Popup::New();
513 ConnectStateSignals( popup );
515 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
516 popup.SetDisplayState( Popup::SHOWN );
517 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
518 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
520 // Wait for a while (allow animation to complete), and then check state.
521 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
523 application.SendNotification();
524 application.Render( RENDER_FRAME_INTERVAL );
527 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
528 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
531 popup.SetDisplayState( Popup::HIDDEN );
532 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
533 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
535 // Wait for a while (allow animation to complete), and then check state.
536 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
538 application.SendNotification();
539 application.Render( RENDER_FRAME_INTERVAL );
542 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
543 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
548 int UtcDaliPopupShowHide(void)
550 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
551 tet_infoline(" UtcDaliPopupShowHide");
553 // Create the Popup actor
554 Popup popup = Popup::New();
555 ConnectStateSignals( popup );
557 Actor container = Actor::New();
558 PushButton button1 = PushButton::New();
559 PushButton button2 = PushButton::New();
560 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
561 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
562 container.Add( button1 );
563 container.Add( button2 );
564 popup.SetFooter( container );
567 // Note: in most popup animation implementations show would result in
568 // popup being onstage immediately following Show(). However we can't
569 // assume for all. e.g. If one creates a animation with a delay.
570 popup.SetDisplayState( Popup::SHOWN );
572 // Wait for a while (allow animation to complete), and then check state.
573 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
575 application.SendNotification();
576 application.Render( RENDER_FRAME_INTERVAL );
580 popup.SetDisplayState( Popup::HIDDEN );
582 // Wait for a while (allow animation to complete), and then check state.
583 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
585 application.SendNotification();
586 application.Render(RENDER_FRAME_INTERVAL);
589 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
593 int UtcDaliPopupPropertyTailVisibility(void)
595 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
596 tet_infoline(" UtcDaliPopupShowHideTail");
598 // Create the Popup actor
599 Popup popup = Popup::New();
600 Stage::GetCurrent().Add( popup );
602 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
603 popup.SetDisplayState( Popup::SHOWN );
605 int withoutTailCount = DescendentCount( popup );
607 popup.SetDisplayState( Popup::HIDDEN );
609 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
610 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
611 popup.SetDisplayState( Popup::SHOWN );
613 int withTailCount = DescendentCount( popup );
615 // There should be more actors if the Tail has been added.
616 DALI_TEST_CHECK( withTailCount > withoutTailCount );
619 popup.SetDisplayState( Popup::HIDDEN );
620 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
621 popup.SetDisplayState( Popup::SHOWN );
622 int withoutTailCount2 = DescendentCount(popup);
624 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
628 int UtcDaliPopupOnTouchedOutsideSignal(void)
630 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
631 tet_infoline(" UtcDaliPopupOnTouchedOutside");
633 // Create the Popup actor
634 Popup popup = Popup::New();
635 popup.SetParentOrigin( ParentOrigin::CENTER );
636 popup.SetAnchorPoint( ParentOrigin::CENTER );
637 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
638 popup.SetSize( 50.0f, 50.0f );
639 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
640 Stage::GetCurrent().Add( popup );
641 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
642 popup.SetDisplayState( Popup::SHOWN );
644 application.SendNotification();
645 application.Render();
647 gTouchedOutside = false;
648 Dali::Integration::TouchEvent event;
650 event = Dali::Integration::TouchEvent();
651 event.AddPoint( GetPointDown() );
652 application.ProcessEvent( event );
654 application.SendNotification();
655 application.Render();
657 event = Dali::Integration::TouchEvent();
658 event.AddPoint( GetPointUp() );
659 application.ProcessEvent( event );
661 application.SendNotification();
662 application.Render();
664 // Confirm the signal is ignored if touch_transparent.
665 gTouchedOutside = false;
666 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
668 event = Dali::Integration::TouchEvent();
669 event.AddPoint( GetPointDown() );
670 application.ProcessEvent( event );
672 application.SendNotification();
673 application.Render();
675 event = Dali::Integration::TouchEvent();
676 event.AddPoint( GetPointUp() );
677 application.ProcessEvent( event );
679 application.SendNotification();
680 application.Render();
682 DALI_TEST_CHECK( !gTouchedOutside );
687 int UtcDaliPopupPropertyAutoHide(void)
689 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
690 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
692 // Create the Popup actor
693 Popup popup = Popup::New();
694 ConnectStateSignals( popup );
696 Actor container = Actor::New();
697 PushButton button1 = PushButton::New();
698 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
699 container.Add( button1 );
700 popup.SetFooter( container );
702 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
703 float getAnimationDuration = 0.0f;
704 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
705 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
707 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
708 int getAutoHideDelay = 0;
709 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
710 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
712 Stage::GetCurrent().Add( popup );
714 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
717 // Note: in most popup animation implementations show would result in
718 // popup being onstage immediately following Show(). However we can't
719 // assume for all. e.g. If one creates a animation with a delay.
720 popup.SetDisplayState( Popup::SHOWN );
722 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
724 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
726 application.SendNotification();
727 application.Render( RENDER_FRAME_INTERVAL );
730 // Force the timer used by the popup to expire,
731 // this will cause the popup to hide automatically.
732 Dali::Timer timer = Timer::New( 0 );
733 timer.MockEmitSignal();
735 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
741 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
743 int UtcDaliPopupPropertyAnimationMode(void)
745 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
746 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
748 // Create the Popup actor
749 Popup popup = Popup::New();
750 ConnectStateSignals( popup );
751 popup.SetTitle( TextLabel::New( "Title" ) );
752 Stage::GetCurrent().Add( popup );
754 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
756 // Try both default and zero animation duration, as zero has a special case for some animation types.
757 for( int j = 0; j <= 1; j++ )
759 // On the second loop, set duration to zero.
762 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
765 // Loop through 4 animation modes.
766 for( int i = 0; i < 4; i++ )
768 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
770 std::string checkMode;
771 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
773 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
775 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
776 std::string resultState;
778 // Only wait for animation if it isn't instant.
781 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
782 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
783 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
784 WaitAnimation( application );
787 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
788 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
789 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
790 popup.SetDisplayState( Popup::HIDDEN );
794 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
795 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
796 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
797 WaitAnimation( application );
800 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
801 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
802 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
809 int UtcDaliPopupPropertyTitle(void)
811 ToolkitTestApplication application;
812 tet_infoline( " UtcDaliPopupPropertyTitle" );
814 // Create the Popup actor
815 Popup popup = Popup::New();
817 std::string testLabelText = "TitleTest";
818 TextLabel titleLabel = TextLabel::New();
819 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
820 Actor title = titleLabel;
822 Scripting::CreatePropertyMap( title, map );
823 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
825 Property::Map resultMap;
826 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
828 Property::Value* resultProperty = resultMap.Find( "text" );
829 DALI_TEST_CHECK( resultProperty );
831 std::string resultText;
832 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
834 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
839 int UtcDaliPopupPropertyContent(void)
841 ToolkitTestApplication application;
842 tet_infoline( " UtcDaliPopupPropertyContent" );
844 // Create the Popup actor
845 Popup popup = Popup::New();
847 std::string testLabelText = "ContentTest";
848 TextLabel contentLabel = TextLabel::New();
849 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
850 Actor content = contentLabel;
852 Scripting::CreatePropertyMap( content, map );
853 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
855 Property::Map resultMap;
856 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
858 Property::Value* resultProperty = resultMap.Find( "text" );
859 DALI_TEST_CHECK( resultProperty );
861 std::string resultText;
862 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
864 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
869 int UtcDaliPopupPropertyFooter(void)
871 ToolkitTestApplication application;
872 tet_infoline( " UtcDaliPopupPropertyFooter" );
874 // Create the Popup actor
875 Popup popup = Popup::New();
877 std::string testLabelText = "FooterTest";
878 TextLabel footerLabel = TextLabel::New();
879 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
880 Actor footer = footerLabel;
882 Scripting::CreatePropertyMap( footer, map );
883 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
885 Property::Map resultMap;
886 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
888 Property::Value* resultProperty = resultMap.Find( "text" );
889 DALI_TEST_CHECK( resultProperty );
891 std::string resultText;
892 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
894 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
899 int UtcDaliPopupPropertyContextualMode(void)
901 ToolkitTestApplication application;
902 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
904 // Create the Popup actor
905 Popup popup = Popup::New();
906 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
907 std::string testLabelText = "ContentTest";
909 TextLabel contentLabel = TextLabel::New();
911 popup.SetContent( contentLabel );
913 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
914 Actor placement = Actor::New();
915 placement.SetParentOrigin( ParentOrigin::CENTER );
916 placement.SetAnchorPoint( AnchorPoint::CENTER );
917 placement.SetSize( 1.0f, 1.0f );
918 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
919 Stage::GetCurrent().Add( placement );
921 placement.Add( popup );
923 // Test all contextual modes.
924 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
925 Vector2 offsetValues[5];
926 offsetValues[0] = Vector2( 0.375f, 0.0f );
927 offsetValues[1] = Vector2( -0.125f, -10.5f );
928 offsetValues[2] = Vector2( 10.875f, -0.5f );
929 offsetValues[3] = Vector2( -0.125f, 10.5f );
930 offsetValues[4] = Vector2( -10.875f, -0.5f );
932 for( int i = 0; i < 5; ++i )
934 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
936 std::string propertyResult;
937 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
938 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
940 popup.SetDisplayState( Popup::SHOWN );
941 application.SendNotification();
942 application.Render();
944 // Check the position of the label within the popup.
945 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
947 popup.SetDisplayState( Popup::HIDDEN );
948 application.SendNotification();
949 application.Render();
955 int UtcDaliPopupPropertyBacking(void)
957 ToolkitTestApplication application;
958 tet_infoline( " UtcDaliPopupPropertyBacking" );
960 // Create the Popup actor
961 Popup popup = Popup::New();
962 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
963 Stage::GetCurrent().Add( popup );
965 Actor backing = popup.FindChildByName( "popupBacking" );
966 DALI_TEST_CHECK( backing );
968 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
970 // Check enabled property.
971 popup.SetDisplayState( Popup::SHOWN );
972 application.SendNotification();
973 application.Render();
975 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
977 popup.SetDisplayState( Popup::HIDDEN );
978 application.SendNotification();
979 application.Render();
981 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
983 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
985 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
986 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
988 popup.SetDisplayState( Popup::SHOWN );
989 application.SendNotification();
990 application.Render();
992 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
994 popup.SetDisplayState( Popup::HIDDEN );
995 application.SendNotification();
996 application.Render();
998 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1000 // Check color property.
1001 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1002 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1004 popup.SetDisplayState( Popup::SHOWN );
1005 application.SendNotification();
1006 application.Render();
1008 Vector4 resultColor;
1009 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1010 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1015 int UtcDaliPopupPropertyBackgroundImage(void)
1017 ToolkitTestApplication application;
1018 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1020 // Create the Popup actor
1021 Popup popup = Popup::New();
1022 Stage::GetCurrent().Add( popup );
1024 // Check setting an image
1025 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1026 std::string resultString;
1027 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1028 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1033 int UtcDaliPopupPropertyCustomAnimation(void)
1035 ToolkitTestApplication application;
1036 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1038 // Create the Popup actor
1039 Popup popup = Popup::New();
1040 TextLabel content = TextLabel::New( "text" );
1041 popup.SetContent( content );
1043 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1044 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1046 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1047 DALI_TEST_CHECK( popupContainer );
1049 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1050 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1052 Property::Map animationMapEntry;
1053 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1054 animationMapEntry.Insert( "property", "position" );
1055 animationMapEntry.Insert( "value", entryAnimationDestination );
1056 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1058 Property::Array timePeriodMapEntry;
1059 timePeriodMapEntry.PushBack( 0.0f );
1060 timePeriodMapEntry.PushBack( 1.0f );
1062 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1064 Property::Map animationMapExit;
1065 animationMapExit.Insert( "actor", "customAnimationPopup" );
1066 animationMapExit.Insert( "property", "position" );
1067 animationMapExit.Insert( "value", exitAnimationDestination );
1068 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1070 Property::Array timePeriodMapExit;
1071 timePeriodMapExit.PushBack( 0.0f );
1072 timePeriodMapExit.PushBack( 1.0f );
1074 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1076 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1077 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1079 Property::Map resultMap;
1080 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1081 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1082 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1083 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1085 Stage::GetCurrent().Add( popup );
1086 popup.SetDisplayState( Popup::SHOWN );
1088 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1090 application.SendNotification();
1091 application.Render( RENDER_FRAME_INTERVAL );
1094 // Test the popup has animated to it's entry-transition destination.
1095 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1097 popup.SetDisplayState( Popup::HIDDEN );
1099 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1101 application.SendNotification();
1102 application.Render( RENDER_FRAME_INTERVAL );
1105 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1110 static bool gPushButtonClicked;
1111 static bool PushButtonClicked( Button button )
1113 gPushButtonClicked = true;
1117 int UtcDaliPopupPropertyTouchTransparent(void)
1119 ToolkitTestApplication application;
1120 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1122 // Create the Popup actor
1123 Popup popup = Popup::New();
1124 TextLabel content = TextLabel::New( "text" );
1125 popup.SetContent( content );
1126 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1127 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1128 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1129 popup.SetSize( 100, 100 );
1130 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1132 // Create a button (to go underneath the popup).
1133 PushButton button = Toolkit::PushButton::New();
1134 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1135 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1136 button.SetSize( 100, 100 );
1137 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1139 button.ClickedSignal().Connect( &PushButtonClicked );
1141 Stage::GetCurrent().Add( button );
1143 button.Add( popup );
1145 popup.SetDisplayState( Popup::SHOWN );
1146 application.SendNotification();
1147 application.Render();
1149 gPushButtonClicked = false;
1150 Dali::Integration::TouchEvent event;
1152 // Perform a click, the popup should block the click from hitting the button.
1153 event = Dali::Integration::TouchEvent();
1154 event.AddPoint( GetPointDown() );
1155 application.ProcessEvent( event );
1156 application.SendNotification();
1157 application.Render();
1159 event = Dali::Integration::TouchEvent();
1160 event.AddPoint( GetPointUp() );
1161 application.ProcessEvent( event );
1162 application.SendNotification();
1163 application.Render();
1165 DALI_TEST_CHECK( !gPushButtonClicked );
1167 // Enable touch transparency.
1168 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1169 bool propertyResult;
1170 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1171 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1173 // Perform a click, the popup should allow the click to travel through to the button.
1174 event = Dali::Integration::TouchEvent();
1175 event.AddPoint( GetPointDown() );
1176 application.ProcessEvent( event );
1177 application.SendNotification();
1178 application.Render();
1180 event = Dali::Integration::TouchEvent();
1181 event.AddPoint( GetPointUp() );
1182 application.ProcessEvent( event );
1183 application.SendNotification();
1184 application.Render();
1186 DALI_TEST_CHECK( gPushButtonClicked );
1191 int UtcDaliPopupPropertyTail(void)
1193 ToolkitTestApplication application;
1194 tet_infoline( " UtcDaliPopupPropertyTail" );
1196 // Create the Popup actor
1197 Popup popup = Popup::New();
1198 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1199 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1200 popup.SetSize( 100, 100 );
1201 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1202 TextLabel content = TextLabel::New( "text" );
1203 popup.SetContent( content );
1205 std::string imageFilename = "invalid-image.jpg";
1206 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1207 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1208 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1209 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1211 std::string resultString;
1212 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1213 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1214 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1215 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1216 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1217 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1218 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1219 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1221 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1223 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1224 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1227 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1229 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1230 Vector3 vectorResult;
1231 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1232 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1234 Stage::GetCurrent().Add( popup );
1236 popup.SetDisplayState( Popup::SHOWN );
1237 application.SendNotification();
1238 application.Render();
1239 tailActor = popup.FindChildByName( "tailImage" );
1240 DALI_TEST_CHECK( tailActor );
1242 float baseValX = tailActor.GetCurrentWorldPosition().x;
1244 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1246 popup.SetDisplayState( Popup::HIDDEN );
1247 application.SendNotification();
1248 application.Render();
1250 tailPosition = ParentOrigin::CENTER_LEFT;
1251 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1253 popup.SetDisplayState( Popup::SHOWN );
1254 application.SendNotification();
1255 application.Render();
1256 tailActor = popup.FindChildByName( "tailImage" );
1257 DALI_TEST_CHECK( tailActor );
1259 float baseValY = tailActor.GetCurrentWorldPosition().y;
1260 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1262 popup.SetDisplayState( Popup::HIDDEN );
1263 application.SendNotification();
1264 application.Render();
1266 tailPosition = ParentOrigin::BOTTOM_CENTER;
1267 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1269 popup.SetDisplayState( Popup::SHOWN );
1270 application.SendNotification();
1271 application.Render();
1272 tailActor = popup.FindChildByName( "tailImage" );
1273 DALI_TEST_CHECK( tailActor );
1274 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1275 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1277 popup.SetDisplayState( Popup::HIDDEN );
1278 application.SendNotification();
1279 application.Render();
1281 tailPosition = ParentOrigin::CENTER_RIGHT;
1282 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1284 popup.SetDisplayState( Popup::SHOWN );
1285 application.SendNotification();
1286 application.Render();
1287 tailActor = popup.FindChildByName( "tailImage" );
1288 DALI_TEST_CHECK( tailActor );
1289 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1290 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1292 popup.SetDisplayState( Popup::HIDDEN );
1293 application.SendNotification();
1294 application.Render();
1299 int UtcDaliPopupTypeToast(void)
1301 ToolkitTestApplication application;
1302 tet_infoline( " UtcDaliPopupTypeToast" );
1304 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1305 DALI_TEST_CHECK( typeInfo )
1307 BaseHandle baseHandle = typeInfo.CreateInstance();
1308 DALI_TEST_CHECK( baseHandle )
1310 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1311 gPopupState = Toolkit::Popup::HIDDEN;
1312 ConnectStateSignals( popup );
1313 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1315 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1316 Stage::GetCurrent().Add( popup );
1317 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1319 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1321 application.SendNotification();
1322 application.Render( RENDER_FRAME_INTERVAL );
1325 // Check the toast popup is shown.
1326 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1328 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1330 application.SendNotification();
1331 application.Render( RENDER_FRAME_INTERVAL );
1334 // Check the toast popup hides.
1335 Dali::Timer timer = Timer::New( 0 );
1336 timer.MockEmitSignal();
1338 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1340 application.SendNotification();
1341 application.Render( RENDER_FRAME_INTERVAL );
1344 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1349 int UtcDaliPopupTypeRegistryCreation(void)
1351 ToolkitTestApplication application;
1352 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1354 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1355 DALI_TEST_CHECK( typeInfo )
1357 BaseHandle baseHandle = typeInfo.CreateInstance();
1358 DALI_TEST_CHECK( baseHandle )
1360 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1361 gPopupState = Toolkit::Popup::HIDDEN;
1362 ConnectStateSignals( popup );
1363 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1365 Stage::GetCurrent().Add( popup );
1366 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1368 application.SendNotification();
1369 application.Render();
1371 // Check the popup is shown.
1372 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1377 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1379 ToolkitTestApplication application;
1380 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1382 // Create the Popup actor
1383 Popup popup = Popup::New();
1385 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1386 // Note: The emmision of this signals has already been tested in other tests.
1387 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1388 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1389 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1390 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1391 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1393 // Test connecting to an invalid signal does not work.
1394 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1399 int UtcDaliPopupOnControlChildAdd(void)
1401 ToolkitTestApplication application;
1402 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1404 // Create the Popup actor
1405 Popup popup = Popup::New();
1406 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1407 std::string testLabelText = "ContentTest";
1408 TextLabel contentLabel = TextLabel::New( testLabelText );
1410 popup.Add( contentLabel );
1412 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1417 int UtcDaliPopupOnKeyEvent(void)
1419 ToolkitTestApplication application;
1420 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1422 // Create the Popup actor
1423 Popup popup = Popup::New();
1424 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1425 Stage::GetCurrent().Add( popup );
1427 popup.SetDisplayState( Popup::SHOWN );
1428 application.SendNotification();
1429 application.Render();
1431 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1433 popup.SetKeyInputFocus();
1435 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DevelDevice::Class::TOUCH, DevelDevice::Subclass::NONE ) );
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1444 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1446 ToolkitTestApplication application;
1448 tet_infoline( "Set the background border property of a popup & retrieve it" );
1449 Popup popup = Popup::New();
1451 Rect< int > rect( 40, 30, 20, 10 );
1452 tet_infoline( "Ensure value we want to set is different from what is already set" );
1453 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1455 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1456 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1457 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1459 tet_infoline( "Set a vector4 as well which should also work" );
1460 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1461 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1462 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );