X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-PushButton.cpp;h=05ced5a76ef082be3cf8ffc26f007ec1c0f8b8a1;hp=d381f5c4b0f64ed76e533c3d8527ae536a1b2ddb;hb=b458e407eba11c73f38da68bce8e967a30ea03e2;hpb=30f6ca1e541089b19f2b349a8a12d8a5bcaf2f9e diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp index d381f5c..05ced5a 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp @@ -1,26 +1,27 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #include #include +#include #include #include #include -#include using namespace Dali; @@ -29,10 +30,10 @@ using namespace Toolkit; namespace { -static bool gPushButtonToggleState = false; -bool PushButtonToggled( Button button, bool toggled ) +static bool gPushButtonSelectedState = false; +bool PushButtonSelected( Button button, bool selected ) { - gPushButtonToggleState = toggled && ( toggled == static_cast( button ).IsToggled() ); + gPushButtonSelectedState = selected && ( selected == static_cast( button ).IsSelected() ); return true; } @@ -66,15 +67,15 @@ class TETButton; } /** - * Creates a Button to test if interrupt events are handled correctly. + * Creates a PushButton to test if interrupt events are handled correctly. */ -class TETButton : public Button +class TETButton : public PushButton { public: // PushButton Pressed - typedef SignalV2< bool ( Button ) > PressedSignalV2; + typedef Signal< bool ( PushButton ) > ButtonSignalType; - PressedSignalV2& PressedSignal(); + ButtonSignalType& PressedSignal(); /** * Default constructor. @@ -84,7 +85,7 @@ public: /** * Copy constructor. */ - TETButton( const Button& button ); + TETButton( const PushButton& button ); /** * Assignment operator. @@ -120,7 +121,7 @@ namespace Internal /** * Internal implementation */ -class TETButton : public Button +class TETButton : public PushButton { public: /** @@ -141,7 +142,7 @@ public: /** * @return the pressed signal. */ - Toolkit::TETButton::PressedSignalV2& PressedSignal(); + Toolkit::TETButton::ButtonSignalType& PressedSignal(); /** * Callback called when an interrupt events is received. @@ -153,7 +154,7 @@ public: */ void OnButtonDown(); - Toolkit::TETButton::PressedSignalV2 mPressedSignal; ///< Signal emitted when the button is pressed. + Toolkit::TETButton::ButtonSignalType mPressedSignal; ///< Signal emitted when the button is pressed. }; } // namespace Internal @@ -162,8 +163,8 @@ TETButton::TETButton() { } -TETButton::TETButton( const Button& button ) -: Button( button ) +TETButton::TETButton( const PushButton& button ) +: PushButton( button ) { } @@ -171,7 +172,7 @@ TETButton& TETButton::operator=( const TETButton& button ) { if( &button != this ) { - Button::operator=( button ); + PushButton::operator=( button ); } return *this; } @@ -186,7 +187,7 @@ TETButton TETButton::DownCast( BaseHandle handle ) return Control::DownCast(handle); } -TETButton::PressedSignalV2& TETButton::PressedSignal() +TETButton::ButtonSignalType& TETButton::PressedSignal() { TETButton button( *this ); DALI_ASSERT_ALWAYS( button ); @@ -197,11 +198,11 @@ TETButton::PressedSignalV2& TETButton::PressedSignal() } TETButton::TETButton( Internal::TETButton& implementation ) -: Button( implementation ) +: PushButton( implementation ) {} TETButton::TETButton( Dali::Internal::CustomActor* internal ) -: Button( internal ) +: PushButton( internal ) { VerifyCustomActorPointer(internal); } @@ -210,7 +211,7 @@ namespace Internal { TETButton::TETButton() -: Button(), +: PushButton(), mPressedSignal() { } @@ -234,7 +235,7 @@ Toolkit::TETButton TETButton::New() return tetButton; } -Toolkit::TETButton::PressedSignalV2& TETButton::PressedSignal() +Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal() { return mPressedSignal; } @@ -276,7 +277,7 @@ public: { } - bool Callback( Button button ) + bool Callback( PushButton button ) { switch( mTest ) { @@ -637,87 +638,88 @@ int UtcDaliPushButtonProperties(void) PushButton button = PushButton::New(); Stage::GetCurrent().Add( button ); - // PushButton::PROPERTY_AUTO_REPEATING + // Button::PROPERTY_AUTO_REPEATING button.SetAutoRepeating( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) ); - button.SetProperty( PushButton::PROPERTY_AUTO_REPEATING, true ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) ); + button.SetProperty( Button::Property::AUTO_REPEATING, true ); DALI_TEST_CHECK( button.IsAutoRepeating() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) ); + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) ); - // PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY + // Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY button.SetInitialAutoRepeatingDelay( 10.0f ); - DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - button.SetProperty( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, 25.0f ); + DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + button.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 25.0f ); DALI_TEST_EQUALS( 25.0f, button.GetInitialAutoRepeatingDelay(), TEST_LOCATION ); - DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - // PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY + // Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY button.SetNextAutoRepeatingDelay( 3.0f ); - DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - button.SetProperty( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY, 4.0f ); + DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 4.0f ); DALI_TEST_EQUALS( 4.0f, button.GetNextAutoRepeatingDelay(), TEST_LOCATION ); - DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); - - // PushButton::PROPERTY_TOGGLABLE - button.SetToggleButton( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) ); - button.SetProperty( PushButton::PROPERTY_TOGGLABLE, true ); - DALI_TEST_CHECK( button.IsToggleButton() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) ); - - // PushButton::PROPERTY_TOGGLE - button.SetToggled( false ); - DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) ); - button.SetProperty( PushButton::PROPERTY_TOGGLE, true ); - DALI_TEST_CHECK( button.IsToggled() ) ; - DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) ); - - // PushButton::PROPERTY_NORMAL_STATE_ACTOR + DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION ); + + // Button::PROPERTY_TOGGLABLE + button.SetTogglableButton( false ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::TOGGLABLE ) ); + button.SetProperty( Button::Property::TOGGLABLE, true ); + DALI_TEST_CHECK( button.IsTogglableButton() ) ; + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::TOGGLABLE ) ); + + // Button::PROPERTY_SELECTED + button.SetSelected( false ); + DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::SELECTED ) ); + button.SetProperty( Button::Property::SELECTED, true ); + DALI_TEST_CHECK( button.IsSelected() ) ; + DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) ); + + // Button::PROPERTY_NORMAL_STATE_ACTOR { - button.SetButtonImage( Image::New( "IMAGE_PATH_1") ); - DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); + button.SetButtonImage( ResourceImage::New( "IMAGE_PATH_1") ); + DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); Property::Map map; - map.push_back( Property::StringValuePair( "type", "ImageActor" ) ); + map[ "type" ] = "ImageActor"; - button.SetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "ImageActor", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + button.SetProperty( Button::Property::NORMAL_STATE_ACTOR, map ); + DALI_TEST_EQUALS( "ImageActor", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); } - // PushButton::PROPERTY_PRESSED_IMAGE + // Button::PROPERTY_SELECTED_STATE_ACTOR { - button.SetPressedImage( Image::New( "IMAGE_PATH_2") ); - DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); + button.SetSelectedImage( ResourceImage::New( "IMAGE_PATH_2") ); + DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); Property::Map map; - map.push_back( Property::StringValuePair( "type", "TextActor" ) ); + map[ "type" ] = "Actor"; - button.SetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "TextActor", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + button.SetProperty( Button::Property::SELECTED_STATE_ACTOR, map ); + DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + DALI_TEST_CHECK( "ImageActor" != button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >() ); } - // PushButton::PROPERTY_DIMMED_STATE_ACTOR + // Button::PROPERTY_DISABLED_STATE_ACTOR { - button.SetDimmedImage( Image::New( "IMAGE_PATH_3") ); - DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); + button.SetDisabledImage( ResourceImage::New( "IMAGE_PATH_3") ); + DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION ); Property::Map map; - map.push_back( Property::StringValuePair( "type", "Actor" ) ); + map[ "type" ] = "Actor"; - button.SetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR, map ); - DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + button.SetProperty( Button::Property::DISABLED_STATE_ACTOR, map ); + DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); } - // PushButton::PROPERTY_LABEL_ACTOR + // Button::PROPERTY_LABEL_ACTOR { - button.SetLabelText( "LABEL_TEXT_CUSTOM" ); - DALI_TEST_EQUALS( "TextView", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + button.SetLabel( "LABEL_TEXT_CUSTOM" ); + DALI_TEST_EQUALS( "TextView", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); Property::Map map; - map.push_back( Property::StringValuePair( "type", "Actor" ) ); + map[ "type" ] = "Actor"; - button.SetProperty( PushButton::PROPERTY_LABEL_ACTOR, map ); - DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + button.SetProperty( Button::Property::LABEL_ACTOR, map ); + DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); } END_TEST; }