X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Popup.cpp;h=159ea013ffc83d35b4904e715c212457b9801a41;hp=9a8b579c9da3709acaa98330c3c59d961e7c7b1c;hb=01777a3489f027123010b281e58efbc9f0a93db7;hpb=24ea337df1049251ab2e47c556edc6e8458f9c93 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp index 9a8b579..159ea01 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -174,23 +176,29 @@ struct PopupTestFunctor // Generate a KeyEvent to send to Core. Integration::KeyEvent GenerateKey( const std::string& keyName, + const std::string& logicalKey, const std::string& keyString, int keyCode, int keyModifier, unsigned long timeStamp, const Integration::KeyEvent::State& keyState, - const std::string& deviceName, - const DevelKeyEvent::DeviceClass::Type& deviceClass + const std::string& compose = "", + const std::string& deviceName = "", + const Device::Class::Type& deviceClass = Device::Class::NONE, + const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE ) { return Integration::KeyEvent( keyName, + logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, + compose, deviceName, - deviceClass ); + deviceClass, + deviceSubclass ); } } // Anonymous namespace @@ -217,7 +225,7 @@ int UtcDaliPopupNewP( void ) DALI_TEST_CHECK( popup2 == popup ); // Additional check to ensure object is created by checking if it's registered. - ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + ObjectRegistry registry = application.GetCore().GetObjectRegistry(); DALI_TEST_CHECK( registry ); gObjectCreatedCallBackCalled = false; @@ -349,7 +357,7 @@ int UtcDaliPopupSetContentP(void) // Create the Popup actor Popup popup = Popup::New(); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f ); // Put in show state so it's layer is connected to popup (for ancestor check). @@ -394,7 +402,7 @@ int UtcDaliPopupSetFooterP(void) // Create the Popup actor Popup popup = Popup::New(); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f ); // Put in show state so it's layer is connected to popup (for ancestor check). popup.SetDisplayState( Popup::SHOWN ); @@ -438,7 +446,7 @@ int UtcDaliPopupSetControlFooterMultiple(void) // Create the Popup actor Popup popup = Popup::New(); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f ); // Put in show state so it's layer is connected to popup (for ancestor check). popup.SetDisplayState( Popup::SHOWN ); @@ -460,6 +468,44 @@ int UtcDaliPopupSetControlFooterMultiple(void) END_TEST; } +int UtcDaliPopupSetTitleAndFooter(void) +{ + ToolkitTestApplication application; // Exceptions require ToolkitTestApplication + tet_infoline( " UtcDaliPopupSetTitleAndFooter" ); + + // Create the Popup actor + Popup popup = Popup::New(); + + // Put in show state so it's layer is connected to popup (for ancestor check). + popup.SetDisplayState( Popup::SHOWN ); + + // Add the title + TextLabel titleActor = TextLabel::New(); + titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" ); + + DALI_TEST_CHECK( !popup.GetTitle() ); + popup.SetTitle( titleActor ); + TextLabel textActor = TextLabel::DownCast( popup.GetTitle() ); + DALI_TEST_CHECK( textActor == titleActor ); + + std::string resultText; + DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) ); + DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) ); + // verify titleActor is actually inside popup, and not elsewhere on stage, or off even. + DALI_TEST_CHECK( HasAncestor( titleActor, popup ) ); + + // Add the footer + PushButton button = PushButton::New(); + DALI_TEST_CHECK( !HasAncestor(button, popup) ); + popup.SetFooter( button ); + // Hide and then re-show popup to cause button to be rearranged and added to popup. + popup.SetDisplayState( Popup::HIDDEN ); + popup.SetDisplayState( Popup::SHOWN ); + DALI_TEST_CHECK( HasAncestor( button, popup ) ); + + END_TEST; +} + int UtcDaliPopupSetStateP(void) { ToolkitTestApplication application; // Exceptions require ToolkitTestApplication @@ -555,8 +601,8 @@ int UtcDaliPopupShowHide(void) Actor container = Actor::New(); PushButton button1 = PushButton::New(); PushButton button2 = PushButton::New(); - button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() ); - button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() ); + button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() ); + button2.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() ); container.Add( button1 ); container.Add( button2 ); popup.SetFooter( container ); @@ -595,7 +641,7 @@ int UtcDaliPopupPropertyTailVisibility(void) // Create the Popup actor Popup popup = Popup::New(); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false ); popup.SetDisplayState( Popup::SHOWN ); @@ -630,12 +676,12 @@ int UtcDaliPopupOnTouchedOutsideSignal(void) // Create the Popup actor Popup popup = Popup::New(); - popup.SetParentOrigin( ParentOrigin::CENTER ); - popup.SetAnchorPoint( ParentOrigin::CENTER ); + popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + popup.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER ); popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - popup.SetSize( 50.0f, 50.0f ); + popup.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) ); popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside ); popup.SetDisplayState( Popup::SHOWN ); @@ -693,7 +739,7 @@ int UtcDaliPopupPropertyAutoHide(void) Actor container = Actor::New(); PushButton button1 = PushButton::New(); - button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() ); + button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() ); container.Add( button1 ); popup.SetFooter( container ); @@ -707,7 +753,7 @@ int UtcDaliPopupPropertyAutoHide(void) DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) ); DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION ); @@ -747,7 +793,7 @@ int UtcDaliPopupPropertyAnimationMode(void) Popup popup = Popup::New(); ConnectStateSignals( popup ); popup.SetTitle( TextLabel::New( "Title" ) ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" }; @@ -910,11 +956,11 @@ int UtcDaliPopupPropertyContextualMode(void) // Placement actor to parent the popup from so the popup's contextual position can be relative to it. Actor placement = Actor::New(); - placement.SetParentOrigin( ParentOrigin::CENTER ); - placement.SetAnchorPoint( AnchorPoint::CENTER ); - placement.SetSize( 1.0f, 1.0f ); + placement.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + placement.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + placement.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 1.0f ) ); placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - Stage::GetCurrent().Add( placement ); + application.GetScene().Add( placement ); placement.Add( popup ); @@ -940,7 +986,7 @@ int UtcDaliPopupPropertyContextualMode(void) application.Render(); // Check the position of the label within the popup. - DALI_TEST_EQUALS( contentLabel.GetCurrentWorldPosition().GetVectorXY(), offsetValues[i], TEST_LOCATION ); + DALI_TEST_EQUALS( contentLabel.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).GetVectorXY(), offsetValues[i], TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); @@ -958,25 +1004,25 @@ int UtcDaliPopupPropertyBacking(void) // Create the Popup actor Popup popup = Popup::New(); popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); Actor backing = popup.FindChildByName( "popupBacking" ); DALI_TEST_CHECK( backing ); - DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); // Check enabled property. popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); popup.SetProperty( Popup::Property::BACKING_ENABLED, false ); bool propertyResult; @@ -987,13 +1033,13 @@ int UtcDaliPopupPropertyBacking(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); + DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); // Check color property. popup.SetProperty( Popup::Property::BACKING_ENABLED, true ); @@ -1017,7 +1063,7 @@ int UtcDaliPopupPropertyBackgroundImage(void) // Create the Popup actor Popup popup = Popup::New(); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); // Check setting an image popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" ); @@ -1080,7 +1126,7 @@ int UtcDaliPopupPropertyCustomAnimation(void) DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) ); DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetDisplayState( Popup::SHOWN ); for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ ) @@ -1090,7 +1136,7 @@ int UtcDaliPopupPropertyCustomAnimation(void) } // Test the popup has animated to it's entry-transition destination. - DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), entryAnimationDestination, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), entryAnimationDestination, 0.1f, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); @@ -1100,7 +1146,7 @@ int UtcDaliPopupPropertyCustomAnimation(void) application.Render( RENDER_FRAME_INTERVAL ); } - DALI_TEST_EQUALS( popupContainer.GetCurrentWorldPosition(), exitAnimationDestination, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( popupContainer.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), exitAnimationDestination, 0.1f, TEST_LOCATION ); END_TEST; } @@ -1122,21 +1168,21 @@ int UtcDaliPopupPropertyTouchTransparent(void) TextLabel content = TextLabel::New( "text" ); popup.SetContent( content ); popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); - popup.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - popup.SetParentOrigin( ParentOrigin::TOP_LEFT ); - popup.SetSize( 100, 100 ); + popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) ); popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); // Create a button (to go underneath the popup). PushButton button = Toolkit::PushButton::New(); - button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - button.SetParentOrigin( ParentOrigin::TOP_LEFT ); - button.SetSize( 100, 100 ); + button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + button.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) ); button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); button.ClickedSignal().Connect( &PushButtonClicked ); - Stage::GetCurrent().Add( button ); + application.GetScene().Add( button ); button.Add( popup ); @@ -1162,6 +1208,12 @@ int UtcDaliPopupPropertyTouchTransparent(void) DALI_TEST_CHECK( !gPushButtonClicked ); + // Perform a wheel event + Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u ); + application.ProcessEvent( wheelEvent ); + application.SendNotification(); + application.Render(); + // Enable touch transparency. popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true ); bool propertyResult; @@ -1193,9 +1245,9 @@ int UtcDaliPopupPropertyTail(void) // Create the Popup actor Popup popup = Popup::New(); - popup.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - popup.SetParentOrigin( ParentOrigin::TOP_LEFT ); - popup.SetSize( 100, 100 ); + popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) ); popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); TextLabel content = TextLabel::New( "text" ); popup.SetContent( content ); @@ -1229,7 +1281,7 @@ int UtcDaliPopupPropertyTail(void) DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) ); DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); @@ -1237,9 +1289,9 @@ int UtcDaliPopupPropertyTail(void) tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); - float baseValX = tailActor.GetCurrentWorldPosition().x; + float baseValX = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x; - DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().y, TEST_LOCATION ); + DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); @@ -1254,8 +1306,8 @@ int UtcDaliPopupPropertyTail(void) tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); - float baseValY = tailActor.GetCurrentWorldPosition().y; - DALI_TEST_GREATER( baseValX, tailActor.GetCurrentWorldPosition().x, TEST_LOCATION ); + float baseValY = tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y; + DALI_TEST_GREATER( baseValX, tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); @@ -1269,8 +1321,8 @@ int UtcDaliPopupPropertyTail(void) application.Render(); tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); - DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION ); - DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION ); + DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION ); + DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); @@ -1284,8 +1336,8 @@ int UtcDaliPopupPropertyTail(void) application.Render(); tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); - DALI_TEST_GREATER( tailActor.GetCurrentWorldPosition().x, baseValX, TEST_LOCATION ); - DALI_TEST_EQUALS( tailActor.GetCurrentWorldPosition().y, baseValY, TEST_LOCATION ); + DALI_TEST_GREATER( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).x, baseValX, TEST_LOCATION ); + DALI_TEST_EQUALS( tailActor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ).y, baseValY, TEST_LOCATION ); popup.SetDisplayState( Popup::HIDDEN ); application.SendNotification(); @@ -1311,7 +1363,7 @@ int UtcDaliPopupTypeToast(void) popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f ); popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetDisplayState( Toolkit::Popup::SHOWN ); for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ ) @@ -1360,7 +1412,7 @@ int UtcDaliPopupTypeRegistryCreation(void) ConnectStateSignals( popup ); popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetDisplayState( Toolkit::Popup::SHOWN ); application.SendNotification(); @@ -1394,10 +1446,10 @@ int UtcDaliPopupPropertyTypeRegistryConnectSignal(void) END_TEST; } -int UtcDaliPopupOnControlChildAdd(void) +int UtcDaliPopupOnChildAdd(void) { ToolkitTestApplication application; - tet_infoline( " UtcDaliPopupOnControlChildAdd" ); + tet_infoline( " UtcDaliPopupOnChildAdd" ); // Create the Popup actor Popup popup = Popup::New(); @@ -1420,7 +1472,7 @@ int UtcDaliPopupOnKeyEvent(void) // Create the Popup actor Popup popup = Popup::New(); popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); - Stage::GetCurrent().Add( popup ); + application.GetScene().Add( popup ); popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); @@ -1430,7 +1482,7 @@ int UtcDaliPopupOnKeyEvent(void) popup.SetKeyInputFocus(); - application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DevelKeyEvent::DeviceClass::TOUCH ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) ); application.SendNotification(); application.Render();