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/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 UtcDaliPopupSetStateP(void)
472 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
473 tet_infoline(" UtcDaliPopupSetStateP");
475 // Create the Popup actor
476 Popup popup = Popup::New();
478 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
480 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
482 popup.SetDisplayState( Popup::SHOWN );
483 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
485 popup.SetDisplayState( Popup::HIDDEN );
486 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
490 int UtcDaliPopupSetStateN(void)
492 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
493 tet_infoline(" UtcDaliPopupSetStateN");
495 // Create the Popup actor
496 Popup popup = Popup::New();
498 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
500 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
502 popup.SetDisplayState( Popup::SHOWN );
503 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
505 // Test cancelling a show before it has finished.
506 popup.SetDisplayState( Popup::HIDDEN );
507 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
511 int UtcDaliPopupDisplayStateSignal(void)
513 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
514 tet_infoline( " UtcDaliPopupDisplayStateSignal" );
516 // Create the Popup actor
517 Popup popup = Popup::New();
518 ConnectStateSignals( popup );
520 popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f );
521 popup.SetDisplayState( Popup::SHOWN );
522 DALI_TEST_EQUALS( Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION );
523 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
525 // Wait for a while (allow animation to complete), and then check state.
526 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
528 application.SendNotification();
529 application.Render( RENDER_FRAME_INTERVAL );
532 DALI_TEST_EQUALS( Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION );
533 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
536 popup.SetDisplayState( Popup::HIDDEN );
537 DALI_TEST_EQUALS( Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION );
538 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
540 // Wait for a while (allow animation to complete), and then check state.
541 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
543 application.SendNotification();
544 application.Render( RENDER_FRAME_INTERVAL );
547 DALI_TEST_EQUALS( Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION );
548 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
553 int UtcDaliPopupShowHide(void)
555 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
556 tet_infoline(" UtcDaliPopupShowHide");
558 // Create the Popup actor
559 Popup popup = Popup::New();
560 ConnectStateSignals( popup );
562 Actor container = Actor::New();
563 PushButton button1 = PushButton::New();
564 PushButton button2 = PushButton::New();
565 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
566 button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
567 container.Add( button1 );
568 container.Add( button2 );
569 popup.SetFooter( container );
572 // Note: in most popup animation implementations show would result in
573 // popup being onstage immediately following Show(). However we can't
574 // assume for all. e.g. If one creates a animation with a delay.
575 popup.SetDisplayState( Popup::SHOWN );
577 // Wait for a while (allow animation to complete), and then check state.
578 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
580 application.SendNotification();
581 application.Render( RENDER_FRAME_INTERVAL );
585 popup.SetDisplayState( Popup::HIDDEN );
587 // Wait for a while (allow animation to complete), and then check state.
588 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
590 application.SendNotification();
591 application.Render(RENDER_FRAME_INTERVAL);
594 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
598 int UtcDaliPopupPropertyTailVisibility(void)
600 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
601 tet_infoline(" UtcDaliPopupShowHideTail");
603 // Create the Popup actor
604 Popup popup = Popup::New();
605 Stage::GetCurrent().Add( popup );
607 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
608 popup.SetDisplayState( Popup::SHOWN );
610 int withoutTailCount = DescendentCount( popup );
612 popup.SetDisplayState( Popup::HIDDEN );
614 popup.SetProperty( Popup::Property::TAIL_POSITION, "BOTTOM_CENTER" );
615 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
616 popup.SetDisplayState( Popup::SHOWN );
618 int withTailCount = DescendentCount( popup );
620 // There should be more actors if the Tail has been added.
621 DALI_TEST_CHECK( withTailCount > withoutTailCount );
624 popup.SetDisplayState( Popup::HIDDEN );
625 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
626 popup.SetDisplayState( Popup::SHOWN );
627 int withoutTailCount2 = DescendentCount(popup);
629 DALI_TEST_CHECK( withTailCount > withoutTailCount2 );
633 int UtcDaliPopupOnTouchedOutsideSignal(void)
635 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
636 tet_infoline(" UtcDaliPopupOnTouchedOutside");
638 // Create the Popup actor
639 Popup popup = Popup::New();
640 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
641 popup.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER );
642 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
643 popup.SetSize( 50.0f, 50.0f );
644 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
645 Stage::GetCurrent().Add( popup );
646 popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
647 popup.SetDisplayState( Popup::SHOWN );
649 application.SendNotification();
650 application.Render();
652 gTouchedOutside = false;
653 Dali::Integration::TouchEvent event;
655 event = Dali::Integration::TouchEvent();
656 event.AddPoint( GetPointDown() );
657 application.ProcessEvent( event );
659 application.SendNotification();
660 application.Render();
662 event = Dali::Integration::TouchEvent();
663 event.AddPoint( GetPointUp() );
664 application.ProcessEvent( event );
666 application.SendNotification();
667 application.Render();
669 // Confirm the signal is ignored if touch_transparent.
670 gTouchedOutside = false;
671 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
673 event = Dali::Integration::TouchEvent();
674 event.AddPoint( GetPointDown() );
675 application.ProcessEvent( event );
677 application.SendNotification();
678 application.Render();
680 event = Dali::Integration::TouchEvent();
681 event.AddPoint( GetPointUp() );
682 application.ProcessEvent( event );
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_CHECK( !gTouchedOutside );
692 int UtcDaliPopupPropertyAutoHide(void)
694 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
695 tet_infoline( " UtcDaliPopupPropertyAutoHide" );
697 // Create the Popup actor
698 Popup popup = Popup::New();
699 ConnectStateSignals( popup );
701 Actor container = Actor::New();
702 PushButton button1 = PushButton::New();
703 button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
704 container.Add( button1 );
705 popup.SetFooter( container );
707 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
708 float getAnimationDuration = 0.0f;
709 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_DURATION ).Get( getAnimationDuration ) );
710 DALI_TEST_EQUALS( getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
712 popup.SetProperty( Popup::Property::AUTO_HIDE_DELAY, 200 );
713 int getAutoHideDelay = 0;
714 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
715 DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
717 Stage::GetCurrent().Add( popup );
719 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
722 // Note: in most popup animation implementations show would result in
723 // popup being onstage immediately following Show(). However we can't
724 // assume for all. e.g. If one creates a animation with a delay.
725 popup.SetDisplayState( Popup::SHOWN );
727 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
729 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
731 application.SendNotification();
732 application.Render( RENDER_FRAME_INTERVAL );
735 // Force the timer used by the popup to expire,
736 // this will cause the popup to hide automatically.
737 Dali::Timer timer = Timer::New( 0 );
738 timer.MockEmitSignal();
740 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
746 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
748 int UtcDaliPopupPropertyAnimationMode(void)
750 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
751 tet_infoline( " UtcDaliPopupPropertyAnimationMode" );
753 // Create the Popup actor
754 Popup popup = Popup::New();
755 ConnectStateSignals( popup );
756 popup.SetTitle( TextLabel::New( "Title" ) );
757 Stage::GetCurrent().Add( popup );
759 std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
761 // Try both default and zero animation duration, as zero has a special case for some animation types.
762 for( int j = 0; j <= 1; j++ )
764 // On the second loop, set duration to zero.
767 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
770 // Loop through 4 animation modes.
771 for( int i = 0; i < 4; i++ )
773 popup.SetProperty( Popup::Property::ANIMATION_MODE, animationModes[i] );
775 std::string checkMode;
776 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::ANIMATION_MODE ).Get( checkMode ) )
778 DALI_TEST_EQUALS( checkMode, animationModes[i], TEST_LOCATION );
780 popup.SetProperty( Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN" );
781 std::string resultState;
783 // Only wait for animation if it isn't instant.
786 DALI_TEST_EQUALS( gPopupState, Popup::SHOWING, TEST_LOCATION );
787 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
788 DALI_TEST_EQUALS( resultState, "SHOWING", TEST_LOCATION );
789 WaitAnimation( application );
792 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
793 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
794 DALI_TEST_EQUALS( resultState, "SHOWN", TEST_LOCATION );
795 popup.SetDisplayState( Popup::HIDDEN );
799 DALI_TEST_EQUALS( gPopupState, Popup::HIDING, TEST_LOCATION );
800 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
801 DALI_TEST_EQUALS( resultState, "HIDING", TEST_LOCATION );
802 WaitAnimation( application );
805 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
806 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::DISPLAY_STATE ).Get( resultState ) );
807 DALI_TEST_EQUALS( resultState, "HIDDEN", TEST_LOCATION );
814 int UtcDaliPopupPropertyTitle(void)
816 ToolkitTestApplication application;
817 tet_infoline( " UtcDaliPopupPropertyTitle" );
819 // Create the Popup actor
820 Popup popup = Popup::New();
822 std::string testLabelText = "TitleTest";
823 TextLabel titleLabel = TextLabel::New();
824 titleLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
825 Actor title = titleLabel;
827 Scripting::CreatePropertyMap( title, map );
828 popup.SetProperty( Toolkit::Popup::Property::TITLE, map );
830 Property::Map resultMap;
831 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::TITLE ).Get( resultMap ) );
833 Property::Value* resultProperty = resultMap.Find( "text" );
834 DALI_TEST_CHECK( resultProperty );
836 std::string resultText;
837 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
839 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
844 int UtcDaliPopupPropertyContent(void)
846 ToolkitTestApplication application;
847 tet_infoline( " UtcDaliPopupPropertyContent" );
849 // Create the Popup actor
850 Popup popup = Popup::New();
852 std::string testLabelText = "ContentTest";
853 TextLabel contentLabel = TextLabel::New();
854 contentLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
855 Actor content = contentLabel;
857 Scripting::CreatePropertyMap( content, map );
858 popup.SetProperty( Toolkit::Popup::Property::CONTENT, map );
860 Property::Map resultMap;
861 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTENT ).Get( resultMap ) );
863 Property::Value* resultProperty = resultMap.Find( "text" );
864 DALI_TEST_CHECK( resultProperty );
866 std::string resultText;
867 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
869 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
874 int UtcDaliPopupPropertyFooter(void)
876 ToolkitTestApplication application;
877 tet_infoline( " UtcDaliPopupPropertyFooter" );
879 // Create the Popup actor
880 Popup popup = Popup::New();
882 std::string testLabelText = "FooterTest";
883 TextLabel footerLabel = TextLabel::New();
884 footerLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, testLabelText );
885 Actor footer = footerLabel;
887 Scripting::CreatePropertyMap( footer, map );
888 popup.SetProperty( Toolkit::Popup::Property::FOOTER, map );
890 Property::Map resultMap;
891 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::FOOTER ).Get( resultMap ) );
893 Property::Value* resultProperty = resultMap.Find( "text" );
894 DALI_TEST_CHECK( resultProperty );
896 std::string resultText;
897 DALI_TEST_CHECK( resultProperty->Get( resultText ) );
899 DALI_TEST_EQUALS( resultText, testLabelText, TEST_LOCATION );
904 int UtcDaliPopupPropertyContextualMode(void)
906 ToolkitTestApplication application;
907 tet_infoline( " UtcDaliPopupPropertyContextualMode" );
909 // Create the Popup actor
910 Popup popup = Popup::New();
911 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
912 std::string testLabelText = "ContentTest";
914 TextLabel contentLabel = TextLabel::New();
916 popup.SetContent( contentLabel );
918 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
919 Actor placement = Actor::New();
920 placement.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
921 placement.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
922 placement.SetSize( 1.0f, 1.0f );
923 placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
924 Stage::GetCurrent().Add( placement );
926 placement.Add( popup );
928 // Test all contextual modes.
929 const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" };
930 Vector2 offsetValues[5];
931 offsetValues[0] = Vector2( 0.375f, 0.0f );
932 offsetValues[1] = Vector2( -0.125f, -10.5f );
933 offsetValues[2] = Vector2( 10.875f, -0.5f );
934 offsetValues[3] = Vector2( -0.125f, 10.5f );
935 offsetValues[4] = Vector2( -10.875f, -0.5f );
937 for( int i = 0; i < 5; ++i )
939 popup.SetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i] );
941 std::string propertyResult;
942 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::CONTEXTUAL_MODE ).Get( propertyResult ) );
943 DALI_TEST_EQUALS( propertyResult, std::string( mode[i] ), TEST_LOCATION );
945 popup.SetDisplayState( Popup::SHOWN );
946 application.SendNotification();
947 application.Render();
949 // Check the position of the label within the popup.
950 DALI_TEST_EQUALS( contentLabel.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).GetVectorXY(), offsetValues[i], TEST_LOCATION );
952 popup.SetDisplayState( Popup::HIDDEN );
953 application.SendNotification();
954 application.Render();
960 int UtcDaliPopupPropertyBacking(void)
962 ToolkitTestApplication application;
963 tet_infoline( " UtcDaliPopupPropertyBacking" );
965 // Create the Popup actor
966 Popup popup = Popup::New();
967 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
968 Stage::GetCurrent().Add( popup );
970 Actor backing = popup.FindChildByName( "popupBacking" );
971 DALI_TEST_CHECK( backing );
973 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 // Check enabled property.
976 popup.SetDisplayState( Popup::SHOWN );
977 application.SendNotification();
978 application.Render();
980 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
982 popup.SetDisplayState( Popup::HIDDEN );
983 application.SendNotification();
984 application.Render();
986 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
988 popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
990 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::BACKING_ENABLED ).Get( propertyResult ) );
991 DALI_TEST_EQUALS( propertyResult, false, TEST_LOCATION );
993 popup.SetDisplayState( Popup::SHOWN );
994 application.SendNotification();
995 application.Render();
997 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
999 popup.SetDisplayState( Popup::HIDDEN );
1000 application.SendNotification();
1001 application.Render();
1003 DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1005 // Check color property.
1006 popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
1007 popup.SetProperty( Popup::Property::BACKING_COLOR, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
1009 popup.SetDisplayState( Popup::SHOWN );
1010 application.SendNotification();
1011 application.Render();
1013 Vector4 resultColor;
1014 popup.GetProperty( Popup::Property::BACKING_COLOR ).Get( resultColor );
1015 DALI_TEST_EQUALS( resultColor, Vector4( 1.0f, 0.0f, 0.0f, 1.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1020 int UtcDaliPopupPropertyBackgroundImage(void)
1022 ToolkitTestApplication application;
1023 tet_infoline( " UtcDaliPopupPropertyBackgroundImage" );
1025 // Create the Popup actor
1026 Popup popup = Popup::New();
1027 Stage::GetCurrent().Add( popup );
1029 // Check setting an image
1030 popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
1031 std::string resultString;
1032 popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString );
1033 DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION );
1038 int UtcDaliPopupPropertyCustomAnimation(void)
1040 ToolkitTestApplication application;
1041 tet_infoline( " UtcDaliPopupPropertyCustomAnimation" );
1043 // Create the Popup actor
1044 Popup popup = Popup::New();
1045 TextLabel content = TextLabel::New( "text" );
1046 popup.SetContent( content );
1048 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1049 popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" );
1051 Actor popupContainer = popup.FindChildByName( "popupContainer" );
1052 DALI_TEST_CHECK( popupContainer );
1054 Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f );
1055 Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f );
1057 Property::Map animationMapEntry;
1058 animationMapEntry.Insert( "actor", "customAnimationPopup" );
1059 animationMapEntry.Insert( "property", "position" );
1060 animationMapEntry.Insert( "value", entryAnimationDestination );
1061 animationMapEntry.Insert( "alphaFunction", "EASE_OUT" );
1063 Property::Array timePeriodMapEntry;
1064 timePeriodMapEntry.PushBack( 0.0f );
1065 timePeriodMapEntry.PushBack( 1.0f );
1067 animationMapEntry.Insert( "timePeriod", timePeriodMapEntry );
1069 Property::Map animationMapExit;
1070 animationMapExit.Insert( "actor", "customAnimationPopup" );
1071 animationMapExit.Insert( "property", "position" );
1072 animationMapExit.Insert( "value", exitAnimationDestination );
1073 animationMapExit.Insert( "alphaFunction", "EASE_IN" );
1075 Property::Array timePeriodMapExit;
1076 timePeriodMapExit.PushBack( 0.0f );
1077 timePeriodMapExit.PushBack( 1.0f );
1079 animationMapExit.Insert( "timePeriod", timePeriodMapExit );
1081 popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry );
1082 popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit );
1084 Property::Map resultMap;
1085 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) );
1086 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1087 DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
1088 DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
1090 Stage::GetCurrent().Add( popup );
1091 popup.SetDisplayState( Popup::SHOWN );
1093 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1095 application.SendNotification();
1096 application.Render( RENDER_FRAME_INTERVAL );
1099 // Test the popup has animated to it's entry-transition destination.
1100 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), entryAnimationDestination, 0.1f, TEST_LOCATION );
1102 popup.SetDisplayState( Popup::HIDDEN );
1104 for( int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++ )
1106 application.SendNotification();
1107 application.Render( RENDER_FRAME_INTERVAL );
1110 DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), exitAnimationDestination, 0.1f, TEST_LOCATION );
1115 static bool gPushButtonClicked;
1116 static bool PushButtonClicked( Button button )
1118 gPushButtonClicked = true;
1122 int UtcDaliPopupPropertyTouchTransparent(void)
1124 ToolkitTestApplication application;
1125 tet_infoline( " UtcDaliPopupPropertyTouchTransparent" );
1127 // Create the Popup actor
1128 Popup popup = Popup::New();
1129 TextLabel content = TextLabel::New( "text" );
1130 popup.SetContent( content );
1131 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1132 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1133 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1134 popup.SetSize( 100, 100 );
1135 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1137 // Create a button (to go underneath the popup).
1138 PushButton button = Toolkit::PushButton::New();
1139 button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1140 button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1141 button.SetSize( 100, 100 );
1142 button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1144 button.ClickedSignal().Connect( &PushButtonClicked );
1146 Stage::GetCurrent().Add( button );
1148 button.Add( popup );
1150 popup.SetDisplayState( Popup::SHOWN );
1151 application.SendNotification();
1152 application.Render();
1154 gPushButtonClicked = false;
1155 Dali::Integration::TouchEvent event;
1157 // Perform a click, the popup should block the click from hitting the button.
1158 event = Dali::Integration::TouchEvent();
1159 event.AddPoint( GetPointDown() );
1160 application.ProcessEvent( event );
1161 application.SendNotification();
1162 application.Render();
1164 event = Dali::Integration::TouchEvent();
1165 event.AddPoint( GetPointUp() );
1166 application.ProcessEvent( event );
1167 application.SendNotification();
1168 application.Render();
1170 DALI_TEST_CHECK( !gPushButtonClicked );
1172 // Enable touch transparency.
1173 popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
1174 bool propertyResult;
1175 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TOUCH_TRANSPARENT ).Get( propertyResult ) );
1176 DALI_TEST_EQUALS( propertyResult, true, TEST_LOCATION );
1178 // Perform a click, the popup should allow the click to travel through to the button.
1179 event = Dali::Integration::TouchEvent();
1180 event.AddPoint( GetPointDown() );
1181 application.ProcessEvent( event );
1182 application.SendNotification();
1183 application.Render();
1185 event = Dali::Integration::TouchEvent();
1186 event.AddPoint( GetPointUp() );
1187 application.ProcessEvent( event );
1188 application.SendNotification();
1189 application.Render();
1191 DALI_TEST_CHECK( gPushButtonClicked );
1196 int UtcDaliPopupPropertyTail(void)
1198 ToolkitTestApplication application;
1199 tet_infoline( " UtcDaliPopupPropertyTail" );
1201 // Create the Popup actor
1202 Popup popup = Popup::New();
1203 popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1204 popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1205 popup.SetSize( 100, 100 );
1206 popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1207 TextLabel content = TextLabel::New( "text" );
1208 popup.SetContent( content );
1210 std::string imageFilename = "invalid-image.jpg";
1211 popup.SetProperty( Popup::Property::TAIL_DOWN_IMAGE, imageFilename );
1212 popup.SetProperty( Popup::Property::TAIL_UP_IMAGE, imageFilename );
1213 popup.SetProperty( Popup::Property::TAIL_RIGHT_IMAGE, imageFilename );
1214 popup.SetProperty( Popup::Property::TAIL_LEFT_IMAGE, imageFilename );
1216 std::string resultString;
1217 popup.GetProperty( Toolkit::Popup::Property::TAIL_DOWN_IMAGE ).Get( resultString );
1218 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1219 popup.GetProperty( Toolkit::Popup::Property::TAIL_UP_IMAGE ).Get( resultString );
1220 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1221 popup.GetProperty( Toolkit::Popup::Property::TAIL_RIGHT_IMAGE ).Get( resultString );
1222 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1223 popup.GetProperty( Toolkit::Popup::Property::TAIL_LEFT_IMAGE ).Get( resultString );
1224 DALI_TEST_EQUALS( resultString, imageFilename, TEST_LOCATION );
1226 popup.SetProperty( Popup::Property::TAIL_VISIBILITY, true );
1228 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_VISIBILITY ).Get( boolResult ) );
1229 DALI_TEST_EQUALS( boolResult, true, TEST_LOCATION );
1232 Vector3 tailPosition( ParentOrigin::TOP_CENTER );
1234 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1235 Vector3 vectorResult;
1236 DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
1237 DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
1239 Stage::GetCurrent().Add( popup );
1241 popup.SetDisplayState( Popup::SHOWN );
1242 application.SendNotification();
1243 application.Render();
1244 tailActor = popup.FindChildByName( "tailImage" );
1245 DALI_TEST_CHECK( tailActor );
1247 float baseValX = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x;
1249 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, TEST_LOCATION );
1251 popup.SetDisplayState( Popup::HIDDEN );
1252 application.SendNotification();
1253 application.Render();
1255 tailPosition = ParentOrigin::CENTER_LEFT;
1256 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1258 popup.SetDisplayState( Popup::SHOWN );
1259 application.SendNotification();
1260 application.Render();
1261 tailActor = popup.FindChildByName( "tailImage" );
1262 DALI_TEST_CHECK( tailActor );
1264 float baseValY = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y;
1265 DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, TEST_LOCATION );
1267 popup.SetDisplayState( Popup::HIDDEN );
1268 application.SendNotification();
1269 application.Render();
1271 tailPosition = ParentOrigin::BOTTOM_CENTER;
1272 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1274 popup.SetDisplayState( Popup::SHOWN );
1275 application.SendNotification();
1276 application.Render();
1277 tailActor = popup.FindChildByName( "tailImage" );
1278 DALI_TEST_CHECK( tailActor );
1279 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1280 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1282 popup.SetDisplayState( Popup::HIDDEN );
1283 application.SendNotification();
1284 application.Render();
1286 tailPosition = ParentOrigin::CENTER_RIGHT;
1287 popup.SetProperty( Popup::Property::TAIL_POSITION, tailPosition );
1289 popup.SetDisplayState( Popup::SHOWN );
1290 application.SendNotification();
1291 application.Render();
1292 tailActor = popup.FindChildByName( "tailImage" );
1293 DALI_TEST_CHECK( tailActor );
1294 DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION );
1295 DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION );
1297 popup.SetDisplayState( Popup::HIDDEN );
1298 application.SendNotification();
1299 application.Render();
1304 int UtcDaliPopupTypeToast(void)
1306 ToolkitTestApplication application;
1307 tet_infoline( " UtcDaliPopupTypeToast" );
1309 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" );
1310 DALI_TEST_CHECK( typeInfo )
1312 BaseHandle baseHandle = typeInfo.CreateInstance();
1313 DALI_TEST_CHECK( baseHandle )
1315 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1316 gPopupState = Toolkit::Popup::HIDDEN;
1317 ConnectStateSignals( popup );
1318 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
1320 popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
1321 Stage::GetCurrent().Add( popup );
1322 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1324 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1326 application.SendNotification();
1327 application.Render( RENDER_FRAME_INTERVAL );
1330 // Check the toast popup is shown.
1331 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1333 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1335 application.SendNotification();
1336 application.Render( RENDER_FRAME_INTERVAL );
1339 // Check the toast popup hides.
1340 Dali::Timer timer = Timer::New( 0 );
1341 timer.MockEmitSignal();
1343 for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
1345 application.SendNotification();
1346 application.Render( RENDER_FRAME_INTERVAL );
1349 DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
1354 int UtcDaliPopupTypeRegistryCreation(void)
1356 ToolkitTestApplication application;
1357 tet_infoline( " UtcDaliPopupTypeRegistryCreation" );
1359 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "Popup" );
1360 DALI_TEST_CHECK( typeInfo )
1362 BaseHandle baseHandle = typeInfo.CreateInstance();
1363 DALI_TEST_CHECK( baseHandle )
1365 Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
1366 gPopupState = Toolkit::Popup::HIDDEN;
1367 ConnectStateSignals( popup );
1368 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1370 Stage::GetCurrent().Add( popup );
1371 popup.SetDisplayState( Toolkit::Popup::SHOWN );
1373 application.SendNotification();
1374 application.Render();
1376 // Check the popup is shown.
1377 DALI_TEST_EQUALS( gPopupState, Popup::SHOWN, TEST_LOCATION );
1382 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1384 ToolkitTestApplication application;
1385 tet_infoline( " UtcDaliPopupPropertyTypeRegistryConnectSignal" );
1387 // Create the Popup actor
1388 Popup popup = Popup::New();
1390 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1391 // Note: The emmision of this signals has already been tested in other tests.
1392 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) );
1393 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) );
1394 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) );
1395 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) );
1396 DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hidden", PopupTestFunctor() ) );
1398 // Test connecting to an invalid signal does not work.
1399 DALI_TEST_CHECK( !popup.ConnectSignal( testTracker, "invalid", PopupTestFunctor() ) );
1404 int UtcDaliPopupOnControlChildAdd(void)
1406 ToolkitTestApplication application;
1407 tet_infoline( " UtcDaliPopupOnControlChildAdd" );
1409 // Create the Popup actor
1410 Popup popup = Popup::New();
1411 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1412 std::string testLabelText = "ContentTest";
1413 TextLabel contentLabel = TextLabel::New( testLabelText );
1415 popup.Add( contentLabel );
1417 DALI_TEST_CHECK( HasAncestor( contentLabel, popup ) );
1422 int UtcDaliPopupOnKeyEvent(void)
1424 ToolkitTestApplication application;
1425 tet_infoline( " UtcDaliPopupOnKeyEvent" );
1427 // Create the Popup actor
1428 Popup popup = Popup::New();
1429 popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
1430 Stage::GetCurrent().Add( popup );
1432 popup.SetDisplayState( Popup::SHOWN );
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );
1438 popup.SetKeyInputFocus();
1440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
1441 application.SendNotification();
1442 application.Render();
1444 DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION );
1449 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1451 ToolkitTestApplication application;
1453 tet_infoline( "Set the background border property of a popup & retrieve it" );
1454 Popup popup = Popup::New();
1456 Rect< int > rect( 40, 30, 20, 10 );
1457 tet_infoline( "Ensure value we want to set is different from what is already set" );
1458 DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() );
1460 tet_infoline( "Set the property and retrieve it to make sure it's the value we set" );
1461 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect );
1462 DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );
1464 tet_infoline( "Set a vector4 as well which should also work" );
1465 Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f );
1466 popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue );
1467 DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION );