2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 // Need to override adaptor classes for toolkit test harness, so include
21 // test harness headers before dali headers.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include "dali-toolkit-test-utils/toolkit-timer.h"
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/devel-api/scripting/scripting.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/popup/popup.h>
33 using namespace Toolkit;
35 void utc_dali_toolkit_popup_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_popup_cleanup(void)
42 test_return_value = TET_PASS;
47 static bool gObjectCreatedCallBackCalled;
49 static void TestCallback(BaseHandle handle)
51 gObjectCreatedCallBackCalled = true;
54 const int RENDER_FRAME_INTERVAL = 10; ///< Duration of each frame in ms.
55 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation.
56 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
57 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
59 Dali::Integration::Point GetPointDown()
61 Dali::Integration::Point point;
62 point.SetState( PointState::DOWN );
63 point.SetScreenPosition( Vector2( 10, 10 ) );
67 Dali::Integration::Point GetPointUp()
69 Dali::Integration::Point point;
70 point.SetState( PointState::UP );
71 point.SetScreenPosition( Vector2( 10, 10 ) );
76 * Counts how many descendants root Actor has, including
79 * @param[in] root The root actor to count from.
80 * @return The number of descendants including root actor itself.
82 int DescendentCount( const Actor& root )
84 unsigned int numChildren = root.GetChildCount();
88 for( unsigned int i = 0; i < numChildren; ++i )
90 count += DescendentCount( root.GetChildAt( i ) );
96 bool HasAncestor( Actor child, Actor ancestor )
98 while( child && child != ancestor )
100 child = child.GetParent();
103 return ( child == ancestor );
106 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
107 static bool gTouchedOutside;
111 static void OnPopupTouchedOutside()
113 gTouchedOutside = true;
116 static void OnPopupShowing()
118 gPopupState = Toolkit::Popup::SHOWING;
121 static void OnPopupShown()
123 gPopupState = Toolkit::Popup::SHOWN;
126 static void OnPopupHiding()
128 gPopupState = Toolkit::Popup::HIDING;
131 static void OnPopupHidden()
133 gPopupState = Toolkit::Popup::HIDDEN;
136 void ConnectStateSignals( Toolkit::Popup popup )
138 popup.ShowingSignal().Connect( &OnPopupShowing );
139 popup.ShownSignal().Connect( &OnPopupShown );
140 popup.HidingSignal().Connect( &OnPopupHiding );
141 popup.HiddenSignal().Connect( &OnPopupHidden );
144 void WaitAnimation( ToolkitTestApplication& application )
146 // Wait for a while (allow animation to complete), and then check state.
147 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
149 application.SendNotification();
150 application.Render( RENDER_FRAME_INTERVAL );
155 * A connection tracker is required when connecting to a signal with a functor.
157 class TestConnectionTrackerObject : public ConnectionTracker
162 * This functor is used to test the popup's signal connection.
164 struct PopupTestFunctor
175 // Generate a KeyEvent to send to Core.
176 Integration::KeyEvent GenerateKey( const std::string& keyName,
177 const std::string& keyString,
180 unsigned long timeStamp,
181 const Integration::KeyEvent::State& keyState,
182 const std::string& compose = "",
183 const std::string& deviceName = "",
184 const Device::Class::Type& deviceClass = Device::Class::NONE,
185 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE
188 return Integration::KeyEvent( keyName,
200 } // Anonymous namespace
203 * This test checks popup creation.
205 int UtcDaliPopupNewP( void )
207 ToolkitTestApplication application;
208 tet_infoline( " UtcDaliPopupNewP" );
210 // Create the Popup actor.
213 DALI_TEST_CHECK( !popup );
215 popup = Popup::New();
217 DALI_TEST_CHECK( popup );
219 Popup popup2( popup );
221 DALI_TEST_CHECK( popup2 == popup );
223 // Additional check to ensure object is created by checking if it's registered.
224 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
225 DALI_TEST_CHECK( registry );
227 gObjectCreatedCallBackCalled = false;
228 registry.ObjectCreatedSignal().Connect( &TestCallback );
230 Popup popup = Popup::New();
232 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
237 * This test checks popup destruction.
239 int UtcDaliPopupDestructorP( void )
241 ToolkitTestApplication application;
242 tet_infoline( " UtcDaliPopupDestructorP" );
244 Popup* popup = new Popup();
247 DALI_TEST_CHECK( true );
251 int UtcDaliPopupDownCastP(void)
253 ToolkitTestApplication application;
254 tet_infoline( " UtcDaliPopupDownCastP" );
256 Handle handle = Popup::New();
258 Popup popup = Popup::DownCast( handle );
260 DALI_TEST_CHECK( popup == handle );
264 int UtcDaliPopupSetPropertyP(void)
266 ToolkitTestApplication application;
267 tet_infoline( " UtcDaliPopupSetProperty" );
269 Popup popup = Popup::New();
272 std::string testString = "Hello World";
274 TextLabel textActorIn = TextLabel::New( testString );
276 Scripting::CreatePropertyMap( textActorIn, map );
277 popup.SetProperty( popup.GetPropertyIndex( "title" ), map );
278 TextLabel textActorOut = TextLabel::DownCast( popup.GetTitle() );
279 std::string resultText;
280 DALI_TEST_CHECK( textActorOut.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
281 DALI_TEST_EQUALS( testString, resultText, TEST_LOCATION );
286 int UtcDaliPopupSetTitleP(void)
288 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
289 tet_infoline( " UtcDaliPopupSetTitleP" );
291 // Create the Popup actor
292 Popup popup = Popup::New();
294 // Put in show state so it's layer is connected to popup (for ancestor check).
295 popup.SetDisplayState( Popup::SHOWN );
297 TextLabel titleActor = TextLabel::New();
298 titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
300 DALI_TEST_CHECK( !popup.GetTitle() );
301 popup.SetTitle( titleActor );
302 TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
303 DALI_TEST_CHECK( textActor == titleActor );
305 std::string resultText;
306 DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
308 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
309 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
310 DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
312 TextLabel titleActor2 = TextLabel::New();
313 titleActor2.SetProperty( Toolkit::TextLabel::Property::TEXT, "anothertitle" );
314 popup.SetTitle( titleActor2 );
315 DALI_TEST_CHECK( popup.GetTitle() != titleActor );
316 DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
317 DALI_TEST_CHECK( TextLabel::DownCast( popup.GetTitle() ).GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
319 DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "anothertitle" ) );
321 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
322 DALI_TEST_CHECK( HasAncestor( titleActor2, popup ) );
326 int UtcDaliPopupSetTitleN(void)
328 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
329 tet_infoline( " UtcDaliPopupSetTitleN" );
331 // Create the Popup actor
332 Popup popup = Popup::New();
334 TextLabel titleActor = TextLabel::New( "text" );
335 popup.SetTitle( titleActor );
337 DALI_TEST_CHECK( popup.GetTitle() );
339 // Set a bad title value.
340 // Confirm this has disabled the title.
342 popup.SetTitle( badActor );
344 DALI_TEST_CHECK( !popup.GetTitle() );
349 int UtcDaliPopupSetContentP(void)
351 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
352 tet_infoline( " UtcDaliPopupSetContentP" );
354 // Create the Popup actor
355 Popup popup = Popup::New();
356 Stage::GetCurrent().Add( popup );
357 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
359 // Put in show state so it's layer is connected to popup (for ancestor check).
360 popup.SetDisplayState( Popup::SHOWN );
362 PushButton button = PushButton::New();
363 DALI_TEST_CHECK( !HasAncestor( button, popup ) );
364 popup.SetFooter( button );
365 // Hide and then re-show popup to cause button to be rearranged and added to popup.
366 popup.SetDisplayState( Popup::HIDDEN );
367 popup.SetDisplayState( Popup::SHOWN );
368 DALI_TEST_CHECK( HasAncestor( button, popup ) );
372 int UtcDaliPopupSetContentN(void)
374 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
375 tet_infoline( " UtcDaliPopupSetContentN" );
377 // Create the Popup actor
378 Popup popup = Popup::New();
380 TextLabel content = TextLabel::New( "text" );
381 popup.SetContent( content );
383 DALI_TEST_CHECK( popup.GetContent() );
385 // Set a bad title value.
387 popup.SetContent( badActor );
389 DALI_TEST_CHECK( !popup.GetContent() );
394 int UtcDaliPopupSetFooterP(void)
396 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
397 tet_infoline(" UtcDaliPopupSetFooterP");
399 // Create the Popup actor
400 Popup popup = Popup::New();
401 Stage::GetCurrent().Add( popup );
402 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
403 // Put in show state so it's layer is connected to popup (for ancestor check).
404 popup.SetDisplayState( Popup::SHOWN );
406 PushButton button = PushButton::New();
407 DALI_TEST_CHECK( !HasAncestor(button, popup) );
408 popup.SetFooter( button );
409 // Hide and then re-show popup to cause button to be rearranged and added to popup.
410 popup.SetDisplayState( Popup::HIDDEN );
411 popup.SetDisplayState( Popup::SHOWN );
412 DALI_TEST_CHECK( HasAncestor( button, popup ) );
416 int UtcDaliPopupSetFooterN(void)
418 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
419 tet_infoline(" UtcDaliPopupSetFooterN");
421 // Create the Popup actor
422 Popup popup = Popup::New();
424 PushButton button = PushButton::New();
425 popup.SetFooter( button );
427 DALI_TEST_CHECK( popup.GetFooter() );
429 // Set a bad title value.
431 popup.SetFooter( badActor );
433 DALI_TEST_CHECK( !popup.GetFooter() );
438 int UtcDaliPopupSetControlFooterMultiple(void)
440 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
441 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
443 // Create the Popup actor
444 Popup popup = Popup::New();
445 Stage::GetCurrent().Add( popup );
446 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
447 // Put in show state so it's layer is connected to popup (for ancestor check).
448 popup.SetDisplayState( Popup::SHOWN );
450 Actor container = Actor::New();
451 PushButton button1 = PushButton::New();
452 PushButton button2 = PushButton::New();
453 DALI_TEST_CHECK( !HasAncestor( button1, popup ) );
454 DALI_TEST_CHECK( !HasAncestor( button2, popup ) );
455 container.Add( button1 );
456 container.Add( button2 );
457 popup.SetFooter( container );
459 // Hide and then re-show popup to cause button to be rearranged and added to popup.
460 popup.SetDisplayState( Popup::HIDDEN );
461 popup.SetDisplayState( Popup::SHOWN );
462 DALI_TEST_CHECK( HasAncestor( button1, popup ) );
463 DALI_TEST_CHECK( HasAncestor( button2, popup ) );
467 int UtcDaliPopupSetStateP(void)
469 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
470 tet_infoline(" UtcDaliPopupSetStateP");
472 // Create the Popup actor
473 Popup popup = Popup::New();
475 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
477 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
479 popup.SetDisplayState( Popup::SHOWN );
480 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
482 popup.SetDisplayState( Popup::HIDDEN );
483 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
487 int UtcDaliPopupSetStateN(void)
489 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
490 tet_infoline(" UtcDaliPopupSetStateN");
492 // Create the Popup actor
493 Popup popup = Popup::New();
495 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
497 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
499 popup.SetDisplayState( Popup::SHOWN );
500 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
502 // Test cancelling a show before it has finished.
503 popup.SetDisplayState( Popup::HIDDEN );
504 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
508 int UtcDaliPopupDisplayStateSignal(void)
510 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
511 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
513 // Create the Popup actor
514 Popup popup = Popup::New();
515 ConnectStateSignals( popup );
517 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
518 popup.SetDisplayState( Popup::SHOWN );
519 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
520 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
522 // Wait for a while (allow animation to complete), and then check state.
523 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
525 application.SendNotification();
526 application.Render( RENDER_FRAME_INTERVAL );
529 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
530 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
533 popup.SetDisplayState( Popup::HIDDEN );
534 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
535 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
537 // Wait for a while (allow animation to complete), and then check state.
538 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
540 application.SendNotification();
541 application.Render( RENDER_FRAME_INTERVAL );
544 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
545 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
550 int UtcDaliPopupShowHide(void)
552 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
553 tet_infoline(" UtcDaliPopupShowHide");
555 // Create the Popup actor
556 Popup popup = Popup::New();
557 ConnectStateSignals( popup );
559 Actor container = Actor::New();
560 PushButton button1 = PushButton::New();
561 PushButton button2 = PushButton::New();
562 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
563 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
564 container.Add( button1 );
565 container.Add( button2 );
566 popup.SetFooter( container );
569 // Note: in most popup animation implementations show would result in
570 // popup being onstage immediately following Show(). However we can't
571 // assume for all. e.g. If one creates a animation with a delay.
572 popup.SetDisplayState( Popup::SHOWN );
574 // Wait for a while (allow animation to complete), and then check state.
575 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
577 application.SendNotification();
578 application.Render( RENDER_FRAME_INTERVAL );
582 popup.SetDisplayState( Popup::HIDDEN );
584 // Wait for a while (allow animation to complete), and then check state.
585 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
587 application.SendNotification();
588 application.Render(RENDER_FRAME_INTERVAL);
591 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
595 int UtcDaliPopupPropertyTailVisibility(void)
597 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
598 tet_infoline(" UtcDaliPopupShowHideTail");
600 // Create the Popup actor
601 Popup popup = Popup::New();
602 Stage::GetCurrent().Add( popup );
604 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
605 popup.SetDisplayState( Popup::SHOWN );
607 int withoutTailCount = DescendentCount( popup );
609 popup.SetDisplayState( Popup::HIDDEN );
611 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
612 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
613 popup.SetDisplayState( Popup::SHOWN );
615 int withTailCount = DescendentCount( popup );
617 // There should be more actors if the Tail has been added.
618 DALI_TEST_CHECK( withTailCount > withoutTailCount );
621 popup.SetDisplayState( Popup::HIDDEN );
622 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
623 popup.SetDisplayState( Popup::SHOWN );
624 int withoutTailCount2 = DescendentCount(popup);
626 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
630 int UtcDaliPopupOnTouchedOutsideSignal(void)
632 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
633 tet_infoline(" UtcDaliPopupOnTouchedOutside");
635 // Create the Popup actor
636 Popup popup = Popup::New();
637 popup.SetParentOrigin( ParentOrigin::CENTER );
638 popup.SetAnchorPoint( ParentOrigin::CENTER );
639 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
640 popup.SetSize( 50.0f, 50.0f );
641 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
642 Stage::GetCurrent().Add( popup );
643 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
644 popup.SetDisplayState( Popup::SHOWN );
646 application.SendNotification();
647 application.Render();
649 gTouchedOutside = false;
650 Dali::Integration::TouchEvent event;
652 event = Dali::Integration::TouchEvent();
653 event.AddPoint( GetPointDown() );
654 application.ProcessEvent( event );
656 application.SendNotification();
657 application.Render();
659 event = Dali::Integration::TouchEvent();
660 event.AddPoint( GetPointUp() );
661 application.ProcessEvent( event );
663 application.SendNotification();
664 application.Render();
666 // Confirm the signal is ignored if touch_transparent.
667 gTouchedOutside = false;
668 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
670 event = Dali::Integration::TouchEvent();
671 event.AddPoint( GetPointDown() );
672 application.ProcessEvent( event );
674 application.SendNotification();
675 application.Render();
677 event = Dali::Integration::TouchEvent();
678 event.AddPoint( GetPointUp() );
679 application.ProcessEvent( event );
681 application.SendNotification();
682 application.Render();
684 DALI_TEST_CHECK( !gTouchedOutside );
689 int UtcDaliPopupPropertyAutoHide(void)
691 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
692 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
694 // Create the Popup actor
695 Popup popup = Popup::New();
696 ConnectStateSignals( popup );
698 Actor container = Actor::New();
699 PushButton button1 = PushButton::New();
700 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
701 container.Add( button1 );
702 popup.SetFooter( container );
704 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
705 float getAnimationDuration = 0.0f;
706 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
707 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
709 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
710 int getAutoHideDelay = 0;
711 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
712 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
714 Stage::GetCurrent().Add( popup );
716 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
719 // Note: in most popup animation implementations show would result in
720 // popup being onstage immediately following Show(). However we can't
721 // assume for all. e.g. If one creates a animation with a delay.
722 popup.SetDisplayState( Popup::SHOWN );
724 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
726 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
728 application.SendNotification();
729 application.Render( RENDER_FRAME_INTERVAL );
732 // Force the timer used by the popup to expire,
733 // this will cause the popup to hide automatically.
734 Dali::Timer timer = Timer::New( 0 );
735 timer.MockEmitSignal();
737 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
743 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
745 int UtcDaliPopupPropertyAnimationMode(void)
747 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
748 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
750 // Create the Popup actor
751 Popup popup = Popup::New();
752 ConnectStateSignals( popup );
753 popup.SetTitle( TextLabel::New( "Title" ) );
754 Stage::GetCurrent().Add( popup );
756 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
758 // Try both default and zero animation duration, as zero has a special case for some animation types.
759 for( int j = 0; j <= 1; j++ )
761 // On the second loop, set duration to zero.
764 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
767 // Loop through 4 animation modes.
768 for( int i = 0; i < 4; i++ )
770 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
772 std::string checkMode;
773 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
775 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
777 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
778 std::string resultState;
780 // Only wait for animation if it isn't instant.
783 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
784 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
785 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
786 WaitAnimation( application );
789 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
790 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
791 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
792 popup.SetDisplayState( Popup::HIDDEN );
796 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
797 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
798 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
799 WaitAnimation( application );
802 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
803 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
804 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
811 int UtcDaliPopupPropertyTitle(void)
813 ToolkitTestApplication application;
814 tet_infoline( " UtcDaliPopupPropertyTitle" );
816 // Create the Popup actor
817 Popup popup = Popup::New();
819 std::string testLabelText = "TitleTest";
820 TextLabel titleLabel = TextLabel::New();
821 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
822 Actor title = titleLabel;
824 Scripting::CreatePropertyMap( title, map );
825 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
827 Property::Map resultMap;
828 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
830 Property::Value* resultProperty = resultMap.Find( "text" );
831 DALI_TEST_CHECK( resultProperty );
833 std::string resultText;
834 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
836 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
841 int UtcDaliPopupPropertyContent(void)
843 ToolkitTestApplication application;
844 tet_infoline( " UtcDaliPopupPropertyContent" );
846 // Create the Popup actor
847 Popup popup = Popup::New();
849 std::string testLabelText = "ContentTest";
850 TextLabel contentLabel = TextLabel::New();
851 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
852 Actor content = contentLabel;
854 Scripting::CreatePropertyMap( content, map );
855 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
857 Property::Map resultMap;
858 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
860 Property::Value* resultProperty = resultMap.Find( "text" );
861 DALI_TEST_CHECK( resultProperty );
863 std::string resultText;
864 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
866 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
871 int UtcDaliPopupPropertyFooter(void)
873 ToolkitTestApplication application;
874 tet_infoline( " UtcDaliPopupPropertyFooter" );
876 // Create the Popup actor
877 Popup popup = Popup::New();
879 std::string testLabelText = "FooterTest";
880 TextLabel footerLabel = TextLabel::New();
881 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
882 Actor footer = footerLabel;
884 Scripting::CreatePropertyMap( footer, map );
885 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
887 Property::Map resultMap;
888 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
890 Property::Value* resultProperty = resultMap.Find( "text" );
891 DALI_TEST_CHECK( resultProperty );
893 std::string resultText;
894 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
896 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
901 int UtcDaliPopupPropertyContextualMode(void)
903 ToolkitTestApplication application;
904 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
906 // Create the Popup actor
907 Popup popup = Popup::New();
908 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
909 std::string testLabelText = "ContentTest";
911 TextLabel contentLabel = TextLabel::New();
913 popup.SetContent( contentLabel );
915 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
916 Actor placement = Actor::New();
917 placement.SetParentOrigin( ParentOrigin::CENTER );
918 placement.SetAnchorPoint( AnchorPoint::CENTER );
919 placement.SetSize( 1.0f, 1.0f );
920 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
921 Stage::GetCurrent().Add( placement );
923 placement.Add( popup );
925 // Test all contextual modes.
926 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
927 Vector2 offsetValues[5];
928 offsetValues[0] = Vector2( 0.375f, 0.0f );
929 offsetValues[1] = Vector2( -0.125f, -10.5f );
930 offsetValues[2] = Vector2( 10.875f, -0.5f );
931 offsetValues[3] = Vector2( -0.125f, 10.5f );
932 offsetValues[4] = Vector2( -10.875f, -0.5f );
934 for( int i = 0; i < 5; ++i )
936 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
938 std::string propertyResult;
939 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
940 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
942 popup.SetDisplayState( Popup::SHOWN );
943 application.SendNotification();
944 application.Render();
946 // Check the position of the label within the popup.
947 DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION );
949 popup.SetDisplayState( Popup::HIDDEN );
950 application.SendNotification();
951 application.Render();
957 int UtcDaliPopupPropertyBacking(void)
959 ToolkitTestApplication application;
960 tet_infoline( " UtcDaliPopupPropertyBacking" );
962 // Create the Popup actor
963 Popup popup = Popup::New();
964 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
965 Stage::GetCurrent().Add( popup );
967 Actor backing = popup.FindChildByName( "popupBacking" );
968 DALI_TEST_CHECK( backing );
970 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
972 // Check enabled property.
973 popup.SetDisplayState( Popup::SHOWN );
974 application.SendNotification();
975 application.Render();
977 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
979 popup.SetDisplayState( Popup::HIDDEN );
980 application.SendNotification();
981 application.Render();
983 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
985 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
987 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
988 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
990 popup.SetDisplayState( Popup::SHOWN );
991 application.SendNotification();
992 application.Render();
994 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996 popup.SetDisplayState( Popup::HIDDEN );
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1002 // Check color property.
1003 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1004 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1006 popup.SetDisplayState( Popup::SHOWN );
1007 application.SendNotification();
1008 application.Render();
1010 Vector4 resultColor;
1011 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1012 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1017 int UtcDaliPopupPropertyBackgroundImage(void)
1019 ToolkitTestApplication application;
1020 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1022 // Create the Popup actor
1023 Popup popup = Popup::New();
1024 Stage::GetCurrent().Add( popup );
1026 // Check setting an image
1027 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1028 std::string resultString;
1029 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1030 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1035 int UtcDaliPopupPropertyCustomAnimation(void)
1037 ToolkitTestApplication application;
1038 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1040 // Create the Popup actor
1041 Popup popup = Popup::New();
1042 TextLabel content = TextLabel::New( "text" );
1043 popup.SetContent( content );
1045 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1046 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1048 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1049 DALI_TEST_CHECK( popupContainer );
1051 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1052 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1054 Property::Map animationMapEntry;
1055 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1056 animationMapEntry.Insert( "property", "position" );
1057 animationMapEntry.Insert( "value", entryAnimationDestination );
1058 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1060 Property::Array timePeriodMapEntry;
1061 timePeriodMapEntry.PushBack( 0.0f );
1062 timePeriodMapEntry.PushBack( 1.0f );
1064 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1066 Property::Map animationMapExit;
1067 animationMapExit.Insert( "actor", "customAnimationPopup" );
1068 animationMapExit.Insert( "property", "position" );
1069 animationMapExit.Insert( "value", exitAnimationDestination );
1070 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1072 Property::Array timePeriodMapExit;
1073 timePeriodMapExit.PushBack( 0.0f );
1074 timePeriodMapExit.PushBack( 1.0f );
1076 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1078 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1079 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1081 Property::Map resultMap;
1082 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1083 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1084 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1085 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1087 Stage::GetCurrent().Add( popup );
1088 popup.SetDisplayState( Popup::SHOWN );
1090 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1092 application.SendNotification();
1093 application.Render( RENDER_FRAME_INTERVAL );
1096 // Test the popup has animated to it's entry-transition destination.
1097 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION );
1099 popup.SetDisplayState( Popup::HIDDEN );
1101 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1103 application.SendNotification();
1104 application.Render( RENDER_FRAME_INTERVAL );
1107 DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION );
1112 static bool gPushButtonClicked;
1113 static bool PushButtonClicked( Button button )
1115 gPushButtonClicked = true;
1119 int UtcDaliPopupPropertyTouchTransparent(void)
1121 ToolkitTestApplication application;
1122 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1124 // Create the Popup actor
1125 Popup popup = Popup::New();
1126 TextLabel content = TextLabel::New( "text" );
1127 popup.SetContent( content );
1128 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1129 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1130 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1131 popup.SetSize( 100, 100 );
1132 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1134 // Create a button (to go underneath the popup).
1135 PushButton button = Toolkit::PushButton::New();
1136 button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1137 button.SetParentOrigin( ParentOrigin::TOP_LEFT );
1138 button.SetSize( 100, 100 );
1139 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1141 button.ClickedSignal().Connect( &PushButtonClicked );
1143 Stage::GetCurrent().Add( button );
1145 button.Add( popup );
1147 popup.SetDisplayState( Popup::SHOWN );
1148 application.SendNotification();
1149 application.Render();
1151 gPushButtonClicked = false;
1152 Dali::Integration::TouchEvent event;
1154 // Perform a click, the popup should block the click from hitting the button.
1155 event = Dali::Integration::TouchEvent();
1156 event.AddPoint( GetPointDown() );
1157 application.ProcessEvent( event );
1158 application.SendNotification();
1159 application.Render();
1161 event = Dali::Integration::TouchEvent();
1162 event.AddPoint( GetPointUp() );
1163 application.ProcessEvent( event );
1164 application.SendNotification();
1165 application.Render();
1167 DALI_TEST_CHECK( !gPushButtonClicked );
1169 // Enable touch transparency.
1170 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1171 bool propertyResult;
1172 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1173 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1175 // Perform a click, the popup should allow the click to travel through to the button.
1176 event = Dali::Integration::TouchEvent();
1177 event.AddPoint( GetPointDown() );
1178 application.ProcessEvent( event );
1179 application.SendNotification();
1180 application.Render();
1182 event = Dali::Integration::TouchEvent();
1183 event.AddPoint( GetPointUp() );
1184 application.ProcessEvent( event );
1185 application.SendNotification();
1186 application.Render();
1188 DALI_TEST_CHECK( gPushButtonClicked );
1193 int UtcDaliPopupPropertyTail(void)
1195 ToolkitTestApplication application;
1196 tet_infoline( " UtcDaliPopupPropertyTail" );
1198 // Create the Popup actor
1199 Popup popup = Popup::New();
1200 popup.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1201 popup.SetParentOrigin( ParentOrigin::TOP_LEFT );
1202 popup.SetSize( 100, 100 );
1203 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1204 TextLabel content = TextLabel::New( "text" );
1205 popup.SetContent( content );
1207 std::string imageFilename = "invalid-image.jpg";
1208 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1209 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1210 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1211 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1213 std::string resultString;
1214 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1215 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1216 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1217 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1218 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1219 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1220 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1221 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1223 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1225 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1226 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1229 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1231 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1232 Vector3 vectorResult;
1233 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1234 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1236 Stage::GetCurrent().Add( popup );
1238 popup.SetDisplayState( Popup::SHOWN );
1239 application.SendNotification();
1240 application.Render();
1241 tailActor = popup.FindChildByName( "tailImage" );
1242 DALI_TEST_CHECK( tailActor );
1244 float baseValX = tailActor.GetCurrentWorldPosition().x;
1246 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION );
1248 popup.SetDisplayState( Popup::HIDDEN );
1249 application.SendNotification();
1250 application.Render();
1252 tailPosition = ParentOrigin::CENTER_LEFT;
1253 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1255 popup.SetDisplayState( Popup::SHOWN );
1256 application.SendNotification();
1257 application.Render();
1258 tailActor = popup.FindChildByName( "tailImage" );
1259 DALI_TEST_CHECK( tailActor );
1261 float baseValY = tailActor.GetCurrentWorldPosition().y;
1262 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION );
1264 popup.SetDisplayState( Popup::HIDDEN );
1265 application.SendNotification();
1266 application.Render();
1268 tailPosition = ParentOrigin::BOTTOM_CENTER;
1269 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1271 popup.SetDisplayState( Popup::SHOWN );
1272 application.SendNotification();
1273 application.Render();
1274 tailActor = popup.FindChildByName( "tailImage" );
1275 DALI_TEST_CHECK( tailActor );
1276 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1277 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1279 popup.SetDisplayState( Popup::HIDDEN );
1280 application.SendNotification();
1281 application.Render();
1283 tailPosition = ParentOrigin::CENTER_RIGHT;
1284 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1286 popup.SetDisplayState( Popup::SHOWN );
1287 application.SendNotification();
1288 application.Render();
1289 tailActor = popup.FindChildByName( "tailImage" );
1290 DALI_TEST_CHECK( tailActor );
1291 DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION );
1292 DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION );
1294 popup.SetDisplayState( Popup::HIDDEN );
1295 application.SendNotification();
1296 application.Render();
1301 int UtcDaliPopupTypeToast(void)
1303 ToolkitTestApplication application;
1304 tet_infoline( " UtcDaliPopupTypeToast" );
1306 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1307 DALI_TEST_CHECK( typeInfo )
1309 BaseHandle baseHandle = typeInfo.CreateInstance();
1310 DALI_TEST_CHECK( baseHandle )
1312 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1313 gPopupState = Toolkit::Popup::HIDDEN;
1314 ConnectStateSignals( popup );
1315 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1317 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1318 Stage::GetCurrent().Add( popup );
1319 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1321 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1323 application.SendNotification();
1324 application.Render( RENDER_FRAME_INTERVAL );
1327 // Check the toast popup is shown.
1328 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1330 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1332 application.SendNotification();
1333 application.Render( RENDER_FRAME_INTERVAL );
1336 // Check the toast popup hides.
1337 Dali::Timer timer = Timer::New( 0 );
1338 timer.MockEmitSignal();
1340 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1342 application.SendNotification();
1343 application.Render( RENDER_FRAME_INTERVAL );
1346 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1351 int UtcDaliPopupTypeRegistryCreation(void)
1353 ToolkitTestApplication application;
1354 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1356 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1357 DALI_TEST_CHECK( typeInfo )
1359 BaseHandle baseHandle = typeInfo.CreateInstance();
1360 DALI_TEST_CHECK( baseHandle )
1362 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1363 gPopupState = Toolkit::Popup::HIDDEN;
1364 ConnectStateSignals( popup );
1365 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1367 Stage::GetCurrent().Add( popup );
1368 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1370 application.SendNotification();
1371 application.Render();
1373 // Check the popup is shown.
1374 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1379 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1381 ToolkitTestApplication application;
1382 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1384 // Create the Popup actor
1385 Popup popup = Popup::New();
1387 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1388 // Note: The emmision of this signals has already been tested in other tests.
1389 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1390 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1391 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1392 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1393 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1395 // Test connecting to an invalid signal does not work.
1396 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1401 int UtcDaliPopupOnControlChildAdd(void)
1403 ToolkitTestApplication application;
1404 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1406 // Create the Popup actor
1407 Popup popup = Popup::New();
1408 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1409 std::string testLabelText = "ContentTest";
1410 TextLabel contentLabel = TextLabel::New( testLabelText );
1412 popup.Add( contentLabel );
1414 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1419 int UtcDaliPopupOnKeyEvent(void)
1421 ToolkitTestApplication application;
1422 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1424 // Create the Popup actor
1425 Popup popup = Popup::New();
1426 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1427 Stage::GetCurrent().Add( popup );
1429 popup.SetDisplayState( Popup::SHOWN );
1430 application.SendNotification();
1431 application.Render();
1433 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1435 popup.SetKeyInputFocus();
1437 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
1438 application.SendNotification();
1439 application.Render();
1441 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1446 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1448 ToolkitTestApplication application;
1450 tet_infoline( "Set the background border property of a popup & retrieve it" );
1451 Popup popup = Popup::New();
1453 Rect< int > rect( 40, 30, 20, 10 );
1454 tet_infoline( "Ensure value we want to set is different from what is already set" );
1455 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1457 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1458 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1459 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1461 tet_infoline( "Set a vector4 as well which should also work" );
1462 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1463 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1464 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );