It is possible that user set invalid value type.
If then, we need to skip given value setter.
Change-Id: I1d3074c6bf7ee061cb195195a90f8b07fe04db7f
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
// Test "rows" property
DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_ROWS) == TableView::Property::ROWS);
- tableView.SetProperty(TableView::Property::ROWS, 4);
+ tableView.SetProperty(TableView::Property::ROWS, 7);
- DALI_TEST_CHECK(tableView.GetRows() == 4u);
- DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::ROWS).Get<int>() == 4);
+ DALI_TEST_CHECK(tableView.GetRows() == 7u);
+ DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::ROWS).Get<int>() == 7);
// Test "columns" property
DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_COLUMNS) == TableView::Property::COLUMNS);
- tableView.SetProperty(TableView::Property::COLUMNS, 5);
+ tableView.SetProperty(TableView::Property::COLUMNS, 8);
- DALI_TEST_CHECK(tableView.GetColumns() == 5u);
- DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::COLUMNS).Get<int>() == 5);
+ DALI_TEST_CHECK(tableView.GetColumns() == 8u);
+ DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::COLUMNS).Get<int>() == 8);
// Test "cellPadding" property
DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_CELL_PADDING) == TableView::Property::CELL_PADDING);
Property::Map item2;
item2["policy"] = "relative";
item2["value"] = 0.2f;
+ //{ "policy": "fill"},
+ Property::Map item3;
+ item3["policy"] = "fill";
+ //{ "policy": "fit"},
+ Property::Map item4;
+ item4["policy"] = "fit";
// Test "layoutRows" property
DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS);
* "layoutRows":
* {
* "1": { "policy": "fixed", "value": 30 },
- * "3": { "policy": "relative", "value": 0.2 }
+ * "3": { "policy": "relative", "value": 0.2 },
+ * "4": { "policy": "fill" },
+ * "6": { "policy": "fit" },
* }
*/
Property::Map layoutRows;
layoutRows["1"] = item1;
layoutRows["3"] = item2;
+ layoutRows["4"] = item3;
+ layoutRows["6"] = item4;
tableView.SetProperty(TableView::Property::LAYOUT_ROWS, layoutRows);
DALI_TEST_EQUALS(tableView.GetFixedHeight(1u), 30.f, TEST_LOCATION);
DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("relative") == 0);
DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 0.2f, TEST_LOCATION);
+ childMap = layoutRowsGet.GetValue(4).GetMap();
+ DALI_TEST_CHECK(layoutRowsGet.GetKey(4).compare(layoutRows.GetKey(2)) == 0);
+ DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fill") == 0);
+
+ childMap = layoutRowsGet.GetValue(6).GetMap();
+ DALI_TEST_CHECK(layoutRowsGet.GetKey(6).compare(layoutRows.GetKey(3)) == 0);
+ DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fit") == 0);
+
// Test "layoutColumns" property
DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_COLUMNS) == TableView::Property::LAYOUT_COLUMNS);
* "layoutColumns":
* {
* "2": { "policy": "relative", "value": 0.2 },
- * "3": { "policy": "fixed", "value": 30 }
+ * "3": { "policy": "fixed", "value": 30 },
+ * "5": { "policy": "fit" },
+ * "7": { "policy": "fill" }
* }
*/
Property::Map layoutColumns;
layoutColumns["2"] = item2;
layoutColumns["3"] = item1;
+ layoutColumns["5"] = item4;
+ layoutColumns["7"] = item3;
tableView.SetProperty(TableView::Property::LAYOUT_COLUMNS, layoutColumns);
DALI_TEST_EQUALS(tableView.GetRelativeWidth(2u), 0.2f, TEST_LOCATION);
DALI_TEST_EQUALS(tableView.GetFixedWidth(3u), 30.f, TEST_LOCATION);
Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
+
DALI_TEST_CHECK(layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0);
childMap = layoutColumnsGet.GetValue(2).GetMap();
DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("relative") == 0);
DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 0.2f, TEST_LOCATION);
+
childMap = layoutColumnsGet.GetValue(3).GetMap();
DALI_TEST_CHECK(layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0);
DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fixed") == 0);
DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 30.f, TEST_LOCATION);
+ childMap = layoutColumnsGet.GetValue(5).GetMap();
+ DALI_TEST_CHECK(layoutColumnsGet.GetKey(5).compare(layoutColumns.GetKey(2)) == 0);
+ DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fit") == 0);
+
+ childMap = layoutColumnsGet.GetValue(7).GetMap();
+ DALI_TEST_CHECK(layoutColumnsGet.GetKey(7).compare(layoutColumns.GetKey(3)) == 0);
+ DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fill") == 0);
+
END_TEST;
}
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
{
// If we find "{","}" pair but can't find matched constant
// try to find other "{","}" pair after current left position.
- pos = leftPos + 1;
+ pos = rightPos + 1;
for(uint32_t i = 0; i < mReplacementMap.Count(); i++)
{
if(0 == stringConfigValue.compare(leftPos + 1, rightPos - leftPos - 1, constant.stringKey))
{
std::string replaceString;
- mReplacementMap.GetValue(i).Get(replaceString);
-
- stringConfigValue.replace(leftPos, rightPos - leftPos + 1, replaceString);
- pos = leftPos + replaceString.size();
- break;
+ if(DALI_LIKELY(mReplacementMap.GetValue(i).Get(replaceString)))
+ {
+ stringConfigValue.replace(leftPos, rightPos - leftPos + 1, replaceString);
+ pos = leftPos + replaceString.size();
+ break;
+ }
}
}
}
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
std::vector<std::string> tips;
size_t tipsCount = tipArray->Count();
tips.resize(tipsCount);
+
+ bool valid = true;
for(size_t i = 0; i != tipsCount; ++i)
{
- tipArray->GetElementAt(i).Get(tips[i]);
+ if(DALI_UNLIKELY(!tipArray->GetElementAt(i).Get(tips[i])))
+ {
+ // Given array is invalid. Fast out.
+ valid = false;
+ break;
+ }
+ }
+
+ if(DALI_LIKELY(valid))
+ {
+ toggleButtonImpl.SetToggleTooltips(tips);
}
- toggleButtonImpl.SetToggleTooltips(tips);
}
break;
}
if(propertyIndex == Toolkit::SuperBlurView::Property::IMAGE_URL)
{
- value.Get(superBlurViewImpl.mUrl);
-
- PixelData pixels = SyncImageLoader::Load(superBlurViewImpl.mUrl);
-
- if(pixels)
- {
- Texture texture = Texture::New(TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight());
- texture.Upload(pixels, 0, 0, 0, 0, pixels.GetWidth(), pixels.GetHeight());
-
- superBlurViewImpl.SetTexture(texture);
- }
- else
+ if(DALI_LIKELY(value.Get(superBlurViewImpl.mUrl)))
{
- DALI_LOG_ERROR("Cannot create image from property value\n");
+ PixelData pixels = SyncImageLoader::Load(superBlurViewImpl.mUrl);
+
+ if(pixels)
+ {
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight());
+ texture.Upload(pixels, 0, 0, 0, 0, pixels.GetWidth(), pixels.GetHeight());
+
+ superBlurViewImpl.SetTexture(texture);
+ }
+ else
+ {
+ DALI_LOG_ERROR("Cannot create image from property value\n");
+ }
}
}
}
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
std::istringstream(map->GetKey(i)) >> index;
if(childMap)
{
- Property::Value* policy = childMap->Find("policy");
- Property::Value* childMapValue = childMap->Find("value");
- if(policy && childMapValue)
+ Property::Value* policy = childMap->Find("policy");
+ if(policy)
{
std::string policyValue;
- policy->Get(policyValue);
- Toolkit::TableView::LayoutPolicy policy;
- if(Scripting::GetEnumeration<Toolkit::TableView::LayoutPolicy>(policyValue.c_str(),
- LAYOUT_POLICY_STRING_TABLE,
- LAYOUT_POLICY_STRING_TABLE_COUNT,
- policy))
+ if(DALI_LIKELY(policy->Get(policyValue)))
{
- if(policy == Toolkit::TableView::FIXED)
+ Toolkit::TableView::LayoutPolicy policy;
+ if(Scripting::GetEnumeration<Toolkit::TableView::LayoutPolicy>(policyValue.c_str(),
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT,
+ policy))
{
- (tableViewImpl.*funcFixed)(index, childMapValue->Get<float>());
- }
- else if(policy == Toolkit::TableView::RELATIVE)
- {
- (tableViewImpl.*funcRelative)(index, childMapValue->Get<float>());
- }
- else if(policy == Toolkit::TableView::FIT)
- {
- (tableViewImpl.*funcFit)(index);
+ switch(policy)
+ {
+ case Toolkit::TableView::FIXED:
+ case Toolkit::TableView::RELATIVE:
+ {
+ Property::Value* childMapValue = childMap->Find("value");
+ float childValue = 0.0f;
+ if(DALI_LIKELY(childMapValue && childMapValue->Get(childValue)))
+ {
+ if(policy == Toolkit::TableView::FIXED)
+ {
+ (tableViewImpl.*funcFixed)(index, childValue);
+ }
+ else // if(policy == Toolkit::TableView::RELATIVE)
+ {
+ (tableViewImpl.*funcRelative)(index, childValue);
+ }
+ }
+ break;
+ }
+ case Toolkit::TableView::FIT:
+ {
+ (tableViewImpl.*funcFit)(index);
+ break;
+ }
+ default:
+ {
+ // do nothing for FILL policy
+ break;
+ }
+ }
}
- // do nothing for FILL policy
}
}
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
if(type == Property::STRING)
{
- value.Get(mBackgroundImage);
- mBackgroundBorder.Set(0, 0, 0, 0);
+ if(DALI_LIKELY(value.Get(mBackgroundImage)))
+ {
+ mBackgroundBorder.Set(0, 0, 0, 0);
+ }
}
else if(type == Property::MAP)
{