2 * Copyright (c) 2020 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/integration-api/events/wheel-event-integ.h>
29 #include <dali/devel-api/actors/actor-devel.h>
30 #include <dali/devel-api/scripting/scripting.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/popup/popup.h>
35 using namespace Toolkit;
37 void utc_dali_toolkit_popup_startup(void)
39 test_return_value = TET_UNDEF;
42 void utc_dali_toolkit_popup_cleanup(void)
44 test_return_value = TET_PASS;
49 static bool gObjectCreatedCallBackCalled;
51 static void TestCallback(BaseHandle handle)
53 gObjectCreatedCallBackCalled = true;
56 const int RENDER_FRAME_INTERVAL = 10; ///< Duration of each frame in ms.
57 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation.
58 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
59 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
61 Dali::Integration::Point GetPointDown()
63 Dali::Integration::Point point;
64 point.SetState( PointState::DOWN );
65 point.SetScreenPosition( Vector2( 10, 10 ) );
69 Dali::Integration::Point GetPointUp()
71 Dali::Integration::Point point;
72 point.SetState( PointState::UP );
73 point.SetScreenPosition( Vector2( 10, 10 ) );
78 * Counts how many descendants root Actor has, including
81 * @param[in] root The root actor to count from.
82 * @return The number of descendants including root actor itself.
84 int DescendentCount( const Actor& root )
86 unsigned int numChildren = root.GetChildCount();
90 for( unsigned int i = 0; i < numChildren; ++i )
92 count += DescendentCount( root.GetChildAt( i ) );
98 bool HasAncestor( Actor child, Actor ancestor )
100 while( child && child != ancestor )
102 child = child.GetParent();
105 return ( child == ancestor );
108 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
109 static bool gTouchedOutside;
113 static void OnPopupTouchedOutside()
115 gTouchedOutside = true;
118 static void OnPopupShowing()
120 gPopupState = Toolkit::Popup::SHOWING;
123 static void OnPopupShown()
125 gPopupState = Toolkit::Popup::SHOWN;
128 static void OnPopupHiding()
130 gPopupState = Toolkit::Popup::HIDING;
133 static void OnPopupHidden()
135 gPopupState = Toolkit::Popup::HIDDEN;
138 void ConnectStateSignals( Toolkit::Popup popup )
140 popup.ShowingSignal().Connect( &OnPopupShowing );
141 popup.ShownSignal().Connect( &OnPopupShown );
142 popup.HidingSignal().Connect( &OnPopupHiding );
143 popup.HiddenSignal().Connect( &OnPopupHidden );
146 void WaitAnimation( ToolkitTestApplication& application )
148 // Wait for a while (allow animation to complete), and then check state.
149 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
151 application.SendNotification();
152 application.Render( RENDER_FRAME_INTERVAL );
157 * A connection tracker is required when connecting to a signal with a functor.
159 class TestConnectionTrackerObject : public ConnectionTracker
164 * This functor is used to test the popup's signal connection.
166 struct PopupTestFunctor
177 // Generate a KeyEvent to send to Core.
178 Integration::KeyEvent GenerateKey( const std::string& keyName,
179 const std::string& logicalKey,
180 const std::string& keyString,
183 unsigned long timeStamp,
184 const Integration::KeyEvent::State& keyState,
185 const std::string& compose = "",
186 const std::string& deviceName = "",
187 const Device::Class::Type& deviceClass = Device::Class::NONE,
188 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE
191 return Integration::KeyEvent( keyName,
204 } // Anonymous namespace
207 * This test checks popup creation.
209 int UtcDaliPopupNewP( void )
211 ToolkitTestApplication application;
212 tet_infoline( " UtcDaliPopupNewP" );
214 // Create the Popup actor.
217 DALI_TEST_CHECK( !popup );
219 popup = Popup::New();
221 DALI_TEST_CHECK( popup );
223 Popup popup2( popup );
225 DALI_TEST_CHECK( popup2 == popup );
227 // Additional check to ensure object is created by checking if it's registered.
228 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
229 DALI_TEST_CHECK( registry );
231 gObjectCreatedCallBackCalled = false;
232 registry.ObjectCreatedSignal().Connect( &TestCallback );
234 Popup popup = Popup::New();
236 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
241 * This test checks popup destruction.
243 int UtcDaliPopupDestructorP( void )
245 ToolkitTestApplication application;
246 tet_infoline( " UtcDaliPopupDestructorP" );
248 Popup* popup = new Popup();
251 DALI_TEST_CHECK( true );
255 int UtcDaliPopupDownCastP(void)
257 ToolkitTestApplication application;
258 tet_infoline( " UtcDaliPopupDownCastP" );
260 Handle handle = Popup::New();
262 Popup popup = Popup::DownCast( handle );
264 DALI_TEST_CHECK( popup == handle );
268 int UtcDaliPopupSetPropertyP(void)
270 ToolkitTestApplication application;
271 tet_infoline( " UtcDaliPopupSetProperty" );
273 Popup popup = Popup::New();
276 std::string testString = "Hello World";
278 TextLabel textActorIn = TextLabel::New( testString );
280 Scripting::CreatePropertyMap( textActorIn, map );
281 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
282 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
283 std::string resultText;
284 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
285 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
290 int UtcDaliPopupSetTitleP(void)
292 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
293 tet_infoline( " UtcDaliPopupSetTitleP" );
295 // Create the Popup actor
296 Popup popup = Popup::New();
298 // Put in show state so it's layer is connected to popup (for ancestor check).
299 popup.SetDisplayState( Popup::SHOWN );
301 TextLabel titleActor = TextLabel::New();
302 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
304 DALI_TEST_CHECK( !popup.GetTitle() );
305 popup.SetTitle( titleActor );
306 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
307 DALI_TEST_CHECK( textActor == titleActor );
309 std::string resultText;
310 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
312 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
313 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
314 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
316 TextLabel titleActor2 = TextLabel::New();
317 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
318 popup.SetTitle( titleActor2 );
319 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
320 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
321 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
323 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
325 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
326 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
330 int UtcDaliPopupSetTitleN(void)
332 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
333 tet_infoline( " UtcDaliPopupSetTitleN" );
335 // Create the Popup actor
336 Popup popup = Popup::New();
338 TextLabel titleActor = TextLabel::New( "text" );
339 popup.SetTitle( titleActor );
341 DALI_TEST_CHECK( popup.GetTitle() );
343 // Set a bad title value.
344 // Confirm this has disabled the title.
346 popup.SetTitle( badActor );
348 DALI_TEST_CHECK( !popup.GetTitle() );
353 int UtcDaliPopupSetContentP(void)
355 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
356 tet_infoline( " UtcDaliPopupSetContentP" );
358 // Create the Popup actor
359 Popup popup = Popup::New();
360 application.GetScene().Add( popup );
361 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
363 // Put in show state so it's layer is connected to popup (for ancestor check).
364 popup.SetDisplayState( Popup::SHOWN );
366 PushButton button = PushButton::New();
367 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
368 popup.SetFooter( button );
369 // Hide and then re-show popup to cause button to be rearranged and added to popup.
370 popup.SetDisplayState( Popup::HIDDEN );
371 popup.SetDisplayState( Popup::SHOWN );
372 DALI_TEST_CHECK( HasAncestor( button, popup ) );
376 int UtcDaliPopupSetContentN(void)
378 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
379 tet_infoline( " UtcDaliPopupSetContentN" );
381 // Create the Popup actor
382 Popup popup = Popup::New();
384 TextLabel content = TextLabel::New( "text" );
385 popup.SetContent( content );
387 DALI_TEST_CHECK( popup.GetContent() );
389 // Set a bad title value.
391 popup.SetContent( badActor );
393 DALI_TEST_CHECK( !popup.GetContent() );
398 int UtcDaliPopupSetFooterP(void)
400 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
401 tet_infoline(" UtcDaliPopupSetFooterP");
403 // Create the Popup actor
404 Popup popup = Popup::New();
405 application.GetScene().Add( popup );
406 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
407 // Put in show state so it's layer is connected to popup (for ancestor check).
408 popup.SetDisplayState( Popup::SHOWN );
410 PushButton button = PushButton::New();
411 DALI_TEST_CHECK( !HasAncestor(button, popup) );
412 popup.SetFooter( button );
413 // Hide and then re-show popup to cause button to be rearranged and added to popup.
414 popup.SetDisplayState( Popup::HIDDEN );
415 popup.SetDisplayState( Popup::SHOWN );
416 DALI_TEST_CHECK( HasAncestor( button, popup ) );
420 int UtcDaliPopupSetFooterN(void)
422 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
423 tet_infoline(" UtcDaliPopupSetFooterN");
425 // Create the Popup actor
426 Popup popup = Popup::New();
428 PushButton button = PushButton::New();
429 popup.SetFooter( button );
431 DALI_TEST_CHECK( popup.GetFooter() );
433 // Set a bad title value.
435 popup.SetFooter( badActor );
437 DALI_TEST_CHECK( !popup.GetFooter() );
442 int UtcDaliPopupSetControlFooterMultiple(void)
444 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
445 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
447 // Create the Popup actor
448 Popup popup = Popup::New();
449 application.GetScene().Add( popup );
450 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
451 // Put in show state so it's layer is connected to popup (for ancestor check).
452 popup.SetDisplayState( Popup::SHOWN );
454 Actor container = Actor::New();
455 PushButton button1 = PushButton::New();
456 PushButton button2 = PushButton::New();
457 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
458 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
459 container.Add( button1 );
460 container.Add( button2 );
461 popup.SetFooter( container );
463 // Hide and then re-show popup to cause button to be rearranged and added to popup.
464 popup.SetDisplayState( Popup::HIDDEN );
465 popup.SetDisplayState( Popup::SHOWN );
466 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
467 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
471 int UtcDaliPopupSetTitleAndFooter(void)
473 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
474 tet_infoline( " UtcDaliPopupSetTitleAndFooter" );
476 // Create the Popup actor
477 Popup popup = Popup::New();
479 // Put in show state so it's layer is connected to popup (for ancestor check).
480 popup.SetDisplayState( Popup::SHOWN );
483 TextLabel titleActor = TextLabel::New();
484 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
486 DALI_TEST_CHECK( !popup.GetTitle() );
487 popup.SetTitle( titleActor );
488 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
489 DALI_TEST_CHECK( textActor == titleActor );
491 std::string resultText;
492 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
493 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
494 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
495 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
498 PushButton button = PushButton::New();
499 DALI_TEST_CHECK( !HasAncestor(button, popup) );
500 popup.SetFooter( button );
501 // Hide and then re-show popup to cause button to be rearranged and added to popup.
502 popup.SetDisplayState( Popup::HIDDEN );
503 popup.SetDisplayState( Popup::SHOWN );
504 DALI_TEST_CHECK( HasAncestor( button, popup ) );
509 int UtcDaliPopupSetStateP(void)
511 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
512 tet_infoline(" UtcDaliPopupSetStateP");
514 // Create the Popup actor
515 Popup popup = Popup::New();
517 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
519 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
521 popup.SetDisplayState( Popup::SHOWN );
522 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
524 popup.SetDisplayState( Popup::HIDDEN );
525 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
529 int UtcDaliPopupSetStateN(void)
531 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
532 tet_infoline(" UtcDaliPopupSetStateN");
534 // Create the Popup actor
535 Popup popup = Popup::New();
537 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
539 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
541 popup.SetDisplayState( Popup::SHOWN );
542 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
544 // Test cancelling a show before it has finished.
545 popup.SetDisplayState( Popup::HIDDEN );
546 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
550 int UtcDaliPopupDisplayStateSignal(void)
552 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
553 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
555 // Create the Popup actor
556 Popup popup = Popup::New();
557 ConnectStateSignals( popup );
559 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
560 popup.SetDisplayState( Popup::SHOWN );
561 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
562 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
564 // Wait for a while (allow animation to complete), and then check state.
565 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
567 application.SendNotification();
568 application.Render( RENDER_FRAME_INTERVAL );
571 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
572 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
575 popup.SetDisplayState( Popup::HIDDEN );
576 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
577 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
579 // Wait for a while (allow animation to complete), and then check state.
580 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
582 application.SendNotification();
583 application.Render( RENDER_FRAME_INTERVAL );
586 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
587 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
592 int UtcDaliPopupShowHide(void)
594 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
595 tet_infoline(" UtcDaliPopupShowHide");
597 // Create the Popup actor
598 Popup popup = Popup::New();
599 ConnectStateSignals( popup );
601 Actor container = Actor::New();
602 PushButton button1 = PushButton::New();
603 PushButton button2 = PushButton::New();
604 button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
605 button2.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
606 container.Add( button1 );
607 container.Add( button2 );
608 popup.SetFooter( container );
611 // Note: in most popup animation implementations show would result in
612 // popup being onstage immediately following Show(). However we can't
613 // assume for all. e.g. If one creates a animation with a delay.
614 popup.SetDisplayState( Popup::SHOWN );
616 // Wait for a while (allow animation to complete), and then check state.
617 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
619 application.SendNotification();
620 application.Render( RENDER_FRAME_INTERVAL );
624 popup.SetDisplayState( Popup::HIDDEN );
626 // Wait for a while (allow animation to complete), and then check state.
627 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
629 application.SendNotification();
630 application.Render(RENDER_FRAME_INTERVAL);
633 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
637 int UtcDaliPopupPropertyTailVisibility(void)
639 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
640 tet_infoline(" UtcDaliPopupShowHideTail");
642 // Create the Popup actor
643 Popup popup = Popup::New();
644 application.GetScene().Add( popup );
646 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
647 popup.SetDisplayState( Popup::SHOWN );
649 int withoutTailCount = DescendentCount( popup );
651 popup.SetDisplayState( Popup::HIDDEN );
653 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
654 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
655 popup.SetDisplayState( Popup::SHOWN );
657 int withTailCount = DescendentCount( popup );
659 // There should be more actors if the Tail has been added.
660 DALI_TEST_CHECK( withTailCount > withoutTailCount );
663 popup.SetDisplayState( Popup::HIDDEN );
664 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
665 popup.SetDisplayState( Popup::SHOWN );
666 int withoutTailCount2 = DescendentCount(popup);
668 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
672 int UtcDaliPopupOnTouchedOutsideSignal(void)
674 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
675 tet_infoline(" UtcDaliPopupOnTouchedOutside");
677 // Create the Popup actor
678 Popup popup = Popup::New();
679 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
680 popup.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER );
681 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
682 popup.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
683 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
684 application.GetScene().Add( popup );
685 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
686 popup.SetDisplayState( Popup::SHOWN );
688 application.SendNotification();
689 application.Render();
691 gTouchedOutside = false;
692 Dali::Integration::TouchEvent event;
694 event = Dali::Integration::TouchEvent();
695 event.AddPoint( GetPointDown() );
696 application.ProcessEvent( event );
698 application.SendNotification();
699 application.Render();
701 event = Dali::Integration::TouchEvent();
702 event.AddPoint( GetPointUp() );
703 application.ProcessEvent( event );
705 application.SendNotification();
706 application.Render();
708 // Confirm the signal is ignored if touch_transparent.
709 gTouchedOutside = false;
710 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
712 event = Dali::Integration::TouchEvent();
713 event.AddPoint( GetPointDown() );
714 application.ProcessEvent( event );
716 application.SendNotification();
717 application.Render();
719 event = Dali::Integration::TouchEvent();
720 event.AddPoint( GetPointUp() );
721 application.ProcessEvent( event );
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_CHECK( !gTouchedOutside );
731 int UtcDaliPopupPropertyAutoHide(void)
733 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
734 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
736 // Create the Popup actor
737 Popup popup = Popup::New();
738 ConnectStateSignals( popup );
740 Actor container = Actor::New();
741 PushButton button1 = PushButton::New();
742 button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
743 container.Add( button1 );
744 popup.SetFooter( container );
746 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
747 float getAnimationDuration = 0.0f;
748 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
749 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
751 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
752 int getAutoHideDelay = 0;
753 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
754 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
756 application.GetScene().Add( popup );
758 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
761 // Note: in most popup animation implementations show would result in
762 // popup being onstage immediately following Show(). However we can't
763 // assume for all. e.g. If one creates a animation with a delay.
764 popup.SetDisplayState( Popup::SHOWN );
766 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
768 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
770 application.SendNotification();
771 application.Render( RENDER_FRAME_INTERVAL );
774 // Force the timer used by the popup to expire,
775 // this will cause the popup to hide automatically.
776 Dali::Timer timer = Timer::New( 0 );
777 timer.MockEmitSignal();
779 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
785 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
787 int UtcDaliPopupPropertyAnimationMode(void)
789 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
790 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
792 // Create the Popup actor
793 Popup popup = Popup::New();
794 ConnectStateSignals( popup );
795 popup.SetTitle( TextLabel::New( "Title" ) );
796 application.GetScene().Add( popup );
798 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
800 // Try both default and zero animation duration, as zero has a special case for some animation types.
801 for( int j = 0; j <= 1; j++ )
803 // On the second loop, set duration to zero.
806 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
809 // Loop through 4 animation modes.
810 for( int i = 0; i < 4; i++ )
812 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
814 std::string checkMode;
815 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
817 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
819 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
820 std::string resultState;
822 // Only wait for animation if it isn't instant.
825 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
826 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
827 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
828 WaitAnimation( application );
831 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
832 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
833 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
834 popup.SetDisplayState( Popup::HIDDEN );
838 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
839 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
840 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
841 WaitAnimation( application );
844 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
845 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
846 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
853 int UtcDaliPopupPropertyTitle(void)
855 ToolkitTestApplication application;
856 tet_infoline( " UtcDaliPopupPropertyTitle" );
858 // Create the Popup actor
859 Popup popup = Popup::New();
861 std::string testLabelText = "TitleTest";
862 TextLabel titleLabel = TextLabel::New();
863 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
864 Actor title = titleLabel;
866 Scripting::CreatePropertyMap( title, map );
867 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
869 Property::Map resultMap;
870 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
872 Property::Value* resultProperty = resultMap.Find( "text" );
873 DALI_TEST_CHECK( resultProperty );
875 std::string resultText;
876 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
878 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
883 int UtcDaliPopupPropertyContent(void)
885 ToolkitTestApplication application;
886 tet_infoline( " UtcDaliPopupPropertyContent" );
888 // Create the Popup actor
889 Popup popup = Popup::New();
891 std::string testLabelText = "ContentTest";
892 TextLabel contentLabel = TextLabel::New();
893 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
894 Actor content = contentLabel;
896 Scripting::CreatePropertyMap( content, map );
897 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
899 Property::Map resultMap;
900 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
902 Property::Value* resultProperty = resultMap.Find( "text" );
903 DALI_TEST_CHECK( resultProperty );
905 std::string resultText;
906 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
908 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
913 int UtcDaliPopupPropertyFooter(void)
915 ToolkitTestApplication application;
916 tet_infoline( " UtcDaliPopupPropertyFooter" );
918 // Create the Popup actor
919 Popup popup = Popup::New();
921 std::string testLabelText = "FooterTest";
922 TextLabel footerLabel = TextLabel::New();
923 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
924 Actor footer = footerLabel;
926 Scripting::CreatePropertyMap( footer, map );
927 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
929 Property::Map resultMap;
930 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
932 Property::Value* resultProperty = resultMap.Find( "text" );
933 DALI_TEST_CHECK( resultProperty );
935 std::string resultText;
936 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
938 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
943 int UtcDaliPopupPropertyContextualMode(void)
945 ToolkitTestApplication application;
946 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
948 // Create the Popup actor
949 Popup popup = Popup::New();
950 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
951 std::string testLabelText = "ContentTest";
953 TextLabel contentLabel = TextLabel::New();
955 popup.SetContent( contentLabel );
957 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
958 Actor placement = Actor::New();
959 placement.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
960 placement.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
961 placement.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 1.0f ) );
962 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
963 application.GetScene().Add( placement );
965 placement.Add( popup );
967 // Test all contextual modes.
968 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
969 Vector2 offsetValues[5];
970 offsetValues[0] = Vector2( 0.375f, 0.0f );
971 offsetValues[1] = Vector2( -0.125f, -10.5f );
972 offsetValues[2] = Vector2( 10.875f, -0.5f );
973 offsetValues[3] = Vector2( -0.125f, 10.5f );
974 offsetValues[4] = Vector2( -10.875f, -0.5f );
976 for( int i = 0; i < 5; ++i )
978 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
980 std::string propertyResult;
981 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
982 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
984 popup.SetDisplayState( Popup::SHOWN );
985 application.SendNotification();
986 application.Render();
988 // Check the position of the label within the popup.
989 DALI_TEST_EQUALS( contentLabel.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).GetVectorXY(), offsetValues[i], TEST_LOCATION );
991 popup.SetDisplayState( Popup::HIDDEN );
992 application.SendNotification();
993 application.Render();
999 int UtcDaliPopupPropertyBacking(void)
1001 ToolkitTestApplication application;
1002 tet_infoline( " UtcDaliPopupPropertyBacking" );
1004 // Create the Popup actor
1005 Popup popup = Popup::New();
1006 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1007 application.GetScene().Add( popup );
1009 Actor backing = popup.FindChildByName( "popupBacking" );
1010 DALI_TEST_CHECK( backing );
1012 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1014 // Check enabled property.
1015 popup.SetDisplayState( Popup::SHOWN );
1016 application.SendNotification();
1017 application.Render();
1019 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1021 popup.SetDisplayState( Popup::HIDDEN );
1022 application.SendNotification();
1023 application.Render();
1025 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1027 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
1028 bool propertyResult;
1029 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
1030 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
1032 popup.SetDisplayState( Popup::SHOWN );
1033 application.SendNotification();
1034 application.Render();
1036 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1038 popup.SetDisplayState( Popup::HIDDEN );
1039 application.SendNotification();
1040 application.Render();
1042 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1044 // Check color property.
1045 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1046 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1048 popup.SetDisplayState( Popup::SHOWN );
1049 application.SendNotification();
1050 application.Render();
1052 Vector4 resultColor;
1053 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1054 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1059 int UtcDaliPopupPropertyBackgroundImage(void)
1061 ToolkitTestApplication application;
1062 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1064 // Create the Popup actor
1065 Popup popup = Popup::New();
1066 application.GetScene().Add( popup );
1068 // Check setting an image
1069 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1070 std::string resultString;
1071 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1072 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1077 int UtcDaliPopupPropertyCustomAnimation(void)
1079 ToolkitTestApplication application;
1080 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1082 // Create the Popup actor
1083 Popup popup = Popup::New();
1084 TextLabel content = TextLabel::New( "text" );
1085 popup.SetContent( content );
1087 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1088 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1090 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1091 DALI_TEST_CHECK( popupContainer );
1093 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1094 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1096 Property::Map animationMapEntry;
1097 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1098 animationMapEntry.Insert( "property", "position" );
1099 animationMapEntry.Insert( "value", entryAnimationDestination );
1100 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1102 Property::Array timePeriodMapEntry;
1103 timePeriodMapEntry.PushBack( 0.0f );
1104 timePeriodMapEntry.PushBack( 1.0f );
1106 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1108 Property::Map animationMapExit;
1109 animationMapExit.Insert( "actor", "customAnimationPopup" );
1110 animationMapExit.Insert( "property", "position" );
1111 animationMapExit.Insert( "value", exitAnimationDestination );
1112 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1114 Property::Array timePeriodMapExit;
1115 timePeriodMapExit.PushBack( 0.0f );
1116 timePeriodMapExit.PushBack( 1.0f );
1118 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1120 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1121 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1123 Property::Map resultMap;
1124 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1125 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1126 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1127 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1129 application.GetScene().Add( popup );
1130 popup.SetDisplayState( Popup::SHOWN );
1132 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1134 application.SendNotification();
1135 application.Render( RENDER_FRAME_INTERVAL );
1138 // Test the popup has animated to it's entry-transition destination.
1139 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), entryAnimationDestination, 0.1f, TEST_LOCATION );
1141 popup.SetDisplayState( Popup::HIDDEN );
1143 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1145 application.SendNotification();
1146 application.Render( RENDER_FRAME_INTERVAL );
1149 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), exitAnimationDestination, 0.1f, TEST_LOCATION );
1154 static bool gPushButtonClicked;
1155 static bool PushButtonClicked( Button button )
1157 gPushButtonClicked = true;
1161 int UtcDaliPopupPropertyTouchTransparent(void)
1163 ToolkitTestApplication application;
1164 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1166 // Create the Popup actor
1167 Popup popup = Popup::New();
1168 TextLabel content = TextLabel::New( "text" );
1169 popup.SetContent( content );
1170 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1171 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1172 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1173 popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
1174 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1176 // Create a button (to go underneath the popup).
1177 PushButton button = Toolkit::PushButton::New();
1178 button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1179 button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1180 button.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
1181 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1183 button.ClickedSignal().Connect( &PushButtonClicked );
1185 application.GetScene().Add( button );
1187 button.Add( popup );
1189 popup.SetDisplayState( Popup::SHOWN );
1190 application.SendNotification();
1191 application.Render();
1193 gPushButtonClicked = false;
1194 Dali::Integration::TouchEvent event;
1196 // Perform a click, the popup should block the click from hitting the button.
1197 event = Dali::Integration::TouchEvent();
1198 event.AddPoint( GetPointDown() );
1199 application.ProcessEvent( event );
1200 application.SendNotification();
1201 application.Render();
1203 event = Dali::Integration::TouchEvent();
1204 event.AddPoint( GetPointUp() );
1205 application.ProcessEvent( event );
1206 application.SendNotification();
1207 application.Render();
1209 DALI_TEST_CHECK( !gPushButtonClicked );
1211 // Perform a wheel event
1212 Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
1213 application.ProcessEvent( wheelEvent );
1214 application.SendNotification();
1215 application.Render();
1217 // Enable touch transparency.
1218 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1219 bool propertyResult;
1220 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1221 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1223 // Perform a click, the popup should allow the click to travel through to the button.
1224 event = Dali::Integration::TouchEvent();
1225 event.AddPoint( GetPointDown() );
1226 application.ProcessEvent( event );
1227 application.SendNotification();
1228 application.Render();
1230 event = Dali::Integration::TouchEvent();
1231 event.AddPoint( GetPointUp() );
1232 application.ProcessEvent( event );
1233 application.SendNotification();
1234 application.Render();
1236 DALI_TEST_CHECK( gPushButtonClicked );
1241 int UtcDaliPopupPropertyTail(void)
1243 ToolkitTestApplication application;
1244 tet_infoline( " UtcDaliPopupPropertyTail" );
1246 // Create the Popup actor
1247 Popup popup = Popup::New();
1248 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1249 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1250 popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
1251 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1252 TextLabel content = TextLabel::New( "text" );
1253 popup.SetContent( content );
1255 std::string imageFilename = "invalid-image.jpg";
1256 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1257 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1258 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1259 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1261 std::string resultString;
1262 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1263 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1264 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1265 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1266 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1267 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1268 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1269 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1271 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1273 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1274 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1277 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1279 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1280 Vector3 vectorResult;
1281 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1282 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1284 application.GetScene().Add( popup );
1286 popup.SetDisplayState( Popup::SHOWN );
1287 application.SendNotification();
1288 application.Render();
1289 tailActor = popup.FindChildByName( "tailImage" );
1290 DALI_TEST_CHECK( tailActor );
1292 float baseValX = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x;
1294 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, TEST_LOCATION );
1296 popup.SetDisplayState( Popup::HIDDEN );
1297 application.SendNotification();
1298 application.Render();
1300 tailPosition = ParentOrigin::CENTER_LEFT;
1301 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1303 popup.SetDisplayState( Popup::SHOWN );
1304 application.SendNotification();
1305 application.Render();
1306 tailActor = popup.FindChildByName( "tailImage" );
1307 DALI_TEST_CHECK( tailActor );
1309 float baseValY = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y;
1310 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, TEST_LOCATION );
1312 popup.SetDisplayState( Popup::HIDDEN );
1313 application.SendNotification();
1314 application.Render();
1316 tailPosition = ParentOrigin::BOTTOM_CENTER;
1317 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1319 popup.SetDisplayState( Popup::SHOWN );
1320 application.SendNotification();
1321 application.Render();
1322 tailActor = popup.FindChildByName( "tailImage" );
1323 DALI_TEST_CHECK( tailActor );
1324 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1325 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1327 popup.SetDisplayState( Popup::HIDDEN );
1328 application.SendNotification();
1329 application.Render();
1331 tailPosition = ParentOrigin::CENTER_RIGHT;
1332 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1334 popup.SetDisplayState( Popup::SHOWN );
1335 application.SendNotification();
1336 application.Render();
1337 tailActor = popup.FindChildByName( "tailImage" );
1338 DALI_TEST_CHECK( tailActor );
1339 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1340 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1342 popup.SetDisplayState( Popup::HIDDEN );
1343 application.SendNotification();
1344 application.Render();
1349 int UtcDaliPopupTypeToast(void)
1351 ToolkitTestApplication application;
1352 tet_infoline( " UtcDaliPopupTypeToast" );
1354 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
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, 1.0f );
1365 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1366 application.GetScene().Add( popup );
1367 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1369 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1371 application.SendNotification();
1372 application.Render( RENDER_FRAME_INTERVAL );
1375 // Check the toast popup is shown.
1376 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1378 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1380 application.SendNotification();
1381 application.Render( RENDER_FRAME_INTERVAL );
1384 // Check the toast popup hides.
1385 Dali::Timer timer = Timer::New( 0 );
1386 timer.MockEmitSignal();
1388 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1390 application.SendNotification();
1391 application.Render( RENDER_FRAME_INTERVAL );
1394 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1399 int UtcDaliPopupTypeRegistryCreation(void)
1401 ToolkitTestApplication application;
1402 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1404 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1405 DALI_TEST_CHECK( typeInfo )
1407 BaseHandle baseHandle = typeInfo.CreateInstance();
1408 DALI_TEST_CHECK( baseHandle )
1410 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1411 gPopupState = Toolkit::Popup::HIDDEN;
1412 ConnectStateSignals( popup );
1413 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1415 application.GetScene().Add( popup );
1416 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1418 application.SendNotification();
1419 application.Render();
1421 // Check the popup is shown.
1422 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1427 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1429 ToolkitTestApplication application;
1430 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1432 // Create the Popup actor
1433 Popup popup = Popup::New();
1435 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1436 // Note: The emmision of this signals has already been tested in other tests.
1437 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1438 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1439 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1440 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1441 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1443 // Test connecting to an invalid signal does not work.
1444 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1449 int UtcDaliPopupOnChildAdd(void)
1451 ToolkitTestApplication application;
1452 tet_infoline( " UtcDaliPopupOnChildAdd" );
1454 // Create the Popup actor
1455 Popup popup = Popup::New();
1456 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1457 std::string testLabelText = "ContentTest";
1458 TextLabel contentLabel = TextLabel::New( testLabelText );
1460 popup.Add( contentLabel );
1462 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1467 int UtcDaliPopupOnKeyEvent(void)
1469 ToolkitTestApplication application;
1470 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1472 // Create the Popup actor
1473 Popup popup = Popup::New();
1474 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1475 application.GetScene().Add( popup );
1477 popup.SetDisplayState( Popup::SHOWN );
1478 application.SendNotification();
1479 application.Render();
1481 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1483 popup.SetKeyInputFocus();
1485 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
1486 application.SendNotification();
1487 application.Render();
1489 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1494 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1496 ToolkitTestApplication application;
1498 tet_infoline( "Set the background border property of a popup & retrieve it" );
1499 Popup popup = Popup::New();
1501 Rect< int > rect( 40, 30, 20, 10 );
1502 tet_infoline( "Ensure value we want to set is different from what is already set" );
1503 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1505 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1506 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1507 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1509 tet_infoline( "Set a vector4 as well which should also work" );
1510 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1511 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1512 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );