From af9057cae8bb9ae12c7c3502c83d1002accc5d8e Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Thu, 18 Oct 2018 14:42:04 +0100 Subject: [PATCH] SVACE error in size negotiation mapper Change-Id: Iae3a219ccff0941bc2f4890f72b5f314c5b46e52 --- .../src/dali-toolkit-internal/CMakeLists.txt | 1 + .../utc-Dali-SizeNegotiationMapper.cpp | 112 +++++++++++++++++++++ .../internal/layouting/size-negotiation-mapper.cpp | 10 +- 3 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 037fd71..df591a7 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -14,6 +14,7 @@ SET(TC_SOURCES utc-Dali-ItemView-internal.cpp utc-Dali-LogicalModel.cpp utc-Dali-PropertyHelper.cpp + utc-Dali-SizeNegotiationMapper.cpp utc-Dali-Text-CharacterSetConversion.cpp utc-Dali-Text-Controller.cpp utc-Dali-Text-Cursor.cpp diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp new file mode 100644 index 0000000..692cef7 --- /dev/null +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018 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; +using namespace Toolkit; + +int UtcDaliLayoutingSizeNegotiationMapper_01(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_01 - Test mapping Dimension::ALL_DIMENSIONS"); + + auto control = Control::New(); + control.SetName( "fitToChildrenControl" ); + DevelControl::SetLayoutingRequired( control, true ); + control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); + + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); + Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); + Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); + // Set defaults which should be overriden by mapper + control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + + // Set ALL_DIMENSIONS specifications using mapper + Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::ALL_DIMENSIONS ); + + // Test WIDTH and HEIGHT updated + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliLayoutingSizeNegotiationMapper_02(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_02 - Test mapping for Dimension::WIDTH only"); + + auto control = Control::New(); + control.SetName( "fitToChildrenControl" ); + DevelControl::SetLayoutingRequired( control, true ); + control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); + + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); + Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); + Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); + + // Set defaults which should be overriden by mapper + control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + + // Set WIDTH specifications using mapper + Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::WIDTH ); + + // Test WIDTH only updated. + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliLayoutingSizeNegotiationMapper_03(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_03 - Test mapping for Dimension::HEIGHT only"); + + auto control = Control::New(); + control.SetName( "fitToChildrenControl" ); + DevelControl::SetLayoutingRequired( control, true ); + control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); + + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); + Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); + Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); + + // Set defaults which should be overriden by mapper + control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); + + // Set HEIGHT specifications using mapper + Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::HEIGHT ); + + // Test HEIGHT only updated. + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT), TEST_LOCATION ); + + END_TEST; +} \ No newline at end of file diff --git a/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp b/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp index a0f052a..2a1c7a3 100644 --- a/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp +++ b/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp @@ -150,17 +150,13 @@ void SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( Toolkit::Contr // matchedLayoutParamHeight should not be used. if( matchFound ) { - if( dimension == Dimension::WIDTH ) + if( dimension & Dimension::WIDTH ) { SetWidthLayoutParams( control, matchedLayoutParamWidth ); } - else if( dimension == Dimension::HEIGHT ) - { - SetHeightLayoutParams( control, matchedLayoutParamHeight ); - } - else if( Dimension::ALL_DIMENSIONS ) + + if( dimension & Dimension::HEIGHT ) { - SetWidthLayoutParams( control, matchedLayoutParamWidth ); SetHeightLayoutParams( control, matchedLayoutParamHeight ); } } -- 2.7.4