/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
{
}
+static bool gKeyInputFocusCallBackCalled;
+
+static void TestKeyInputFocusCallback( Control control )
+{
+ tet_infoline(" TestKeyInputFocusCallback");
+
+ gKeyInputFocusCallBackCalled = true;
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////////////////////////
END_TEST;
}
-int UtcDaliControlGetImplementation(void)
+int UtcDaliControlGetImplementationN(void)
{
ToolkitTestApplication application;
-
DummyControl control;
// Get Empty
{
try
{
- Toolkit::Internal::Control& controlImpl = control.GetImplementation();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
(void)controlImpl; // Avoid unused warning
tet_result(TET_FAIL);
}
tet_result(TET_PASS);
}
}
+ END_TEST;
+}
+
+int UtcDaliControlGetImplementationConstN(void)
+{
+ ToolkitTestApplication application;
+ DummyControl control;
// Get Const Empty
{
try
{
const DummyControl constControl(control);
- const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation();
+ const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
(void)controlImpl; // Avoid unused warning
tet_result(TET_FAIL);
}
tet_result(TET_PASS);
}
}
+ END_TEST;
+}
- control = DummyControl::New();
+int UtcDaliControlGetImplementationP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl control = DummyControl::New();
// Get
{
try
{
- Toolkit::Internal::Control& controlImpl = control.GetImplementation();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
(void)controlImpl; // Avoid unused warning
tet_result(TET_PASS);
}
tet_result(TET_FAIL);
}
}
+ END_TEST;
+}
+int UtcDaliControlGetImplementationConstP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl control = DummyControl::New();
// Get Const
{
try
{
const DummyControl constControl(control);
- const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation();
+ const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
(void)controlImpl; // Avoid unused warning
tet_result(TET_PASS);
}
Actor actor = Actor::New();
DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
- Toolkit::Internal::Control& control = dummy.GetImplementation();
+ Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
- DALI_TEST_CHECK( dummyImpl );
+
+ if( dummyImpl == NULL )
+ {
+ tet_result( TET_FAIL );
+ END_TEST;
+ }
actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
{
DummyControl dummy = DummyControlImpl::New();
- Toolkit::Internal::Control& control = dummy.GetImplementation();
+ Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
- DALI_TEST_CHECK( dummyImpl );
+
+ if( dummyImpl == NULL )
+ {
+ tet_result( TET_FAIL );
+ END_TEST;
+ }
actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
float width = 640.0f;
float height = test.GetHeightForWidth( width );
- DALI_TEST_CHECK( test.GetWidthForHeight( height ) == width );
+ DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
+ DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
test.KeyEventSignal();
ToolkitTestApplication application;
Control control = Control::New();
- DALI_TEST_CHECK( !control.GetBackgroundActor() );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
control.SetBackgroundColor( Color::RED );
- DALI_TEST_CHECK( control.GetBackgroundActor() );
+
+ Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "COLOR" );
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::RED );
+
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
+ control.SetBackgroundColor( Color::YELLOW );
+
+ propValue = control.GetProperty( Control::Property::BACKGROUND );
+ resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::YELLOW );
+
+ DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
+
END_TEST;
}
ToolkitTestApplication application;
Control control = Control::New();
- DALI_TEST_CHECK( !control.GetBackgroundActor() );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
Image image = ResourceImage::New("TestImage");
control.SetBackgroundImage( image );
- DALI_TEST_CHECK( control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::WHITE, TEST_LOCATION );
- control.SetBackgroundColor( Color::GREEN );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::GREEN, TEST_LOCATION );
+ Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "IMAGE" );
+ DALI_TEST_CHECK( resultMap->Find( "url" ) );
+ DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage" );
- control.ClearBackground();
- DALI_TEST_CHECK( !control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
-
- control.SetBackgroundColor( Color::YELLOW );
+ image = ResourceImage::New("TestImage2");
control.SetBackgroundImage( image );
- DALI_TEST_CHECK( control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
+
+ propValue = control.GetProperty( Control::Property::BACKGROUND );
+ resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "url" ) );
+ DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage2" );
END_TEST;
}
ToolkitTestApplication application;
Control control = Control::New();
- DALI_TEST_CHECK( !control.GetBackgroundActor() );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
- DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
- DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
-
- control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::RED );
- DALI_TEST_CHECK( control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
- DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION );
+ DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
Property::Map imageMap;
- imageMap[ "filename" ] = "TestImage";
- Property::Map map;
- map[ "image" ] = imageMap;
- control.SetProperty( Control::Property::BACKGROUND_IMAGE, map );
- DALI_TEST_CHECK( control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
- DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION );
-
- Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
- DALI_TEST_CHECK( propValue.HasKey( "image" ) );
- DALI_TEST_CHECK( propValue.GetValue( "image" ).HasKey( "filename" ) );
- DALI_TEST_CHECK( propValue.GetValue( "image" ).GetValue( "filename" ).Get< std::string>() == "TestImage" );
+ imageMap[ "rendererType" ] = "IMAGE";
+ imageMap[ "url" ] = "TestImage";
+ control.SetProperty( Control::Property::BACKGROUND, imageMap );
+ Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "IMAGE" );
+ DALI_TEST_CHECK( resultMap->Find( "url" ) );
+ DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage" );
+
+ Property::Map rendererMap;
+ rendererMap["rendererType"] = "COLOR";
+ rendererMap["mixColor"] = Color::CYAN;
+ control.SetProperty( Control::Property::BACKGROUND, rendererMap );
+ propValue = control.GetProperty( Control::Property::BACKGROUND );
+ resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
+ DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "COLOR" );
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
+ DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::CYAN );
Property::Map emptyMap;
+ control.SetProperty( Control::Property::BACKGROUND, emptyMap );
+ DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
+
+ // Deprecated Properties
+ control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
+ DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == Color::YELLOW );
+ DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == control.GetBackgroundColor() );
+ control.ClearBackground();
+
+ Property::Map deprecatedImageMap;
+ deprecatedImageMap[ "filename" ] = "TestImage";
+ control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
+ propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
+ resultMap = propValue.GetMap();
+ DALI_TEST_CHECK( resultMap->Find( "url" )->Get< std::string >() == "TestImage" );
control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
- DALI_TEST_CHECK( !control.GetBackgroundActor() );
- DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
- DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
END_TEST;
DALI_TEST_CHECK( control.GetPinchGestureDetector() );
DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
- control.ConnectSignal( &connectionTracker, "long-pressed", &TestVoidCallback );
+ control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
END_TEST;
}
+
+int UtcDaliControlImplKeyInputFocusGainedSignal(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ Stage::GetCurrent().Add( control );
+
+ gKeyInputFocusCallBackCalled = false;
+ control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetKeyInputFocus();
+
+ DALI_TEST_CHECK( control.HasKeyInputFocus() );
+
+ DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplKeyInputFocusLostSignal(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ Stage::GetCurrent().Add( control );
+
+ gKeyInputFocusCallBackCalled = false;
+ control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetKeyInputFocus();
+
+ DALI_TEST_CHECK( control.HasKeyInputFocus() );
+
+ control.ClearKeyInputFocus();
+
+ DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplGetControlExtensionP(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
+
+ DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
+
+ END_TEST;
+}