-//
-// 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 <iostream>
#include <stdlib.h>
+#include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-toolkit/internal/controls/buttons/button-impl.h>
using namespace Dali;
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<PushButton&>( button ).IsToggled() );
+ gPushButtonSelectedState = selected && ( selected == static_cast<PushButton&>( button ).IsSelected() );
return true;
}
}
/**
- * 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.
/**
* Copy constructor.
*/
- TETButton( const Button& button );
+ TETButton( const PushButton& button );
/**
* Assignment operator.
/**
* Internal implementation
*/
-class TETButton : public Button
+class TETButton : public PushButton
{
public:
/**
/**
* @return the pressed signal.
*/
- Toolkit::TETButton::PressedSignalV2& PressedSignal();
+ Toolkit::TETButton::ButtonSignalType& PressedSignal();
/**
* Callback called when an interrupt events is received.
*/
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
{
}
-TETButton::TETButton( const Button& button )
-: Button( button )
+TETButton::TETButton( const PushButton& button )
+: PushButton( button )
{
}
{
if( &button != this )
{
- Button::operator=( button );
+ PushButton::operator=( button );
}
return *this;
}
return Control::DownCast<TETButton, Internal::TETButton>(handle);
}
-TETButton::PressedSignalV2& TETButton::PressedSignal()
+TETButton::ButtonSignalType& TETButton::PressedSignal()
{
TETButton button( *this );
DALI_ASSERT_ALWAYS( button );
}
TETButton::TETButton( Internal::TETButton& implementation )
-: Button( implementation )
+: PushButton( implementation )
{}
TETButton::TETButton( Dali::Internal::CustomActor* internal )
-: Button( internal )
+: PushButton( internal )
{
VerifyCustomActorPointer<Internal::TETButton>(internal);
}
{
TETButton::TETButton()
-: Button(),
+: PushButton(),
mPressedSignal()
{
}
return tetButton;
}
-Toolkit::TETButton::PressedSignalV2& TETButton::PressedSignal()
+Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal()
{
return mPressedSignal;
}
{
}
- bool Callback( Button button )
+ bool Callback( PushButton button )
{
switch( mTest )
{
//////////////////////////////////////////////////////////
+int UtcDaliPushButtonDownCast(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliPushButtonDownCast");
+
+ TETButton tetButton= Toolkit::TETButton::New();
+
+ BaseHandle object(tetButton);
+
+ TETButton tetButton2 = TETButton::DownCast( object );
+ DALI_TEST_CHECK(tetButton2);
+
+ TETButton tetButton3 = DownCast< TETButton >(object);
+ DALI_TEST_CHECK(tetButton3);
+ END_TEST;
+}
int UtcDaliPushButtonInterruptEventWhenInsensitive(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
- {
- 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 );
-
- Property::Map map;
- map.push_back( Property::StringValuePair( "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 );
- }
+ 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 ) );
- // PushButton::PROPERTY_PRESSED_IMAGE
- {
- 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 );
-
- Property::Map map;
- map.push_back( Property::StringValuePair( "type", "TextActor" ) );
-
- 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 );
- }
-
- // PushButton::PROPERTY_DIMMED_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 );
-
- Property::Map map;
- map.push_back( Property::StringValuePair( "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 );
- }
-
- // PushButton::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 );
-
- Property::Map map;
- map.push_back( Property::StringValuePair( "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 );
- }
END_TEST;
}