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=3e50df31e9ffbbe8d0dc34a7fb1bf9c68fa9e5d8;hp=4df55da1b7b9cbc65b6454b65f121c94099e19d1;hb=5e351965bad7e1de2e94027548b022bac692603c;hpb=75fdb5f9730fa6f6723c517691c9778fb646d082 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp index 4df55da..3e50df3 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) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -55,8 +55,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 @@ -164,14 +178,21 @@ Integration::KeyEvent GenerateKey( const std::string& keyName, int keyCode, int keyModifier, unsigned long timeStamp, - const Integration::KeyEvent::State& keyState ) + const Integration::KeyEvent::State& keyState, + const std::string& deviceName = "", + const Device::Class::Type& deviceClass = Device::Class::NONE, + const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE + ) { return Integration::KeyEvent( keyName, keyString, keyCode, keyModifier, timeStamp, - keyState ); + keyState, + deviceName, + deviceClass, + deviceSubclass ); } } // Anonymous namespace @@ -627,14 +648,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 +666,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(); @@ -902,11 +923,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 ) { @@ -1000,11 +1021,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; } @@ -1127,18 +1148,16 @@ 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(); @@ -1153,13 +1172,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(); @@ -1413,7 +1432,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 +1440,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; +}