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/devel-api/actors/actor-devel.h>
29 #include <dali/devel-api/scripting/scripting.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/popup/popup.h>
34 using namespace Toolkit;
36 void utc_dali_toolkit_popup_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_popup_cleanup(void)
43 test_return_value = TET_PASS;
48 static bool gObjectCreatedCallBackCalled;
50 static void TestCallback(BaseHandle handle)
52 gObjectCreatedCallBackCalled = true;
55 const int RENDER_FRAME_INTERVAL = 10; ///< Duration of each frame in ms.
56 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation.
57 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
58 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
60 Dali::Integration::Point GetPointDown()
62 Dali::Integration::Point point;
63 point.SetState( PointState::DOWN );
64 point.SetScreenPosition( Vector2( 10, 10 ) );
68 Dali::Integration::Point GetPointUp()
70 Dali::Integration::Point point;
71 point.SetState( PointState::UP );
72 point.SetScreenPosition( Vector2( 10, 10 ) );
77 * Counts how many descendants root Actor has, including
80 * @param[in] root The root actor to count from.
81 * @return The number of descendants including root actor itself.
83 int DescendentCount( const Actor& root )
85 unsigned int numChildren = root.GetChildCount();
89 for( unsigned int i = 0; i < numChildren; ++i )
91 count += DescendentCount( root.GetChildAt( i ) );
97 bool HasAncestor( Actor child, Actor ancestor )
99 while( child && child != ancestor )
101 child = child.GetParent();
104 return ( child == ancestor );
107 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
108 static bool gTouchedOutside;
112 static void OnPopupTouchedOutside()
114 gTouchedOutside = true;
117 static void OnPopupShowing()
119 gPopupState = Toolkit::Popup::SHOWING;
122 static void OnPopupShown()
124 gPopupState = Toolkit::Popup::SHOWN;
127 static void OnPopupHiding()
129 gPopupState = Toolkit::Popup::HIDING;
132 static void OnPopupHidden()
134 gPopupState = Toolkit::Popup::HIDDEN;
137 void ConnectStateSignals( Toolkit::Popup popup )
139 popup.ShowingSignal().Connect( &OnPopupShowing );
140 popup.ShownSignal().Connect( &OnPopupShown );
141 popup.HidingSignal().Connect( &OnPopupHiding );
142 popup.HiddenSignal().Connect( &OnPopupHidden );
145 void WaitAnimation( ToolkitTestApplication& application )
147 // Wait for a while (allow animation to complete), and then check state.
148 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
150 application.SendNotification();
151 application.Render( RENDER_FRAME_INTERVAL );
156 * A connection tracker is required when connecting to a signal with a functor.
158 class TestConnectionTrackerObject : public ConnectionTracker
163 * This functor is used to test the popup's signal connection.
165 struct PopupTestFunctor
176 // Generate a KeyEvent to send to Core.
177 Integration::KeyEvent GenerateKey( const std::string& keyName,
178 const std::string& logicalKey,
179 const std::string& keyString,
182 unsigned long timeStamp,
183 const Integration::KeyEvent::State& keyState,
184 const std::string& compose = "",
185 const std::string& deviceName = "",
186 const Device::Class::Type& deviceClass = Device::Class::NONE,
187 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE
190 return Integration::KeyEvent( keyName,
203 } // Anonymous namespace
206 * This test checks popup creation.
208 int UtcDaliPopupNewP( void )
210 ToolkitTestApplication application;
211 tet_infoline( " UtcDaliPopupNewP" );
213 // Create the Popup actor.
216 DALI_TEST_CHECK( !popup );
218 popup = Popup::New();
220 DALI_TEST_CHECK( popup );
222 Popup popup2( popup );
224 DALI_TEST_CHECK( popup2 == popup );
226 // Additional check to ensure object is created by checking if it's registered.
227 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
228 DALI_TEST_CHECK( registry );
230 gObjectCreatedCallBackCalled = false;
231 registry.ObjectCreatedSignal().Connect( &TestCallback );
233 Popup popup = Popup::New();
235 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
240 * This test checks popup destruction.
242 int UtcDaliPopupDestructorP( void )
244 ToolkitTestApplication application;
245 tet_infoline( " UtcDaliPopupDestructorP" );
247 Popup* popup = new Popup();
250 DALI_TEST_CHECK( true );
254 int UtcDaliPopupDownCastP(void)
256 ToolkitTestApplication application;
257 tet_infoline( " UtcDaliPopupDownCastP" );
259 Handle handle = Popup::New();
261 Popup popup = Popup::DownCast( handle );
263 DALI_TEST_CHECK( popup == handle );
267 int UtcDaliPopupSetPropertyP(void)
269 ToolkitTestApplication application;
270 tet_infoline( " UtcDaliPopupSetProperty" );
272 Popup popup = Popup::New();
275 std::string testString = "Hello World";
277 TextLabel textActorIn = TextLabel::New( testString );
279 Scripting::CreatePropertyMap( textActorIn, map );
280 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
281 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
282 std::string resultText;
283 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
284 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
289 int UtcDaliPopupSetTitleP(void)
291 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
292 tet_infoline( " UtcDaliPopupSetTitleP" );
294 // Create the Popup actor
295 Popup popup = Popup::New();
297 // Put in show state so it's layer is connected to popup (for ancestor check).
298 popup.SetDisplayState( Popup::SHOWN );
300 TextLabel titleActor = TextLabel::New();
301 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
303 DALI_TEST_CHECK( !popup.GetTitle() );
304 popup.SetTitle( titleActor );
305 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
306 DALI_TEST_CHECK( textActor == titleActor );
308 std::string resultText;
309 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
311 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
312 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
313 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
315 TextLabel titleActor2 = TextLabel::New();
316 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
317 popup.SetTitle( titleActor2 );
318 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
319 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
320 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
322 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
324 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
325 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
329 int UtcDaliPopupSetTitleN(void)
331 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
332 tet_infoline( " UtcDaliPopupSetTitleN" );
334 // Create the Popup actor
335 Popup popup = Popup::New();
337 TextLabel titleActor = TextLabel::New( "text" );
338 popup.SetTitle( titleActor );
340 DALI_TEST_CHECK( popup.GetTitle() );
342 // Set a bad title value.
343 // Confirm this has disabled the title.
345 popup.SetTitle( badActor );
347 DALI_TEST_CHECK( !popup.GetTitle() );
352 int UtcDaliPopupSetContentP(void)
354 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
355 tet_infoline( " UtcDaliPopupSetContentP" );
357 // Create the Popup actor
358 Popup popup = Popup::New();
359 Stage::GetCurrent().Add( popup );
360 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
362 // Put in show state so it's layer is connected to popup (for ancestor check).
363 popup.SetDisplayState( Popup::SHOWN );
365 PushButton button = PushButton::New();
366 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
367 popup.SetFooter( button );
368 // Hide and then re-show popup to cause button to be rearranged and added to popup.
369 popup.SetDisplayState( Popup::HIDDEN );
370 popup.SetDisplayState( Popup::SHOWN );
371 DALI_TEST_CHECK( HasAncestor( button, popup ) );
375 int UtcDaliPopupSetContentN(void)
377 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
378 tet_infoline( " UtcDaliPopupSetContentN" );
380 // Create the Popup actor
381 Popup popup = Popup::New();
383 TextLabel content = TextLabel::New( "text" );
384 popup.SetContent( content );
386 DALI_TEST_CHECK( popup.GetContent() );
388 // Set a bad title value.
390 popup.SetContent( badActor );
392 DALI_TEST_CHECK( !popup.GetContent() );
397 int UtcDaliPopupSetFooterP(void)
399 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
400 tet_infoline(" UtcDaliPopupSetFooterP");
402 // Create the Popup actor
403 Popup popup = Popup::New();
404 Stage::GetCurrent().Add( popup );
405 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
406 // Put in show state so it's layer is connected to popup (for ancestor check).
407 popup.SetDisplayState( Popup::SHOWN );
409 PushButton button = PushButton::New();
410 DALI_TEST_CHECK( !HasAncestor(button, popup) );
411 popup.SetFooter( button );
412 // Hide and then re-show popup to cause button to be rearranged and added to popup.
413 popup.SetDisplayState( Popup::HIDDEN );
414 popup.SetDisplayState( Popup::SHOWN );
415 DALI_TEST_CHECK( HasAncestor( button, popup ) );
419 int UtcDaliPopupSetFooterN(void)
421 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
422 tet_infoline(" UtcDaliPopupSetFooterN");
424 // Create the Popup actor
425 Popup popup = Popup::New();
427 PushButton button = PushButton::New();
428 popup.SetFooter( button );
430 DALI_TEST_CHECK( popup.GetFooter() );
432 // Set a bad title value.
434 popup.SetFooter( badActor );
436 DALI_TEST_CHECK( !popup.GetFooter() );
441 int UtcDaliPopupSetControlFooterMultiple(void)
443 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
444 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
446 // Create the Popup actor
447 Popup popup = Popup::New();
448 Stage::GetCurrent().Add( popup );
449 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
450 // Put in show state so it's layer is connected to popup (for ancestor check).
451 popup.SetDisplayState( Popup::SHOWN );
453 Actor container = Actor::New();
454 PushButton button1 = PushButton::New();
455 PushButton button2 = PushButton::New();
456 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
457 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
458 container.Add( button1 );
459 container.Add( button2 );
460 popup.SetFooter( container );
462 // Hide and then re-show popup to cause button to be rearranged and added to popup.
463 popup.SetDisplayState( Popup::HIDDEN );
464 popup.SetDisplayState( Popup::SHOWN );
465 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
466 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
470 int UtcDaliPopupSetTitleAndFooter(void)
472 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
473 tet_infoline( " UtcDaliPopupSetTitleAndFooter" );
475 // Create the Popup actor
476 Popup popup = Popup::New();
478 // Put in show state so it's layer is connected to popup (for ancestor check).
479 popup.SetDisplayState( Popup::SHOWN );
482 TextLabel titleActor = TextLabel::New();
483 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
485 DALI_TEST_CHECK( !popup.GetTitle() );
486 popup.SetTitle( titleActor );
487 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
488 DALI_TEST_CHECK( textActor == titleActor );
490 std::string resultText;
491 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
492 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
493 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
494 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
497 PushButton button = PushButton::New();
498 DALI_TEST_CHECK( !HasAncestor(button, popup) );
499 popup.SetFooter( button );
500 // Hide and then re-show popup to cause button to be rearranged and added to popup.
501 popup.SetDisplayState( Popup::HIDDEN );
502 popup.SetDisplayState( Popup::SHOWN );
503 DALI_TEST_CHECK( HasAncestor( button, popup ) );
508 int UtcDaliPopupSetStateP(void)
510 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
511 tet_infoline(" UtcDaliPopupSetStateP");
513 // Create the Popup actor
514 Popup popup = Popup::New();
516 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
518 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
520 popup.SetDisplayState( Popup::SHOWN );
521 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
523 popup.SetDisplayState( Popup::HIDDEN );
524 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
528 int UtcDaliPopupSetStateN(void)
530 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
531 tet_infoline(" UtcDaliPopupSetStateN");
533 // Create the Popup actor
534 Popup popup = Popup::New();
536 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
538 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
540 popup.SetDisplayState( Popup::SHOWN );
541 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
543 // Test cancelling a show before it has finished.
544 popup.SetDisplayState( Popup::HIDDEN );
545 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
549 int UtcDaliPopupDisplayStateSignal(void)
551 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
552 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
554 // Create the Popup actor
555 Popup popup = Popup::New();
556 ConnectStateSignals( popup );
558 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
559 popup.SetDisplayState( Popup::SHOWN );
560 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
561 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
563 // Wait for a while (allow animation to complete), and then check state.
564 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
566 application.SendNotification();
567 application.Render( RENDER_FRAME_INTERVAL );
570 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
571 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
574 popup.SetDisplayState( Popup::HIDDEN );
575 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
576 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
578 // Wait for a while (allow animation to complete), and then check state.
579 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
581 application.SendNotification();
582 application.Render( RENDER_FRAME_INTERVAL );
585 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
586 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
591 int UtcDaliPopupShowHide(void)
593 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
594 tet_infoline(" UtcDaliPopupShowHide");
596 // Create the Popup actor
597 Popup popup = Popup::New();
598 ConnectStateSignals( popup );
600 Actor container = Actor::New();
601 PushButton button1 = PushButton::New();
602 PushButton button2 = PushButton::New();
603 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
604 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
605 container.Add( button1 );
606 container.Add( button2 );
607 popup.SetFooter( container );
610 // Note: in most popup animation implementations show would result in
611 // popup being onstage immediately following Show(). However we can't
612 // assume for all. e.g. If one creates a animation with a delay.
613 popup.SetDisplayState( Popup::SHOWN );
615 // Wait for a while (allow animation to complete), and then check state.
616 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
618 application.SendNotification();
619 application.Render( RENDER_FRAME_INTERVAL );
623 popup.SetDisplayState( Popup::HIDDEN );
625 // Wait for a while (allow animation to complete), and then check state.
626 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
628 application.SendNotification();
629 application.Render(RENDER_FRAME_INTERVAL);
632 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
636 int UtcDaliPopupPropertyTailVisibility(void)
638 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
639 tet_infoline(" UtcDaliPopupShowHideTail");
641 // Create the Popup actor
642 Popup popup = Popup::New();
643 Stage::GetCurrent().Add( popup );
645 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
646 popup.SetDisplayState( Popup::SHOWN );
648 int withoutTailCount = DescendentCount( popup );
650 popup.SetDisplayState( Popup::HIDDEN );
652 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
653 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
654 popup.SetDisplayState( Popup::SHOWN );
656 int withTailCount = DescendentCount( popup );
658 // There should be more actors if the Tail has been added.
659 DALI_TEST_CHECK( withTailCount > withoutTailCount );
662 popup.SetDisplayState( Popup::HIDDEN );
663 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
664 popup.SetDisplayState( Popup::SHOWN );
665 int withoutTailCount2 = DescendentCount(popup);
667 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
671 int UtcDaliPopupOnTouchedOutsideSignal(void)
673 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
674 tet_infoline(" UtcDaliPopupOnTouchedOutside");
676 // Create the Popup actor
677 Popup popup = Popup::New();
678 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
679 popup.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER );
680 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
681 popup.SetSize( 50.0f, 50.0f );
682 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
683 Stage::GetCurrent().Add( popup );
684 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
685 popup.SetDisplayState( Popup::SHOWN );
687 application.SendNotification();
688 application.Render();
690 gTouchedOutside = false;
691 Dali::Integration::TouchEvent event;
693 event = Dali::Integration::TouchEvent();
694 event.AddPoint( GetPointDown() );
695 application.ProcessEvent( event );
697 application.SendNotification();
698 application.Render();
700 event = Dali::Integration::TouchEvent();
701 event.AddPoint( GetPointUp() );
702 application.ProcessEvent( event );
704 application.SendNotification();
705 application.Render();
707 // Confirm the signal is ignored if touch_transparent.
708 gTouchedOutside = false;
709 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
711 event = Dali::Integration::TouchEvent();
712 event.AddPoint( GetPointDown() );
713 application.ProcessEvent( event );
715 application.SendNotification();
716 application.Render();
718 event = Dali::Integration::TouchEvent();
719 event.AddPoint( GetPointUp() );
720 application.ProcessEvent( event );
722 application.SendNotification();
723 application.Render();
725 DALI_TEST_CHECK( !gTouchedOutside );
730 int UtcDaliPopupPropertyAutoHide(void)
732 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
733 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
735 // Create the Popup actor
736 Popup popup = Popup::New();
737 ConnectStateSignals( popup );
739 Actor container = Actor::New();
740 PushButton button1 = PushButton::New();
741 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
742 container.Add( button1 );
743 popup.SetFooter( container );
745 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
746 float getAnimationDuration = 0.0f;
747 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
748 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
750 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
751 int getAutoHideDelay = 0;
752 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
753 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
755 Stage::GetCurrent().Add( popup );
757 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
760 // Note: in most popup animation implementations show would result in
761 // popup being onstage immediately following Show(). However we can't
762 // assume for all. e.g. If one creates a animation with a delay.
763 popup.SetDisplayState( Popup::SHOWN );
765 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
767 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
769 application.SendNotification();
770 application.Render( RENDER_FRAME_INTERVAL );
773 // Force the timer used by the popup to expire,
774 // this will cause the popup to hide automatically.
775 Dali::Timer timer = Timer::New( 0 );
776 timer.MockEmitSignal();
778 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
784 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
786 int UtcDaliPopupPropertyAnimationMode(void)
788 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
789 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
791 // Create the Popup actor
792 Popup popup = Popup::New();
793 ConnectStateSignals( popup );
794 popup.SetTitle( TextLabel::New( "Title" ) );
795 Stage::GetCurrent().Add( popup );
797 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
799 // Try both default and zero animation duration, as zero has a special case for some animation types.
800 for( int j = 0; j <= 1; j++ )
802 // On the second loop, set duration to zero.
805 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
808 // Loop through 4 animation modes.
809 for( int i = 0; i < 4; i++ )
811 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
813 std::string checkMode;
814 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
816 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
818 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
819 std::string resultState;
821 // Only wait for animation if it isn't instant.
824 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
825 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
826 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
827 WaitAnimation( application );
830 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
831 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
832 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
833 popup.SetDisplayState( Popup::HIDDEN );
837 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
838 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
839 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
840 WaitAnimation( application );
843 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
844 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
845 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
852 int UtcDaliPopupPropertyTitle(void)
854 ToolkitTestApplication application;
855 tet_infoline( " UtcDaliPopupPropertyTitle" );
857 // Create the Popup actor
858 Popup popup = Popup::New();
860 std::string testLabelText = "TitleTest";
861 TextLabel titleLabel = TextLabel::New();
862 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
863 Actor title = titleLabel;
865 Scripting::CreatePropertyMap( title, map );
866 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
868 Property::Map resultMap;
869 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
871 Property::Value* resultProperty = resultMap.Find( "text" );
872 DALI_TEST_CHECK( resultProperty );
874 std::string resultText;
875 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
877 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
882 int UtcDaliPopupPropertyContent(void)
884 ToolkitTestApplication application;
885 tet_infoline( " UtcDaliPopupPropertyContent" );
887 // Create the Popup actor
888 Popup popup = Popup::New();
890 std::string testLabelText = "ContentTest";
891 TextLabel contentLabel = TextLabel::New();
892 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
893 Actor content = contentLabel;
895 Scripting::CreatePropertyMap( content, map );
896 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
898 Property::Map resultMap;
899 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
901 Property::Value* resultProperty = resultMap.Find( "text" );
902 DALI_TEST_CHECK( resultProperty );
904 std::string resultText;
905 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
907 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
912 int UtcDaliPopupPropertyFooter(void)
914 ToolkitTestApplication application;
915 tet_infoline( " UtcDaliPopupPropertyFooter" );
917 // Create the Popup actor
918 Popup popup = Popup::New();
920 std::string testLabelText = "FooterTest";
921 TextLabel footerLabel = TextLabel::New();
922 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
923 Actor footer = footerLabel;
925 Scripting::CreatePropertyMap( footer, map );
926 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
928 Property::Map resultMap;
929 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
931 Property::Value* resultProperty = resultMap.Find( "text" );
932 DALI_TEST_CHECK( resultProperty );
934 std::string resultText;
935 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
937 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
942 int UtcDaliPopupPropertyContextualMode(void)
944 ToolkitTestApplication application;
945 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
947 // Create the Popup actor
948 Popup popup = Popup::New();
949 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
950 std::string testLabelText = "ContentTest";
952 TextLabel contentLabel = TextLabel::New();
954 popup.SetContent( contentLabel );
956 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
957 Actor placement = Actor::New();
958 placement.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
959 placement.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
960 placement.SetSize( 1.0f, 1.0f );
961 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
962 Stage::GetCurrent().Add( placement );
964 placement.Add( popup );
966 // Test all contextual modes.
967 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
968 Vector2 offsetValues[5];
969 offsetValues[0] = Vector2( 0.375f, 0.0f );
970 offsetValues[1] = Vector2( -0.125f, -10.5f );
971 offsetValues[2] = Vector2( 10.875f, -0.5f );
972 offsetValues[3] = Vector2( -0.125f, 10.5f );
973 offsetValues[4] = Vector2( -10.875f, -0.5f );
975 for( int i = 0; i < 5; ++i )
977 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
979 std::string propertyResult;
980 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
981 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
983 popup.SetDisplayState( Popup::SHOWN );
984 application.SendNotification();
985 application.Render();
987 // Check the position of the label within the popup.
988 DALI_TEST_EQUALS( contentLabel.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).GetVectorXY(), offsetValues[i], TEST_LOCATION );
990 popup.SetDisplayState( Popup::HIDDEN );
991 application.SendNotification();
992 application.Render();
998 int UtcDaliPopupPropertyBacking(void)
1000 ToolkitTestApplication application;
1001 tet_infoline( " UtcDaliPopupPropertyBacking" );
1003 // Create the Popup actor
1004 Popup popup = Popup::New();
1005 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1006 Stage::GetCurrent().Add( popup );
1008 Actor backing = popup.FindChildByName( "popupBacking" );
1009 DALI_TEST_CHECK( backing );
1011 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1013 // Check enabled property.
1014 popup.SetDisplayState( Popup::SHOWN );
1015 application.SendNotification();
1016 application.Render();
1018 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1020 popup.SetDisplayState( Popup::HIDDEN );
1021 application.SendNotification();
1022 application.Render();
1024 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1026 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
1027 bool propertyResult;
1028 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
1029 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
1031 popup.SetDisplayState( Popup::SHOWN );
1032 application.SendNotification();
1033 application.Render();
1035 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1037 popup.SetDisplayState( Popup::HIDDEN );
1038 application.SendNotification();
1039 application.Render();
1041 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043 // Check color property.
1044 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1045 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1047 popup.SetDisplayState( Popup::SHOWN );
1048 application.SendNotification();
1049 application.Render();
1051 Vector4 resultColor;
1052 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1053 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1058 int UtcDaliPopupPropertyBackgroundImage(void)
1060 ToolkitTestApplication application;
1061 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1063 // Create the Popup actor
1064 Popup popup = Popup::New();
1065 Stage::GetCurrent().Add( popup );
1067 // Check setting an image
1068 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1069 std::string resultString;
1070 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1071 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1076 int UtcDaliPopupPropertyCustomAnimation(void)
1078 ToolkitTestApplication application;
1079 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1081 // Create the Popup actor
1082 Popup popup = Popup::New();
1083 TextLabel content = TextLabel::New( "text" );
1084 popup.SetContent( content );
1086 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1087 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1089 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1090 DALI_TEST_CHECK( popupContainer );
1092 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1093 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1095 Property::Map animationMapEntry;
1096 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1097 animationMapEntry.Insert( "property", "position" );
1098 animationMapEntry.Insert( "value", entryAnimationDestination );
1099 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1101 Property::Array timePeriodMapEntry;
1102 timePeriodMapEntry.PushBack( 0.0f );
1103 timePeriodMapEntry.PushBack( 1.0f );
1105 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1107 Property::Map animationMapExit;
1108 animationMapExit.Insert( "actor", "customAnimationPopup" );
1109 animationMapExit.Insert( "property", "position" );
1110 animationMapExit.Insert( "value", exitAnimationDestination );
1111 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1113 Property::Array timePeriodMapExit;
1114 timePeriodMapExit.PushBack( 0.0f );
1115 timePeriodMapExit.PushBack( 1.0f );
1117 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1119 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1120 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1122 Property::Map resultMap;
1123 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1124 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1125 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1126 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1128 Stage::GetCurrent().Add( popup );
1129 popup.SetDisplayState( Popup::SHOWN );
1131 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1133 application.SendNotification();
1134 application.Render( RENDER_FRAME_INTERVAL );
1137 // Test the popup has animated to it's entry-transition destination.
1138 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), entryAnimationDestination, 0.1f, TEST_LOCATION );
1140 popup.SetDisplayState( Popup::HIDDEN );
1142 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1144 application.SendNotification();
1145 application.Render( RENDER_FRAME_INTERVAL );
1148 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), exitAnimationDestination, 0.1f, TEST_LOCATION );
1153 static bool gPushButtonClicked;
1154 static bool PushButtonClicked( Button button )
1156 gPushButtonClicked = true;
1160 int UtcDaliPopupPropertyTouchTransparent(void)
1162 ToolkitTestApplication application;
1163 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1165 // Create the Popup actor
1166 Popup popup = Popup::New();
1167 TextLabel content = TextLabel::New( "text" );
1168 popup.SetContent( content );
1169 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1170 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1171 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1172 popup.SetSize( 100, 100 );
1173 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1175 // Create a button (to go underneath the popup).
1176 PushButton button = Toolkit::PushButton::New();
1177 button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1178 button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1179 button.SetSize( 100, 100 );
1180 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1182 button.ClickedSignal().Connect( &PushButtonClicked );
1184 Stage::GetCurrent().Add( button );
1186 button.Add( popup );
1188 popup.SetDisplayState( Popup::SHOWN );
1189 application.SendNotification();
1190 application.Render();
1192 gPushButtonClicked = false;
1193 Dali::Integration::TouchEvent event;
1195 // Perform a click, the popup should block the click from hitting the button.
1196 event = Dali::Integration::TouchEvent();
1197 event.AddPoint( GetPointDown() );
1198 application.ProcessEvent( event );
1199 application.SendNotification();
1200 application.Render();
1202 event = Dali::Integration::TouchEvent();
1203 event.AddPoint( GetPointUp() );
1204 application.ProcessEvent( event );
1205 application.SendNotification();
1206 application.Render();
1208 DALI_TEST_CHECK( !gPushButtonClicked );
1210 // Enable touch transparency.
1211 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1212 bool propertyResult;
1213 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1214 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1216 // Perform a click, the popup should allow the click to travel through to the button.
1217 event = Dali::Integration::TouchEvent();
1218 event.AddPoint( GetPointDown() );
1219 application.ProcessEvent( event );
1220 application.SendNotification();
1221 application.Render();
1223 event = Dali::Integration::TouchEvent();
1224 event.AddPoint( GetPointUp() );
1225 application.ProcessEvent( event );
1226 application.SendNotification();
1227 application.Render();
1229 DALI_TEST_CHECK( gPushButtonClicked );
1234 int UtcDaliPopupPropertyTail(void)
1236 ToolkitTestApplication application;
1237 tet_infoline( " UtcDaliPopupPropertyTail" );
1239 // Create the Popup actor
1240 Popup popup = Popup::New();
1241 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1242 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1243 popup.SetSize( 100, 100 );
1244 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1245 TextLabel content = TextLabel::New( "text" );
1246 popup.SetContent( content );
1248 std::string imageFilename = "invalid-image.jpg";
1249 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1250 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1251 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1252 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1254 std::string resultString;
1255 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1256 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1257 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1258 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1259 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1260 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1261 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1262 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1264 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1266 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1267 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1270 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1272 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1273 Vector3 vectorResult;
1274 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1275 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1277 Stage::GetCurrent().Add( popup );
1279 popup.SetDisplayState( Popup::SHOWN );
1280 application.SendNotification();
1281 application.Render();
1282 tailActor = popup.FindChildByName( "tailImage" );
1283 DALI_TEST_CHECK( tailActor );
1285 float baseValX = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x;
1287 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, TEST_LOCATION );
1289 popup.SetDisplayState( Popup::HIDDEN );
1290 application.SendNotification();
1291 application.Render();
1293 tailPosition = ParentOrigin::CENTER_LEFT;
1294 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1296 popup.SetDisplayState( Popup::SHOWN );
1297 application.SendNotification();
1298 application.Render();
1299 tailActor = popup.FindChildByName( "tailImage" );
1300 DALI_TEST_CHECK( tailActor );
1302 float baseValY = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y;
1303 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, TEST_LOCATION );
1305 popup.SetDisplayState( Popup::HIDDEN );
1306 application.SendNotification();
1307 application.Render();
1309 tailPosition = ParentOrigin::BOTTOM_CENTER;
1310 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1312 popup.SetDisplayState( Popup::SHOWN );
1313 application.SendNotification();
1314 application.Render();
1315 tailActor = popup.FindChildByName( "tailImage" );
1316 DALI_TEST_CHECK( tailActor );
1317 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1318 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1320 popup.SetDisplayState( Popup::HIDDEN );
1321 application.SendNotification();
1322 application.Render();
1324 tailPosition = ParentOrigin::CENTER_RIGHT;
1325 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1327 popup.SetDisplayState( Popup::SHOWN );
1328 application.SendNotification();
1329 application.Render();
1330 tailActor = popup.FindChildByName( "tailImage" );
1331 DALI_TEST_CHECK( tailActor );
1332 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1333 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1335 popup.SetDisplayState( Popup::HIDDEN );
1336 application.SendNotification();
1337 application.Render();
1342 int UtcDaliPopupTypeToast(void)
1344 ToolkitTestApplication application;
1345 tet_infoline( " UtcDaliPopupTypeToast" );
1347 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1348 DALI_TEST_CHECK( typeInfo )
1350 BaseHandle baseHandle = typeInfo.CreateInstance();
1351 DALI_TEST_CHECK( baseHandle )
1353 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1354 gPopupState = Toolkit::Popup::HIDDEN;
1355 ConnectStateSignals( popup );
1356 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1358 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1359 Stage::GetCurrent().Add( popup );
1360 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1362 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1364 application.SendNotification();
1365 application.Render( RENDER_FRAME_INTERVAL );
1368 // Check the toast popup is shown.
1369 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1371 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1373 application.SendNotification();
1374 application.Render( RENDER_FRAME_INTERVAL );
1377 // Check the toast popup hides.
1378 Dali::Timer timer = Timer::New( 0 );
1379 timer.MockEmitSignal();
1381 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1383 application.SendNotification();
1384 application.Render( RENDER_FRAME_INTERVAL );
1387 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1392 int UtcDaliPopupTypeRegistryCreation(void)
1394 ToolkitTestApplication application;
1395 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1397 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1398 DALI_TEST_CHECK( typeInfo )
1400 BaseHandle baseHandle = typeInfo.CreateInstance();
1401 DALI_TEST_CHECK( baseHandle )
1403 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1404 gPopupState = Toolkit::Popup::HIDDEN;
1405 ConnectStateSignals( popup );
1406 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1408 Stage::GetCurrent().Add( popup );
1409 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1411 application.SendNotification();
1412 application.Render();
1414 // Check the popup is shown.
1415 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1420 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1422 ToolkitTestApplication application;
1423 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1425 // Create the Popup actor
1426 Popup popup = Popup::New();
1428 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1429 // Note: The emmision of this signals has already been tested in other tests.
1430 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1431 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1432 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1433 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1434 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1436 // Test connecting to an invalid signal does not work.
1437 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1442 int UtcDaliPopupOnControlChildAdd(void)
1444 ToolkitTestApplication application;
1445 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1447 // Create the Popup actor
1448 Popup popup = Popup::New();
1449 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1450 std::string testLabelText = "ContentTest";
1451 TextLabel contentLabel = TextLabel::New( testLabelText );
1453 popup.Add( contentLabel );
1455 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1460 int UtcDaliPopupOnKeyEvent(void)
1462 ToolkitTestApplication application;
1463 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1465 // Create the Popup actor
1466 Popup popup = Popup::New();
1467 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1468 Stage::GetCurrent().Add( popup );
1470 popup.SetDisplayState( Popup::SHOWN );
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1476 popup.SetKeyInputFocus();
1478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
1479 application.SendNotification();
1480 application.Render();
1482 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1487 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1489 ToolkitTestApplication application;
1491 tet_infoline( "Set the background border property of a popup & retrieve it" );
1492 Popup popup = Popup::New();
1494 Rect< int > rect( 40, 30, 20, 10 );
1495 tet_infoline( "Ensure value we want to set is different from what is already set" );
1496 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1498 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1499 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1500 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1502 tet_infoline( "Set a vector4 as well which should also work" );
1503 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1504 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1505 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );