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=6bd2c05784fddb6abb5ba95e7d5db7731921fabf;hp=3a8b7225d2c05ae42c3bb07ef39fae7f25a847c4;hb=4107c0f5ea45cd9e4e61d30c30e99de0e00287fc;hpb=678abc1612bf792741f9018c0cb5210738b61113 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp index 3a8b722..6bd2c05 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) 2016 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 @@ -627,14 +641,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 +659,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(); @@ -941,7 +955,7 @@ int UtcDaliPopupPropertyBacking(void) popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f ); Stage::GetCurrent().Add( popup ); - Actor backing = popup.FindChildByName( "popup-backing" ); + Actor backing = popup.FindChildByName( "popupBacking" ); DALI_TEST_CHECK( backing ); DALI_TEST_EQUALS( backing.GetCurrentOpacity(), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); @@ -1000,11 +1014,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; } @@ -1022,44 +1036,44 @@ int UtcDaliPopupPropertyCustomAnimation(void) popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f ); popup.SetProperty( Popup::Property::ANIMATION_MODE, "CUSTOM" ); - Actor popupContainer = popup.FindChildByName( "popup-container" ); + Actor popupContainer = popup.FindChildByName( "popupContainer" ); DALI_TEST_CHECK( popupContainer ); Vector3 entryAnimationDestination( 300.0f, 200.0f, 0.0f ); Vector3 exitAnimationDestination( -300.0f, -200.0f, 0.0f ); Property::Map animationMapEntry; - animationMapEntry.Insert( "actor", "custom-animation-popup" ); + animationMapEntry.Insert( "actor", "customAnimationPopup" ); animationMapEntry.Insert( "property", "position" ); animationMapEntry.Insert( "value", entryAnimationDestination ); - animationMapEntry.Insert( "alpha-function", "EASE_OUT" ); + animationMapEntry.Insert( "alphaFunction", "EASE_OUT" ); Property::Array timePeriodMapEntry; timePeriodMapEntry.PushBack( 0.0f ); timePeriodMapEntry.PushBack( 1.0f ); - animationMapEntry.Insert( "time-period", timePeriodMapEntry ); + animationMapEntry.Insert( "timePeriod", timePeriodMapEntry ); Property::Map animationMapExit; - animationMapExit.Insert( "actor", "custom-animation-popup" ); + animationMapExit.Insert( "actor", "customAnimationPopup" ); animationMapExit.Insert( "property", "position" ); animationMapExit.Insert( "value", exitAnimationDestination ); - animationMapExit.Insert( "alpha-function", "EASE_IN" ); + animationMapExit.Insert( "alphaFunction", "EASE_IN" ); Property::Array timePeriodMapExit; timePeriodMapExit.PushBack( 0.0f ); timePeriodMapExit.PushBack( 1.0f ); - animationMapExit.Insert( "time-period", timePeriodMapExit ); + animationMapExit.Insert( "timePeriod", timePeriodMapExit ); popup.SetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry ); popup.SetProperty( Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit ); Property::Map resultMap; DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::ENTRY_ANIMATION ).Get( resultMap ) ); - DALI_TEST_EQUALS( resultMap.Count(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION ); DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) ); - DALI_TEST_EQUALS( resultMap.Count(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION ); Stage::GetCurrent().Add( popup ); popup.SetDisplayState( Popup::SHOWN ); @@ -1127,18 +1141,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 +1165,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(); @@ -1217,7 +1229,7 @@ int UtcDaliPopupPropertyTail(void) popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); application.Render(); - tailActor = popup.FindChildByName( "tail-image" ); + tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); float baseValX = tailActor.GetCurrentWorldPosition().x; @@ -1234,7 +1246,7 @@ int UtcDaliPopupPropertyTail(void) popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); application.Render(); - tailActor = popup.FindChildByName( "tail-image" ); + tailActor = popup.FindChildByName( "tailImage" ); DALI_TEST_CHECK( tailActor ); float baseValY = tailActor.GetCurrentWorldPosition().y; @@ -1250,7 +1262,7 @@ int UtcDaliPopupPropertyTail(void) popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); application.Render(); - tailActor = popup.FindChildByName( "tail-image" ); + 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 ); @@ -1265,7 +1277,7 @@ int UtcDaliPopupPropertyTail(void) popup.SetDisplayState( Popup::SHOWN ); application.SendNotification(); application.Render(); - tailActor = popup.FindChildByName( "tail-image" ); + 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 ); @@ -1282,7 +1294,7 @@ int UtcDaliPopupTypeToast(void) ToolkitTestApplication application; tet_infoline( " UtcDaliPopupTypeToast" ); - TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "popup-toast" ); + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "PopupToast" ); DALI_TEST_CHECK( typeInfo ) BaseHandle baseHandle = typeInfo.CreateInstance(); @@ -1365,7 +1377,7 @@ int UtcDaliPopupPropertyTypeRegistryConnectSignal(void) TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject(); // Note: The emmision of this signals has already been tested in other tests. - DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touched-outside", PopupTestFunctor() ) ); + DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "touchedOutside", PopupTestFunctor() ) ); DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "showing", PopupTestFunctor() ) ); DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "shown", PopupTestFunctor() ) ); DALI_TEST_CHECK( popup.ConnectSignal( testTracker, "hiding", PopupTestFunctor() ) ); @@ -1421,3 +1433,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; +}