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=8c5fbf7ea9ad7c197cc1e2cf8408ba59353a9f1b;hp=4df55da1b7b9cbc65b6454b65f121c94099e19d1;hb=5aaba5adcf1a717e1ece3ef9c55c8912420993b5;hpb=8aa5b5aaaa25d0fd3bad166824ec3c93596f827d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp old mode 100644 new mode 100755 index 4df55da..8c5fbf7 --- 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) 2015 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 @@ -55,8 +57,22 @@ const int RENDER_FRAME_INTERVAL = 10; ///< Duration of const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation. const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames. const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f); -const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10.0f, 10.0f ); -const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10.0f, 10.0f ); + +Dali::Integration::Point GetPointDown() +{ + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10, 10 ) ); + return point; +} + +Dali::Integration::Point GetPointUp() +{ + Dali::Integration::Point point; + point.SetState( PointState::UP ); + point.SetScreenPosition( Vector2( 10, 10 ) ); + return point; +} /** * Counts how many descendants root Actor has, including @@ -160,18 +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 Integration::KeyEvent::State& keyState, + 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 ); + keyState, + compose, + deviceName, + deviceClass, + deviceSubclass ); } } // Anonymous namespace @@ -441,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 @@ -536,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 ); @@ -611,10 +676,10 @@ 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 ); popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside ); @@ -627,14 +692,14 @@ int UtcDaliPopupOnTouchedOutsideSignal(void) Dali::Integration::TouchEvent event; event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownOutside ); + event.AddPoint( GetPointDown() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpOutside ); + event.AddPoint( GetPointUp() ); application.ProcessEvent( event ); application.SendNotification(); @@ -645,14 +710,14 @@ int UtcDaliPopupOnTouchedOutsideSignal(void) popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true ); event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDownOutside ); + event.AddPoint( GetPointDown() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUpOutside ); + event.AddPoint( GetPointUp() ); application.ProcessEvent( event ); application.SendNotification(); @@ -674,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 ); @@ -891,9 +956,9 @@ 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 ); @@ -902,11 +967,11 @@ int UtcDaliPopupPropertyContextualMode(void) // Test all contextual modes. const char* mode[5] = { "NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT" }; Vector2 offsetValues[5]; - offsetValues[0] = Vector2( 0.0f, 0.0f ); - offsetValues[1] = Vector2( 0.0f, -10.0f ); - offsetValues[2] = Vector2( 10.0f, 0.0f ); - offsetValues[3] = Vector2( 0.0f, 10.0f ); - offsetValues[4] = Vector2( -10.0f, 0.0f ); + offsetValues[0] = Vector2( 0.375f, 0.0f ); + offsetValues[1] = Vector2( -0.125f, -10.5f ); + offsetValues[2] = Vector2( 10.875f, -0.5f ); + offsetValues[3] = Vector2( -0.125f, 10.5f ); + offsetValues[4] = Vector2( -10.875f, -0.5f ); for( int i = 0; i < 5; ++i ) { @@ -921,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(); @@ -944,20 +1009,20 @@ int UtcDaliPopupPropertyBacking(void) 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 >( DevelActor::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 >( DevelActor::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 >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); popup.SetProperty( Popup::Property::BACKING_ENABLED, false ); bool propertyResult; @@ -968,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 >( DevelActor::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 >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); // Check color property. popup.SetProperty( Popup::Property::BACKING_ENABLED, true ); @@ -1000,11 +1065,11 @@ int UtcDaliPopupPropertyBackgroundImage(void) Popup popup = Popup::New(); Stage::GetCurrent().Add( popup ); - // Check setting an invalid image. + // Check setting an image popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" ); std::string resultString; popup.GetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE ).Get( resultString ); - DALI_TEST_EQUALS( resultString, std::string(""), TEST_LOCATION ); + DALI_TEST_EQUALS( resultString, "invalid-image.png", TEST_LOCATION ); END_TEST; } @@ -1071,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 ); @@ -1081,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; } @@ -1103,16 +1168,16 @@ 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 ); @@ -1127,24 +1192,28 @@ int UtcDaliPopupPropertyTouchTransparent(void) gPushButtonClicked = false; Dali::Integration::TouchEvent event; - const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f ); - const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f ); // Perform a click, the popup should block the click from hitting the button. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDown ); + event.AddPoint( GetPointDown() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUp ); + event.AddPoint( GetPointUp() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); 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; @@ -1153,13 +1222,13 @@ int UtcDaliPopupPropertyTouchTransparent(void) // Perform a click, the popup should allow the click to travel through to the button. event = Dali::Integration::TouchEvent(); - event.AddPoint( pointDown ); + event.AddPoint( GetPointDown() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); event = Dali::Integration::TouchEvent(); - event.AddPoint( pointUp ); + event.AddPoint( GetPointUp() ); application.ProcessEvent( event ); application.SendNotification(); application.Render(); @@ -1176,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 ); @@ -1220,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(); @@ -1237,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(); @@ -1252,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(); @@ -1267,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(); @@ -1413,7 +1482,7 @@ int UtcDaliPopupOnKeyEvent(void) popup.SetKeyInputFocus(); - application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) ); application.SendNotification(); application.Render(); @@ -1421,3 +1490,26 @@ int UtcDaliPopupOnKeyEvent(void) END_TEST; } + +int UtcDaliPopupSetPopupBackgroundBorderProperty(void) +{ + ToolkitTestApplication application; + + tet_infoline( "Set the background border property of a popup & retrieve it" ); + Popup popup = Popup::New(); + + Rect< int > rect( 40, 30, 20, 10 ); + tet_infoline( "Ensure value we want to set is different from what is already set" ); + DALI_TEST_CHECK( rect != popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >() ); + + tet_infoline( "Set the property and retrieve it to make sure it's the value we set" ); + popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, rect ); + DALI_TEST_EQUALS( rect, popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION ); + + tet_infoline( "Set a vector4 as well which should also work" ); + Vector4 vectorValue( 10.0f, 20.0f, 30.0f, 40.0f ); + popup.SetProperty( Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue ); + DALI_TEST_EQUALS( Rect< int >( 10, 20, 30, 40 ), popup.GetProperty( Popup::Property::POPUP_BACKGROUND_BORDER ).Get< Rect< int > >(), TEST_LOCATION ); + + END_TEST; +}