diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 2ceb5c3c42e7915d79d1a6c85debc6c36e1bee31..95deffcc962796f54ff19c691d2e69c5b21c231f 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -3852,7 +3852,7 @@ void ViewAbstract::SetBorderImageGradient(FrameNode* frameNode, const NG::Gradie } void ViewAbstract::SetForegroundBlurStyle( - FrameNode* frameNode, const BlurStyleOption& fgBlurStyle, const SysOptions& sysOptions) + FrameNode* frameNode, const std::optional& fgBlurStyle, const SysOptions& sysOptions) { const auto target = frameNode->GetRenderContext(); if (target) { @@ -3942,7 +3942,8 @@ void ViewAbstract::SetRenderFit(FrameNode* frameNode, RenderFit renderFit) ACE_UPDATE_NODE_RENDER_CONTEXT(RenderFit, renderFit, frameNode); } -void ViewAbstract::SetUseEffect(FrameNode* frameNode, bool useEffect, EffectType effectType) +void ViewAbstract::SetUseEffect( + FrameNode* frameNode, const std::optional& useEffect, const std::optional& effectType) { CHECK_NULL_VOID(frameNode); auto* pipeline = frameNode->GetContext(); @@ -3952,20 +3953,21 @@ void ViewAbstract::SetUseEffect(FrameNode* frameNode, bool useEffect, EffectType } else { pipeline->RemoveWindowActivateChangedCallback(frameNode->GetId()); } - const auto& target = frameNode->GetRenderContext(); - if (target) { - target->UpdateUseEffect(useEffect); - target->UpdateUseEffectType(effectType); + SetUseEffect(frameNode, useEffect); + if (effectType) { + ACE_UPDATE_NODE_RENDER_CONTEXT(UseEffectType, *effectType, frameNode); + } else { + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, UseEffectType, frameNode); } } void ViewAbstract::SetUseEffect(FrameNode* frameNode, const std::optional& useEffect) { + CHECK_NULL_VOID(frameNode); if (useEffect.has_value()) { - ACE_UPDATE_NODE_RENDER_CONTEXT(UseEffect, useEffect.value(), frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(UseEffect, *useEffect, frameNode); } else { - auto target = frameNode->GetRenderContext(); - ACE_RESET_NODE_RENDER_CONTEXT(target, UseEffect, frameNode); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, UseEffect, frameNode); } } @@ -4460,12 +4462,12 @@ void ViewAbstract::SetMotionBlur(FrameNode* frameNode, const std::optional& effectOption, const SysOptions& sysOptions) { CHECK_NULL_VOID(frameNode); auto pipeline = frameNode->GetContext(); CHECK_NULL_VOID(pipeline); - if (effectOption.policy == BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) { + if (effectOption && effectOption->policy == BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE) { pipeline->AddWindowFocusChangedCallback(frameNode->GetId()); } else { pipeline->RemoveWindowFocusChangedCallback(frameNode->GetId()); diff --git a/frameworks/core/components_ng/base/view_abstract.h b/frameworks/core/components_ng/base/view_abstract.h index 67dd569e024eeb53b184517995547a67317be2fa..69951385d47b2ff7a5525fc2250ac9ac0e405481 100644 --- a/frameworks/core/components_ng/base/view_abstract.h +++ b/frameworks/core/components_ng/base/view_abstract.h @@ -609,8 +609,8 @@ public: static void SetHasBorderImageOutset(FrameNode* frameNode, bool tag); static void SetHasBorderImageRepeat(FrameNode* frameNode, bool tag); static void SetBorderImageGradient(FrameNode* frameNode, const NG::Gradient& gradient); - static void SetForegroundBlurStyle( - FrameNode* frameNode, const BlurStyleOption& fgBlurStyle, const SysOptions& sysOptions = SysOptions()); + static void SetForegroundBlurStyle(FrameNode* frameNode, + const std::optional& fgBlurStyle, const SysOptions& sysOptions = SysOptions()); static void SetLinearGradientBlur(FrameNode* frameNode, const NG::LinearGradientBlurPara& blurPara); static void SetMagnifier(FrameNode* frameNode, const MagnifierParams& magnifierOffset); static void ReSetMagnifier(FrameNode* frameNode); @@ -636,7 +636,8 @@ public: static void SetSphericalEffect(FrameNode* frameNode, const std::optional radio); static void SetRenderGroup(FrameNode* frameNode, bool isRenderGroup); static void SetRenderFit(FrameNode* frameNode, RenderFit renderFit); - static void SetUseEffect(FrameNode* frameNode, bool useEffect, EffectType effectType); + static void SetUseEffect( + FrameNode* frameNode, const std::optional& useEffect, const std::optional& effectType); static void SetUseEffect(FrameNode* frameNode, const std::optional& useEffect); static void SetForegroundColor(FrameNode* frameNode, const Color& color); static void SetForegroundColorStrategy(FrameNode* frameNode, @@ -689,8 +690,8 @@ public: static void SetObscured(FrameNode* frameNode, const std::vector& reasons); static void SetMotionBlur(FrameNode* frameNode, const std::optional& motionBlurOption); static void SetForegroundEffect(FrameNode* frameNode, float radius); - static void SetBackgroundEffect( - FrameNode* frameNode, const EffectOption& effectOption, const SysOptions& sysOptions = SysOptions()); + static void SetBackgroundEffect(FrameNode* frameNode, const std::optional& effectOption, + const SysOptions& sysOptions = SysOptions()); static void SetBackgroundImageResizableSlice(FrameNode* frameNode, const ImageResizableSlice& slice); static void SetDynamicLightUp(FrameNode* frameNode, float rate, float lightUpDegree); static void SetBgDynamicBrightness(FrameNode* frameNode, const BrightnessOption& brightnessOption); diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_property.cpp b/frameworks/core/components_ng/pattern/menu/menu_layout_property.cpp index e3c0200cf7852ca3f6019bfa8d28bba3ab6bd5d5..bc78e8968788afe5fe34a87a2d41b38e331d9faa 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_property.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_property.cpp @@ -99,6 +99,21 @@ void MenuLayoutProperty::ToJsonValue(std::unique_ptr& json, const Ins expandingMode = "SubMenuExpandingMode.STACK"; } json->Put("subMenuExpandingMode", expandingMode); + json->PutExtAttr("avoidance", + AvoidanceModeToString(propSelectAvoidanceMode_.value_or(AvoidanceMode::COVER_TARGET)).c_str(), filter); + auto jsonBorder = JsonUtil::Create(true); + GetBorderRadius().value_or(BorderRadiusProperty()).ToJsonValue(jsonBorder, json, filter); DividerToJsonValue(json); } + +std::string MenuLayoutProperty::AvoidanceModeToString(AvoidanceMode mode) const +{ + switch (mode) { + case AvoidanceMode::AVOID_AROUND_TARGET: + return "AvoidanceMode.AVOID_AROUND_TARGET"; + case AvoidanceMode::COVER_TARGET: + default: + return "AvoidanceMode.COVER_TARGET"; + } +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_property.h b/frameworks/core/components_ng/pattern/menu/menu_layout_property.h index 368bc7e655ef10e3a23925f21753969f8d4edee8..bda298b62aecd58b0da54af5cc864367d26a8e9d 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_property.h +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_property.h @@ -139,6 +139,8 @@ public: void BindToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const; void DividerToJsonValue(std::unique_ptr& json) const; ACE_DISALLOW_COPY_AND_MOVE(MenuLayoutProperty); +private: + std::string AvoidanceModeToString(AvoidanceMode mode) const; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/select/select_model_ng.cpp b/frameworks/core/components_ng/pattern/select/select_model_ng.cpp index 106fd64ac5cb60d0c43a0c2d81a724c1bba44f32..84be52b767cd7e1449eb391229cba2457998c79e 100644 --- a/frameworks/core/components_ng/pattern/select/select_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/select/select_model_ng.cpp @@ -449,7 +449,8 @@ void SelectModelNG::SetDivider(FrameNode* frameNode, const std::optionalSetDividerMode(std::nullopt); } -void SelectModelNG::SetDividerStyle(FrameNode* frameNode, const NG::SelectDivider& divider, const DividerMode& mode) +void SelectModelNG::SetDividerStyle( + FrameNode* frameNode, const std::optional& divider, const std::optional& mode) { CHECK_NULL_VOID(frameNode); auto pattern = frameNode->GetPattern(); @@ -596,11 +597,11 @@ void SelectModelNG::SetMenuAlign(FrameNode* frameNode, const MenuAlign& menuAlig pattern->SetMenuAlign(menuAlign); } -void SelectModelNG::SetAvoidance(FrameNode* frameNode, const Avoidance& avoidance) +void SelectModelNG::SetAvoidance(FrameNode* frameNode, const std::optional& mode) { auto pattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern(frameNode); CHECK_NULL_VOID(pattern); - pattern->SetAvoidance(avoidance); + pattern->SetAvoidance(mode); } void SelectModelNG::SetValue(FrameNode* frameNode, const std::optional& value) @@ -895,11 +896,11 @@ void SelectModelNG::SetMenuOutline(const MenuParam& menuParam) pattern->SetMenuOutline(menuParam); } -void SelectModelNG::SetMenuOutline(FrameNode* frameNode, const MenuParam& menuParam) +void SelectModelNG::SetMenuOutline(FrameNode* frameNode, const std::optional& menuParam) { CHECK_NULL_VOID(frameNode); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); - pattern->SetMenuOutline(menuParam); + pattern->SetMenuOutline(menuParam.value_or(MenuParam())); } } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/select/select_model_ng.h b/frameworks/core/components_ng/pattern/select/select_model_ng.h index 6f08ab933548bb3c5a9568d6ba80e651cbf538f9..0f42eb1bc858abc8d15002f4cd33a3544fb0d1e5 100644 --- a/frameworks/core/components_ng/pattern/select/select_model_ng.h +++ b/frameworks/core/components_ng/pattern/select/select_model_ng.h @@ -83,7 +83,8 @@ public: void SetDivider(const NG::SelectDivider& divider) override; void SetDividerStyle(const NG::SelectDivider& divider, const DividerMode& mode) override; static void SetDivider(FrameNode* frameNode, const std::optional& divider); - static void SetDividerStyle(FrameNode* frameNode, const NG::SelectDivider& divider, const DividerMode& mode); + static void SetDividerStyle(FrameNode* frameNode, + const std::optional& divider, const std::optional& mode); static void ResetDividerStyle(FrameNode* frameNode); void SetControlSize(const std::optional& controlSize) override; void SetLayoutDirection(TextDirection value) override; @@ -103,7 +104,7 @@ public: static void SetArrowPosition(FrameNode* frameNode, const std::optional& value); static void SetSpace(FrameNode* frameNode, const std::optional& value); static void SetMenuAlign(FrameNode* frameNode, const MenuAlign& menuAlign); - static void SetAvoidance(FrameNode* frameNode, const Avoidance& avoidance); + static void SetAvoidance(FrameNode* frameNode, const std::optional& mode); static void SetValue(FrameNode* frameNode, const std::optional& value); static void SetSelected(FrameNode* frameNode, const std::optional& idx); static void SetFontSize(FrameNode* frameNode, const std::optional& value); @@ -133,7 +134,7 @@ public: static void SetSelectChangeEvent(FrameNode* frameNode, NG::SelectChangeEvent&& selectChangeEvent); static void SetValueChangeEvent(FrameNode* frameNode, NG::ValueChangeEvent&& valueChangeEvent); static void SetLayoutDirection(FrameNode* frameNode, TextDirection value); - static void SetMenuOutline(FrameNode* frameNode, const MenuParam& menuParam); + static void SetMenuOutline(FrameNode* frameNode, const std::optional& menuParam); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SELECT_SELECT_MODEL_NG_H diff --git a/frameworks/core/components_ng/pattern/select/select_pattern.cpp b/frameworks/core/components_ng/pattern/select/select_pattern.cpp index 57bb034b3555b1956cadedf557f39fc4989c5789..9bb3f1451aa3c3b13123b31bee77aa89fec61fc7 100644 --- a/frameworks/core/components_ng/pattern/select/select_pattern.cpp +++ b/frameworks/core/components_ng/pattern/select/select_pattern.cpp @@ -1250,6 +1250,7 @@ void SelectPattern::ToJsonValue(std::unique_ptr& json, const Inspecto CHECK_NULL_VOID(menuLayoutProps); std::string optionHeight = std::to_string(menuLayoutProps->GetSelectModifiedHeightValue(0.0f)); json->PutExtAttr("optionHeight", optionHeight.c_str(), filter); + menuLayoutProps->ToJsonValue(json, filter); ToJsonMenuBackgroundStyle(json, filter); ToJsonDivider(json, filter); } @@ -1309,6 +1310,17 @@ void SelectPattern::ToJsonMenuBackgroundStyle( } } +std::string SelectPattern::DividerModeToString(const DividerMode& mode) const +{ + switch (mode) { + case DividerMode::FLOATING_ABOVE_MENU: + return "DividerMode.FLOATING_ABOVE_MENU"; + case DividerMode::EMBEDDED_IN_MENU: + default: + return "DividerMode.EMBEDDED_IN_MENU"; + } +} + void SelectPattern::ToJsonDivider(std::unique_ptr& json, const InspectorFilter& filter) const { /* no fixed attr below, just return */ @@ -1326,6 +1338,13 @@ void SelectPattern::ToJsonDivider(std::unique_ptr& json, const Inspec divider->Put("startMargin", props->GetDividerValue().startMargin.ToString().c_str()); divider->Put("endMargin", props->GetDividerValue().endMargin.ToString().c_str()); divider->Put("color", props->GetDividerValue().color.ColorToString().c_str()); + auto menu = GetMenuNode(); + CHECK_NULL_VOID(menu); + auto menuLayoutProps = menu->GetLayoutProperty(); + if (menuLayoutProps) { + divider->Put("mode", DividerModeToString( + menuLayoutProps->GetItemDividerMode().value_or(DividerMode::EMBEDDED_IN_MENU)).c_str()); + } json->PutExtAttr("divider", divider->ToString().c_str(), filter); } else { json->PutExtAttr("divider", "", filter); @@ -1481,14 +1500,15 @@ void SelectPattern::SetMenuAlign(const MenuAlign& menuAlign) menuLayoutProps->UpdateOffset(menuAlign.offset); } -void SelectPattern::SetAvoidance(const Avoidance& avoidance) +void SelectPattern::SetAvoidance(const std::optional& avoidance) { - avoidance_ = avoidance; + CHECK_NULL_VOID(avoidance); + avoidance_ = *avoidance; auto menu = GetMenuNode(); CHECK_NULL_VOID(menu); auto menuLayoutProps = menu->GetLayoutProperty(); CHECK_NULL_VOID(menuLayoutProps); - menuLayoutProps->UpdateSelectAvoidanceMode(avoidance.mode); + menuLayoutProps->UpdateSelectAvoidanceMode(avoidance->mode); } std::string SelectPattern::ProvideRestoreInfo() diff --git a/frameworks/core/components_ng/pattern/select/select_pattern.h b/frameworks/core/components_ng/pattern/select/select_pattern.h index a8de60e62bdcb86d028d38f8a71e78a87119edbc..3dd099b0960eb0a88d2d12cf9ce79828fefc31d1 100644 --- a/frameworks/core/components_ng/pattern/select/select_pattern.h +++ b/frameworks/core/components_ng/pattern/select/select_pattern.h @@ -189,7 +189,7 @@ public: void SetSpace(const Dimension& value); void SetArrowPosition(const ArrowPosition value); void SetMenuAlign(const MenuAlign& menuAlign); - void SetAvoidance(const Avoidance& avoidance); + void SetAvoidance(const std::optional& avoidance); std::string GetValue(); std::string ProvideRestoreInfo() override; @@ -324,9 +324,13 @@ private: void ToJsonOptionAlign(std::unique_ptr& json, const InspectorFilter& filter) const; void ToJsonMenuBackgroundStyle(std::unique_ptr& json, const InspectorFilter& filter) const; void ToJsonDivider(std::unique_ptr& json, const InspectorFilter& filter) const; + void ToJsonOptionMaxlines(std::unique_ptr& json, const InspectorFilter& filter) const; + // XTS inspector helper functions std::string InspectorGetOptions() const; std::string InspectorGetSelectedFont() const; + std::string AvoidanceModeToString(AvoidanceMode mode) const; + std::string DividerModeToString(const DividerMode& mode) const; std::optional rowId_; std::optional textId_; diff --git a/frameworks/core/components_ng/render/render_context.cpp b/frameworks/core/components_ng/render/render_context.cpp index bc80f5527ea6c91f57d3049426a663f0a9011c90..374334dfcf1d073c922259799dba4fcfa03469c8 100644 --- a/frameworks/core/components_ng/render/render_context.cpp +++ b/frameworks/core/components_ng/render/render_context.cpp @@ -159,6 +159,7 @@ void RenderContext::ToJsonValue(std::unique_ptr& json, const Inspecto json->PutExtAttr("clickEffect", clickEffectJsonValue, filter); } ObscuredToJsonValue(json, filter); + ForegroundBlurStyleToJsonValue(json, filter); json->PutExtAttr("renderGroup", propRenderGroup_.value_or(false) ? "true" : "false", filter); json->PutExtAttr("renderFit", RenderFitToString(propRenderFit_.value_or(RenderFit::TOP_LEFT)).c_str(), filter); json->PutExtAttr("useShadowBatching", propUseShadowBatching_.value_or(false) ? "true" : "false", filter); @@ -183,6 +184,104 @@ void RenderContext::ObscuredToJsonValue(std::unique_ptr& json, const json->PutExtAttr("obscured", jsonObscuredArray, filter); } +std::string RenderContext::BlurStyleToString(const BlurStyle& blurStyle) const +{ + switch (blurStyle) { + case BlurStyle::NO_MATERIAL: + return "BlurStyle.NO_MATERIAL"; + case BlurStyle::THIN: + return "BlurStyle.THIN"; + case BlurStyle::REGULAR: + return "BlurStyle.REGULAR"; + case BlurStyle::THICK: + return "BlurStyle.THICK"; + case BlurStyle::BACKGROUND_THIN: + return "BlurStyle.BACKGROUND_THIN"; + case BlurStyle::BACKGROUND_REGULAR: + return "BlurStyle.BACKGROUND_REGULAR"; + case BlurStyle::BACKGROUND_THICK: + return "BlurStyle.BACKGROUND_THICK"; + case BlurStyle::BACKGROUND_ULTRA_THICK: + return "BlurStyle.BACKGROUND_ULTRA_THICK"; + case BlurStyle::COMPONENT_ULTRA_THIN: + return "BlurStyle.COMPONENT_ULTRA_THIN"; + case BlurStyle::COMPONENT_THIN: + return "BlurStyle.COMPONENT_THIN"; + case BlurStyle::COMPONENT_REGULAR: + return "BlurStyle.COMPONENT_REGULAR"; + case BlurStyle::COMPONENT_THICK: + return "BlurStyle.COMPONENT_THICK"; + case BlurStyle::COMPONENT_ULTRA_THICK: + return "BlurStyle.COMPONENT_ULTRA_THICK"; + case BlurStyle::COMPONENT_ULTRA_THICK_WINDOW: + return "BlurStyle.COMPONENT_ULTRA_THICK_WINDOW"; + default: + return ""; + } +} + +std::string RenderContext::ColorModeToString(const ThemeColorMode& colorMode) const +{ + switch (colorMode) { + case ThemeColorMode::SYSTEM: + return "ThemeColorMode.SYSTEM"; + case ThemeColorMode::LIGHT: + return "ThemeColorMode.LIGHT"; + case ThemeColorMode::DARK: + return "ThemeColorMode.DARK"; + default: + return ""; + } +} + +std::string RenderContext::AdaptiveColorToString(const AdaptiveColor& adaptiveColor) const +{ + switch (adaptiveColor) { + case AdaptiveColor::DEFAULT: + return "AdaptiveColor.DEFAULT"; + case AdaptiveColor::AVERAGE: + return "AdaptiveColor.AVERAGE"; + default: + return ""; + } +} + +void RenderContext::ForegroundBlurStyleToJsonValue( + std::unique_ptr& json, const InspectorFilter& filter) const +{ + /* no fixed attr below, just return */ + if (filter.IsFastFilter()) { + return; + } + auto jsonForegroundBlurStyle = JsonUtil::Create(false); + const auto& foregroundBlurStyle = GetForeground(); + if (foregroundBlurStyle) { + auto blurOptions = foregroundBlurStyle->propBlurStyleOption; + if (blurOptions) { + jsonForegroundBlurStyle->Put("style", BlurStyleToString(blurOptions->blurStyle).c_str()); + auto jsonOptions = JsonUtil::Create(false); + jsonOptions->Put("colorMode", ColorModeToString(blurOptions->colorMode).c_str()); + jsonOptions->Put("adaptiveColor", AdaptiveColorToString(blurOptions->adaptiveColor).c_str()); + auto jsonGrayscale = JsonUtil::CreateArray(false); + for (int i = 0; i < blurOptions->blurOption.grayscale.size(); ++i) { + jsonGrayscale->Put("grayscale", blurOptions->blurOption.grayscale.at(i)); + } + auto jsonBlurOptions = JsonUtil::Create(false); + jsonBlurOptions->Put("grayscale", jsonGrayscale); + jsonOptions->Put("blurOptions", jsonBlurOptions); + jsonOptions->Put("scale", blurOptions->scale); + jsonForegroundBlurStyle->Put("options", jsonOptions); + } + auto sysOptions = foregroundBlurStyle->propSysOptionsForBlur; + if (sysOptions) { + auto jsonDisableSystemAdaptation = JsonUtil::Create(false); + jsonDisableSystemAdaptation->Put("disableSystemAdaptation", sysOptions->disableSystemAdaptation); + jsonForegroundBlurStyle->Put("sysOptions", jsonDisableSystemAdaptation); + } + } + json->PutExtAttr("foregroundBlurStyle", jsonForegroundBlurStyle, filter); +} + void RenderContext::FromJson(const std::unique_ptr& json) { auto borderRadius = json->GetValue("borderRadius"); diff --git a/frameworks/core/components_ng/render/render_context.h b/frameworks/core/components_ng/render/render_context.h index 5879c2a6db2df5129cc945c4653ea06d276a7e14..08ff44f39490279d64e54af53537c3a4f00e0ab5 100644 --- a/frameworks/core/components_ng/render/render_context.h +++ b/frameworks/core/components_ng/render/render_context.h @@ -457,6 +457,7 @@ public: virtual void DumpAdvanceInfo(std::unique_ptr& json) {} void ObscuredToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const; + void ForegroundBlurStyleToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const; void TransitionToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const; void SetSharedTransitionOptions(const std::shared_ptr& option); @@ -903,6 +904,10 @@ private: WeakPtr host_; RefPtr oneCenterTransition_; ACE_DISALLOW_COPY_AND_MOVE(RenderContext); + + std::string BlurStyleToString(const BlurStyle& blurStyle) const; + std::string ColorModeToString(const ThemeColorMode& colorMode) const; + std::string AdaptiveColorToString(const AdaptiveColor& adaptiveColor) const; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp b/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp index a2b5b206b03739548d337f743c50662ca845c5f7..13ac9b6614db24cce9262087e468b0e5760d29bd 100644 --- a/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp @@ -37,6 +37,7 @@ #include "core/interfaces/native/utility/callback_helper.h" #include "core/interfaces/native/generated/interface/node_api.h" #include "core/interfaces/native/implementation/color_metrics_peer.h" +#include "core/interfaces/native/implementation/common_method_modifier_impl.h" #include "core/interfaces/native/implementation/drag_event_peer.h" #include "core/interfaces/native/implementation/focus_axis_event_peer.h" #include "core/interfaces/native/implementation/gesture_group_interface_peer.h" @@ -912,22 +913,6 @@ OverlayOptions Convert(const Ark_OverlayOptions& src) return dst; } -template<> -BorderWidthProperty Convert(const Ark_EdgeOutlineWidths& src) -{ - BorderWidthProperty dst; - dst.leftDimen = OptConvert(src.left); - Validator::ValidateNonNegative(dst.leftDimen); - dst.topDimen = OptConvert(src.top); - Validator::ValidateNonNegative(dst.topDimen); - dst.rightDimen = OptConvert(src.right); - Validator::ValidateNonNegative(dst.rightDimen); - dst.bottomDimen = OptConvert(src.bottom); - Validator::ValidateNonNegative(dst.bottomDimen); - dst.multiValued = true; - return dst; -} - template<> BorderRadiusProperty Convert(const Ark_OutlineRadiuses& src) { @@ -2130,14 +2115,7 @@ void BackgroundImagePositionImpl(Ark_NativePointer node, void BackgroundEffect0Impl(Ark_NativePointer node, const Opt_BackgroundEffectOptions* value) { - auto frameNode = reinterpret_cast(node); - CHECK_NULL_VOID(frameNode); - auto convValue = Converter::OptConvertPtr(value); - if (!convValue) { - // TODO: Reset value - return; - } - ViewAbstract::SetBackgroundEffect(frameNode, *convValue); + BackgroundEffect1Impl(node, value, nullptr); } void BackgroundEffect1Impl(Ark_NativePointer node, const Opt_BackgroundEffectOptions* options, @@ -2145,9 +2123,13 @@ void BackgroundEffect1Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = Converter::Convert(options); - //auto convValue = Converter::OptConvert(options); // for enums - //CommonMethodModelNG::SetBackgroundEffect1(frameNode, convValue); + auto convValue = Converter::OptConvertPtr(options); + auto sysAdaptiveOptions = Converter::OptConvertPtr(sysOptions); + if (sysAdaptiveOptions) { + ViewAbstract::SetBackgroundEffect(frameNode, convValue, *sysAdaptiveOptions); + } else { + ViewAbstract::SetBackgroundEffect(frameNode, convValue); + } } void BackgroundImageResizableImpl(Ark_NativePointer node, const Opt_ResizableOptions* value) @@ -3271,8 +3253,8 @@ void UseEffect0Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto convValue = Converter::OptConvertPtr(value); - ViewAbstract::SetUseEffect(frameNode, convValue); + auto effect = Converter::OptConvertPtr(value); + ViewAbstract::SetUseEffect(frameNode, effect); } void UseEffect1Impl(Ark_NativePointer node, const Opt_Boolean* useEffect, @@ -3280,19 +3262,15 @@ void UseEffect1Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = Converter::Convert(useEffect); - //auto convValue = Converter::OptConvert(useEffect); // for enums - //CommonMethodModelNG::SetUseEffect1(frameNode, convValue); + auto effect = Converter::OptConvertPtr(useEffect); + auto type = Converter::OptConvertPtr(effectType); + ViewAbstract::SetUseEffect(frameNode, effect, type); } void UseEffect2Impl(Ark_NativePointer node, const Opt_Boolean* useEffect, const Opt_EffectType* effectType) { - auto frameNode = reinterpret_cast(node); - CHECK_NULL_VOID(frameNode); - //auto convValue = Converter::Convert(useEffect); - //auto convValue = Converter::OptConvert(useEffect); // for enums - //CommonMethodModelNG::SetUseEffect2(frameNode, convValue); + UseEffect1Impl(node, useEffect, effectType); } void RenderGroup0Impl(Ark_NativePointer node, const Opt_Boolean* value) @@ -4990,16 +4968,7 @@ void ForegroundBlurStyle0Impl(Ark_NativePointer node, const Opt_BlurStyle* value, const Opt_ForegroundBlurStyleOptions* options) { - auto frameNode = reinterpret_cast(node); - CHECK_NULL_VOID(frameNode); - BlurStyleOption convValue; - if (auto opt = Converter::OptConvertPtr(options); opt) { - convValue = *opt; - } - if (auto style = Converter::OptConvertPtr(value); style) { - convValue.blurStyle = *style; - } - ViewAbstract::SetForegroundBlurStyle(frameNode, convValue); + ForegroundBlurStyle1Impl(node, value, options, nullptr); } void ForegroundBlurStyle1Impl(Ark_NativePointer node, const Opt_BlurStyle* style, @@ -5008,9 +4977,17 @@ void ForegroundBlurStyle1Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = Converter::Convert(style); - //auto convValue = Converter::OptConvert(style); // for enums - //CommonMethodModelNG::SetForegroundBlurStyle1(frameNode, convValue); + auto blurStyleOptions = options ? Converter::OptConvert(*options) : std::nullopt; + auto blurStyle = style ? Converter::OptConvert(*style) : std::nullopt; + if (blurStyleOptions && blurStyle) { + blurStyleOptions->blurStyle = *blurStyle; + } + auto sysAdaptiveOptions = sysOptions ? Converter::OptConvert(*sysOptions) : std::nullopt; + if (sysAdaptiveOptions) { + ViewAbstract::SetForegroundBlurStyle(frameNode, blurStyleOptions, *sysAdaptiveOptions); + } else { + ViewAbstract::SetForegroundBlurStyle(frameNode, blurStyleOptions); + } } void FocusScopeId0Impl(Ark_NativePointer node, const Opt_String* id, @@ -5128,7 +5105,12 @@ void Blur1Impl(Ark_NativePointer node, blurOptions = optionsOpt.value(); } CalcDimension dimensionBlur(blur, DimensionUnit::PX); - ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, blurOptions); + auto sysAdaptiveOptions = sysOptions ? Converter::OptConvert(*sysOptions) : std::nullopt; + if (sysAdaptiveOptions) { + ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, blurOptions, *sysAdaptiveOptions); + } else { + ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, blurOptions); + } } void LinearGradientBlur0Impl(Ark_NativePointer node, const Opt_Number* value, diff --git a/frameworks/core/interfaces/native/implementation/common_method_modifier_impl.h b/frameworks/core/interfaces/native/implementation/common_method_modifier_impl.h index 8d3d0a34be71f53aface96c10f6ab41fdbb8ae30..2d84171fc10c6e50d068f50411e5ba28e3202730 100755 --- a/frameworks/core/interfaces/native/implementation/common_method_modifier_impl.h +++ b/frameworks/core/interfaces/native/implementation/common_method_modifier_impl.h @@ -45,6 +45,13 @@ void CreateGesture(FrameNode *frameNode, const Ark_GestureType* gesture, const GestureMask& mask, const GesturePriority& priority); +namespace GeneratedModifier::CommonMethodModifier { +void BackgroundEffect1Impl( + Ark_NativePointer node, const Opt_BackgroundEffectOptions* options, const Opt_SystemAdaptiveOptions* sysOptions); +void ForegroundBlurStyle1Impl(Ark_NativePointer node, const Opt_BlurStyle* style, + const Opt_ForegroundBlurStyleOptions* options, const Opt_SystemAdaptiveOptions* sysOptions); +void UseEffect1Impl(Ark_NativePointer node, const Opt_Boolean* useEffect, const Opt_EffectType* effectType); +} } // OHOS::Ace::NG #endif // FOUNDATION_ARKUI_ACE_ENGINE_FRAMEWORKS_CORE_INTERFACES_NATIVE_COMMON_METHOD_MODIFIER_IMPL_H \ No newline at end of file diff --git a/frameworks/core/interfaces/native/implementation/select_modifier.cpp b/frameworks/core/interfaces/native/implementation/select_modifier.cpp index e1f0deab810bb8a86f1f9252d0271a354a264877..d3e548fbd2a4d65fb76d2bb63c57cf525894553c 100644 --- a/frameworks/core/interfaces/native/implementation/select_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/select_modifier.cpp @@ -16,6 +16,7 @@ #include #include "arkoala_api_generated.h" +#include "core/components/common/layout/constants.h" #include "core/components_ng/base/frame_node.h" #include "core/components_ng/pattern/select/select_model_ng.h" #include "core/components_ng/pattern/select/select_model_static.h" @@ -28,6 +29,11 @@ namespace OHOS::Ace::NG { namespace Converter { +struct SelectDividerStyle { + SelectDivider selectDivider; + std::optional dividerMode; +}; + template<> void AssignCast(std::optional& dst, const Ark_ArrowPosition& src) { @@ -59,6 +65,37 @@ void AssignCast(std::optional& dst, const Ark_OptionWidthMode& src) } } +template<> +void AssignCast(std::optional& dst, const Ark_AvoidanceMode& src) +{ + switch (src) { + case ARK_AVOIDANCE_MODE_COVER_TARGET: dst = AvoidanceMode::COVER_TARGET; break; + case ARK_AVOIDANCE_MODE_AVOID_AROUND_TARGET: dst = AvoidanceMode::AVOID_AROUND_TARGET; break; + default: LOGE("Unexpected enum value in Ark_AvoidanceMode: %{public}d", src); + } +} + +template<> +void AssignCast(std::optional& dst, const Ark_DividerMode& src) +{ + switch (src) { + case ARK_DIVIDER_MODE_FLOATING_ABOVE_MENU: dst = DividerMode::FLOATING_ABOVE_MENU; break; + case ARK_DIVIDER_MODE_EMBEDDED_IN_MENU: dst = DividerMode::EMBEDDED_IN_MENU; break; + default: LOGE("Unexpected enum value in Ark_DevideMode: %{public}d", src); + } +} + +template<> +Avoidance Convert(const Ark_AvoidanceMode& src) +{ + Avoidance avoidance; + auto mode = OptConvert(src); + if (mode) { + avoidance.mode = *mode; + } + return avoidance; +} + template<> SelectParam Convert(const Ark_SelectOption& src) { @@ -96,6 +133,48 @@ SelectDivider Convert(const Ark_DividerOptions& src) } return dst; } + +template<> +SelectDividerStyle Convert(const Ark_DividerStyleOptions& src) +{ + SelectDivider dst; + auto colorOpt = OptConvert(src.color); + if (colorOpt.has_value()) { + dst.color = *colorOpt; + } + auto strokeWidth = OptConvert(src.strokeWidth); + Validator::ValidateNonNegative(strokeWidth); + if (strokeWidth.has_value()) { + dst.strokeWidth = strokeWidth.value(); + } + auto startMargin = OptConvert(src.startMargin); + Validator::ValidateNonNegative(startMargin); + if (startMargin.has_value()) { + dst.startMargin = startMargin.value(); + } + auto endMargin = OptConvert(src.endMargin); + Validator::ValidateNonNegative(endMargin); + if (endMargin.has_value()) { + dst.endMargin = endMargin.value(); + } + return { + .selectDivider = dst, + .dividerMode = OptConvert(src.mode), + }; +} + +template<> +MenuParam Convert(const Ark_MenuOutlineOptions& src) +{ + MenuParam dst; + dst.outlineWidth = OptConvert(src.width); + Validator::ValidateNonPercent(dst.outlineWidth->topDimen); + Validator::ValidateNonPercent(dst.outlineWidth->rightDimen); + Validator::ValidateNonPercent(dst.outlineWidth->bottomDimen); + Validator::ValidateNonPercent(dst.outlineWidth->leftDimen); + dst.outlineColor = OptConvert(src.color); + return dst; +} } // namespace Converter } // namespace OHOS::Ace::NG @@ -498,26 +577,30 @@ void SelectedOptionTextModifierImpl(Ark_NativePointer node, void DividerStyleImpl(Ark_NativePointer node, const Opt_DividerStyleOptions* value) { - auto frameNode = reinterpret_cast(node); + auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = value ? Converter::OptConvert(*value) : std::nullopt; - //SelectModelNG::SetDividerStyle(frameNode, convValue); + auto divider = value ?Converter::OptConvert(*value) : std::nullopt; + if (divider) { + SelectModelNG::SetDividerStyle(frameNode, divider->selectDivider, divider->dividerMode); + } else { + SelectModelNG::SetDivider(frameNode, std::nullopt); + } } void AvoidanceImpl(Ark_NativePointer node, const Opt_AvoidanceMode* value) { - auto frameNode = reinterpret_cast(node); + auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = value ? Converter::OptConvert(*value) : std::nullopt; - //SelectModelNG::SetAvoidance(frameNode, convValue); + SelectModelNG::SetAvoidance(frameNode, Converter::OptConvertPtr(value)); } void MenuOutlineImpl(Ark_NativePointer node, const Opt_MenuOutlineOptions* value) { - auto frameNode = reinterpret_cast(node); + auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = value ? Converter::OptConvert(*value) : std::nullopt; - //SelectModelNG::SetMenuOutline(frameNode, convValue); + CHECK_NULL_VOID(value); + auto optConvert = Converter::OptConvert(*value); + SelectModelNG::SetMenuOutline(frameNode, optConvert); } void MenuAlign0Impl(Ark_NativePointer node, const Opt_MenuAlignType* alignType, diff --git a/frameworks/core/interfaces/native/utility/converter.cpp b/frameworks/core/interfaces/native/utility/converter.cpp index cc9cd69601ce86d2dc2999a6533b694180db8c22..61af54a11ba4cbaa01595dc4194820fb5e9d3293 100644 --- a/frameworks/core/interfaces/native/utility/converter.cpp +++ b/frameworks/core/interfaces/native/utility/converter.cpp @@ -740,6 +740,17 @@ StringArray Convert(const Ark_CustomObject& src) return StringArray(); } +template<> +SysOptions Convert(const Ark_SystemAdaptiveOptions& src) +{ + SysOptions options; + auto disableSystemAdaptation = OptConvert(src.disableSystemAdaptation); + if (disableSystemAdaptation) { + options.disableSystemAdaptation = disableSystemAdaptation.value(); + } + return options; +} + template<> Color Convert(const Ark_Number& src) { @@ -2135,6 +2146,22 @@ BorderWidthProperty Convert(const Ark_Length& src) return dst; } +template<> +BorderWidthProperty Convert(const Ark_EdgeOutlineWidths& src) +{ + BorderWidthProperty dst; + dst.leftDimen = OptConvert(src.left); + Validator::ValidateNonNegative(dst.leftDimen); + dst.topDimen = OptConvert(src.top); + Validator::ValidateNonNegative(dst.topDimen); + dst.rightDimen = OptConvert(src.right); + Validator::ValidateNonNegative(dst.rightDimen); + dst.bottomDimen = OptConvert(src.bottom); + Validator::ValidateNonNegative(dst.bottomDimen); + dst.multiValued = true; + return dst; +} + template<> BorderWidthProperty Convert(const Ark_EdgeWidths& src) { diff --git a/frameworks/core/interfaces/native/utility/converter.h b/frameworks/core/interfaces/native/utility/converter.h index 3ae663ec6de721840cd1e4591258ccfb2dd1b877..947b5f21cc7a8052de2c4909e007a8e69a7eb604 100644 --- a/frameworks/core/interfaces/native/utility/converter.h +++ b/frameworks/core/interfaces/native/utility/converter.h @@ -476,6 +476,7 @@ namespace Converter { template<> BorderRadiusProperty Convert(const Ark_LengthMetrics& src); template<> BorderRadiusProperty Convert(const Ark_LocalizedBorderRadiuses& src); template<> BorderStyleProperty Convert(const Ark_BorderStyle& src); + template<> BorderWidthProperty Convert(const Ark_EdgeOutlineWidths& src); template<> BorderStyleProperty Convert(const Ark_EdgeStyles& src); template<> BorderWidthProperty Convert(const Ark_EdgeWidths& src); template<> BorderWidthProperty Convert(const Ark_Length& src); @@ -596,6 +597,7 @@ namespace Converter { template<> SheetHeight Convert(const Ark_Length& src); template<> SheetHeight Convert(const Ark_SheetSize& src); template<> StringArray Convert(const Ark_CustomObject& src); + template<> SysOptions Convert(const Ark_SystemAdaptiveOptions& src); template<> TextBackgroundStyle Convert(const Ark_TextBackgroundStyle& src); template<> TextCascadePickerOptions Convert(const Ark_TextCascadePickerRangeContent& src); template<> TextDecorationOptions Convert(const Ark_TextDecorationOptions& src); @@ -723,6 +725,7 @@ namespace Converter { template<> void AssignCast(std::optional& dst, const Ark_NestedScrollMode& src); template<> void AssignCast(std::optional& dst, const Ark_EffectDirection& src); template<> void AssignCast(std::optional& dst, const Ark_EffectFillStyle& src); + template<> void AssignCast(std::optional& dst, const Ark_EffectType& src); template<> void AssignCast(std::optional& dst, const Ark_FontStyle& src); template<> void AssignCast(std::optional& dst, const Ark_EffectScope& src); template<> void AssignCast(std::optional& dst, const Ark_SymbolEffectStrategy& src); diff --git a/frameworks/core/interfaces/native/utility/converter_enums.cpp b/frameworks/core/interfaces/native/utility/converter_enums.cpp index d45e8f26f24a0370bc1aa535b7473960f3f1c6a3..ad38a145be94140d38dea844ff48961809653977 100644 --- a/frameworks/core/interfaces/native/utility/converter_enums.cpp +++ b/frameworks/core/interfaces/native/utility/converter_enums.cpp @@ -1909,6 +1909,16 @@ void AssignCast(std::optional& dst, const Ark_EffectFillSt } } template<> +void AssignCast(std::optional& dst, const Ark_EffectType& src) +{ + switch (src) { + case ARK_EFFECT_TYPE_DEFAULT: dst = EffectType::DEFAULT; break; + case ARK_EFFECT_TYPE_WINDOW_EFFECT: dst = EffectType::WINDOW_EFFECT; break; + default: + LOGE("Unexpected enum value in Ark_EffectType: %{public}d", src); + } +} +template<> void AssignCast(std::optional& dst, const Ark_PanDirection& src) { dst = PanDirection(); diff --git a/frameworks/core/interfaces/native/utility/reverse_converter.h b/frameworks/core/interfaces/native/utility/reverse_converter.h index 64811f76f017091fa89db9c728a4384f2ce8ba91..1f8f80572b4e136a0fe2ff05f66d05e2434f76b9 100644 --- a/frameworks/core/interfaces/native/utility/reverse_converter.h +++ b/frameworks/core/interfaces/native/utility/reverse_converter.h @@ -168,6 +168,7 @@ namespace OHOS::Ace::NG::Converter { // SORTED_SECTION void AssignArkValue(Ark_AccessibilityHoverType& dst, const AccessibilityHoverAction& src); + void AssignArkValue(Ark_AdaptiveColor& dst, const AdaptiveColor& src); void AssignArkValue(Ark_Affinity& dst, const Ace::TextAffinity& src); void AssignArkValue(Ark_Affinity& dst, const TextAffinity& src); void AssignArkValue(Ark_AnimationMode& dst, const TabAnimateMode& src); @@ -179,6 +180,7 @@ namespace OHOS::Ace::NG::Converter { void AssignArkValue(Ark_BarState& dst, const DisplayMode& src); void AssignArkValue(Ark_BaseGestureEvent& dst, const std::shared_ptr& src); void AssignArkValue(Ark_BlurStyle& dst, const BlurStyle& src); + void AssignArkValue(Ark_BlurStyleActivePolicy& dst, const BlurStyleActivePolicy& src); void AssignArkValue(Ark_BorderRadiuses& dst, const BorderRadiusProperty& src); void AssignArkValue(Ark_Buffer& dst, const std::string& src); void AssignArkValue(Ark_CaretOffset& dst, const NG::OffsetF& src); diff --git a/frameworks/core/interfaces/native/utility/reverse_converter_enums.cpp b/frameworks/core/interfaces/native/utility/reverse_converter_enums.cpp index be324a6d839f352979b57be2cfbcb2082f8fbec5..1f816e13c0e2878ac19bafbf27603d3778168a5f 100644 --- a/frameworks/core/interfaces/native/utility/reverse_converter_enums.cpp +++ b/frameworks/core/interfaces/native/utility/reverse_converter_enums.cpp @@ -37,6 +37,18 @@ void AssignArkValue(Ark_AccessibilityHoverType& dst, const AccessibilityHoverAct } } +void AssignArkValue(Ark_AdaptiveColor& dst, const AdaptiveColor& src) +{ + switch (src) { + case AdaptiveColor::DEFAULT: dst = ARK_ADAPTIVE_COLOR_DEFAULT; break; + case AdaptiveColor::AVERAGE: dst = ARK_ADAPTIVE_COLOR_AVERAGE; break; + default: + dst = INVALID_ENUM_VAL; + LOGE("Unexpected enum value in Ark_AdaptiveColor: %{public}d", src); + break; + } +} + void AssignArkValue(Ark_DismissReason& dst, const BindSheetDismissReason& src) { switch (src) { @@ -144,6 +156,20 @@ void AssignArkValue(Ark_BlurStyle& dst, const BlurStyle& src) } } +void AssignArkValue(Ark_BlurStyleActivePolicy& dst, const BlurStyleActivePolicy& src) +{ + switch (src) { + case BlurStyleActivePolicy::FOLLOWS_WINDOW_ACTIVE_STATE: + dst = ARK_BLUR_STYLE_ACTIVE_POLICY_FOLLOWS_WINDOW_ACTIVE_STATE; break; + case BlurStyleActivePolicy::ALWAYS_ACTIVE: dst = ARK_BLUR_STYLE_ACTIVE_POLICY_ALWAYS_ACTIVE; break; + case BlurStyleActivePolicy::ALWAYS_INACTIVE: dst = ARK_BLUR_STYLE_ACTIVE_POLICY_ALWAYS_INACTIVE; break; + default: + dst = INVALID_ENUM_VAL; + LOGE("Unexpected enum value in Ark_BlurStyleActivePolicy: %{public}d", src); + break; + } +} + void AssignArkValue(Ark_CrownAction& dst, const CrownAction& src) { switch (src) { diff --git a/test/mock/core/render/mock_render_context.h b/test/mock/core/render/mock_render_context.h index ecc73daee8afbc789d538ddcbaa9bd4fc314c3f9..7cfafc9c18810b649856d0adb1bacf68eac86ba3 100644 --- a/test/mock/core/render/mock_render_context.h +++ b/test/mock/core/render/mock_render_context.h @@ -132,8 +132,29 @@ public: { const auto& groupProperty = GetOrCreateBackground(); groupProperty->propEffectOption = effectOption; + groupProperty->propSysOptions = sysOptions; } + void OnUseEffectUpdate(bool useEffect) override + { + propUseEffect_ = useEffect; + } + + void OnUseEffectTypeUpdate(EffectType effectType) override + { + propUseEffectType_ = effectType; + } + + void SetOuterBorderWidth(const BorderWidthProperty& value) override + { + GetOrCreateOuterBorder()->propOuterBorderWidth = value; + }; + + void SetOuterBorderColor(const BorderColorProperty& value) override + { + GetOrCreateOuterBorder()->propOuterBorderColor = value; + } + void UpdateMotionBlur(const MotionBlurOption& motionBlurOption) override { const auto& groupProperty = GetOrCreateForeground(); @@ -147,6 +168,15 @@ public: foregroundBlurOption = blurOption; } + void UpdateFrontBlurStyle( + const std::optional& fgBlurStyle, const SysOptions& sysOptions = SysOptions()) override + { + const auto& groupProperty = GetOrCreateForeground(); + CHECK_NULL_VOID(groupProperty); + groupProperty->propBlurStyleOption = fgBlurStyle; + groupProperty->propSysOptionsForBlur = sysOptions; + } + void UpdateTransition(const TransitionOptions& options) override { const auto& groupPropertyA = GetOrCreateTransitionAppearing(); diff --git a/test/unittest/capi/modifiers/BUILD.gn b/test/unittest/capi/modifiers/BUILD.gn index 997af9259dce87aaa48c0cd815c7d02973fb8ed3..90d45567a812345d9f4579576053f3bb5afcc1cc 100644 --- a/test/unittest/capi/modifiers/BUILD.gn +++ b/test/unittest/capi/modifiers/BUILD.gn @@ -123,6 +123,7 @@ ace_unittest("capi_all_modifiers_test") { #"security_component_method_modifier_test_2.cpp", #"select_modifier_test.cpp", #"select_modifier_test_1.cpp", + "select_modifier_test_2.cpp", #"shape_modifier_test.cpp", #"side_bar_container_modifier_test.cpp", #"slider_modifier_test.cpp", diff --git a/test/unittest/capi/modifiers/common_method_modifier_test2.cpp b/test/unittest/capi/modifiers/common_method_modifier_test2.cpp index 8c3af0278b769dfaab7b942962586a26f0371950..713a52455e85b80431234af1204d1a98c81f5b59 100644 --- a/test/unittest/capi/modifiers/common_method_modifier_test2.cpp +++ b/test/unittest/capi/modifiers/common_method_modifier_test2.cpp @@ -54,6 +54,15 @@ const auto ATTRIBUTE_ASPECT_RATIO_NAME = "aspectRatio"; const auto ATTRIBUTE_SHADOW_NAME = "shadow"; const auto ATTRIBUTE_BACKGROUND_BLUR_STYLE_NAME = "backgroundBlurStyle"; const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_NAME = "foregroundBlurStyle"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_STYLE_NAME = "style"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_OPTIONS_NAME = "options"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_COLOR_MODE_NAME = "colorMode"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_ADAPTIVE_COLOR_MODE_NAME = "adaptiveColor"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_BLUR_OPTIONS_NAME = "blurOptions"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_GRAYSCALE_NAME = "grayscale"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_SCALE_NAME = "scale"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYS_OPTIONS_NAME = "sysOptions"; +const auto ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYSTEM_ADAPTAION_NAME = "disableSystemAdaptation"; const auto ATTRIBUTE_BLUR_NAME = "blur"; const auto ATTRIBUTE_OVERLAY_NAME = "overlay"; const auto ATTRIBUTE_BORDER_NAME = "border"; @@ -523,11 +532,11 @@ HWTEST_F(CommonMethodModifierTest2, setPixelRoundTest, TestSize.Level1) } /* - * @tc.name: setBackgroundEffectTestValidValues + * @tc.name: setBackgroundEffect0TestValidValues * @tc.desc: * @tc.type: FUNC */ -HWTEST_F(CommonMethodModifierTest2, setBackgroundEffectTestValidValues, TestSize.Level1) +HWTEST_F(CommonMethodModifierTest2, setBackgroundEffect0TestValidValues, TestSize.Level1) { ASSERT_NE(modifier_->setBackgroundEffect0, nullptr); @@ -537,40 +546,85 @@ HWTEST_F(CommonMethodModifierTest2, setBackgroundEffectTestValidValues, TestSize .brightness = 100, .color = Color(0xFF123123), .adaptiveColor = AdaptiveColor::AVERAGE, - .blurOption = {.grayscale = {20, 30}}, + .blurOption = { .grayscale = { 20, 30 } }, .policy = BlurStyleActivePolicy::ALWAYS_ACTIVE, .inactiveColor = Color(0xFF00FFFF), - .blurType = BlurType::WITHIN_WINDOW - }; + .blurType = BlurType::WITHIN_WINDOW }; auto renderMock = GetMockRenderContext(); ASSERT_NE(renderMock, nullptr); Ark_BackgroundEffectOptions arkInputValValid = { - .radius = ArkValue(123.45f), - .saturation = ArkValue(0.123f), - .brightness = ArkValue(100), - .color = ArkUnion(0x123123), - .adaptiveColor = ArkValue(ARK_ADAPTIVE_COLOR_AVERAGE), - .blurOptions = ArkValue(Ark_BlurOptions{ - .grayscale = {ArkValue(20), ArkValue(30)} + .radius = ArkValue(expectedBgEffect.radius), + .saturation = ArkValue(expectedBgEffect.saturation), + .brightness = ArkValue(expectedBgEffect.brightness), + .color = ArkUnion(expectedBgEffect.color.GetValue()), + .adaptiveColor = ArkValue(expectedBgEffect.adaptiveColor), + .blurOptions = ArkValue(Ark_BlurOptions { + .grayscale = { + .value0 = ArkValue(expectedBgEffect.blurOption.grayscale[0]), + .value1 = ArkValue(expectedBgEffect.blurOption.grayscale[1]), + } }), - .policy = ArkValue(ARK_BLUR_STYLE_ACTIVE_POLICY_ALWAYS_ACTIVE), - .inactiveColor = ArkUnion("65535"), + .policy = ArkValue(expectedBgEffect.policy), + .inactiveColor = ArkUnion(expectedBgEffect.inactiveColor.ToString(), + Converter::FC), }; auto inputValValid = Converter::ArkValue(arkInputValValid); modifier_->setBackgroundEffect0(node_, &inputValValid); EXPECT_EQ(renderMock->GetOrCreateBackground()->propEffectOption, expectedBgEffect); + ASSERT_TRUE(renderMock->GetOrCreateBackground()->propSysOptions); + EXPECT_TRUE(renderMock->GetOrCreateBackground()->propSysOptions->disableSystemAdaptation); } /* - * @tc.name: DISABLED_setBackgroundEffectTestInvalidValues + * @tc.name: setBackgroundEffect0TestValidValues * @tc.desc: * @tc.type: FUNC */ -HWTEST_F(CommonMethodModifierTest2, DISABLED_setBackgroundEffectTestInvalidValues, TestSize.Level1) +HWTEST_F(CommonMethodModifierTest2, setBackgroundEffect1TestValidValues, TestSize.Level1) { - EXPECT_TRUE(true); // not implemented + ASSERT_NE(modifier_->setBackgroundEffect0, nullptr); + + EffectOption expectedBgEffect { + .radius = 123.45_vp, + .saturation = 0.123f, + .brightness = 100, + .color = Color(0xFF123123), + .adaptiveColor = AdaptiveColor::AVERAGE, + .blurOption = { .grayscale = { 20, 30 } }, + .policy = BlurStyleActivePolicy::ALWAYS_ACTIVE, + .inactiveColor = Color(0xFF00FFFF), + .blurType = BlurType::WITHIN_WINDOW }; + + auto renderMock = GetMockRenderContext(); + ASSERT_NE(renderMock, nullptr); + + Ark_BackgroundEffectOptions arkInputValValid = { + .radius = ArkValue(expectedBgEffect.radius), + .saturation = ArkValue(expectedBgEffect.saturation), + .brightness = ArkValue(expectedBgEffect.brightness), + .color = ArkUnion(expectedBgEffect.color.GetValue()), + .adaptiveColor = ArkValue(expectedBgEffect.adaptiveColor), + .blurOptions = ArkValue(Ark_BlurOptions { + .grayscale = { + .value0 = ArkValue(expectedBgEffect.blurOption.grayscale[0]), + .value1 = ArkValue(expectedBgEffect.blurOption.grayscale[1]), + } + }), + .policy = ArkValue(expectedBgEffect.policy), + .inactiveColor = ArkUnion(expectedBgEffect.inactiveColor.ToString(), + Converter::FC), + }; + auto inputValValid = Converter::ArkValue(arkInputValValid); + Ark_SystemAdaptiveOptions sysOptions = { + .disableSystemAdaptation = ArkValue(false), + }; + auto sysOptionsOpt = ArkValue(sysOptions); + modifier_->setBackgroundEffect1(node_, &inputValValid, &sysOptionsOpt); + EXPECT_EQ(renderMock->GetOrCreateBackground()->propEffectOption, expectedBgEffect); + ASSERT_TRUE(renderMock->GetOrCreateBackground()->propSysOptions); + EXPECT_FALSE(renderMock->GetOrCreateBackground()->propSysOptions->disableSystemAdaptation); } /* @@ -1268,26 +1322,113 @@ HWTEST_F(CommonMethodModifierTest2, setBackgroundBlurStyle, TestSize.Level1) } /* - * @tc.name: setForegroundBlurStyle + * @tc.name: setForegroundBlurStyle0Test * @tc.desc: * @tc.type: FUNC */ -HWTEST_F(CommonMethodModifierTest2, setForegroundBlurStyle, TestSize.Level1) +HWTEST_F(CommonMethodModifierTest2, setForegroundBlurStyle0Test, TestSize.Level1) { - auto style = Converter::ArkValue(ARK_BLUR_STYLE_COMPONENT_ULTRA_THIN); - auto options = Ark_ForegroundBlurStyleOptions { - .scale = Converter::ArkValue(2.3f), - .colorMode = Converter::ArkValue(ARK_THEME_COLOR_MODE_DARK), - .blurOptions = Converter::ArkValue(Ark_BlurOptions { - .grayscale = Ark_Tuple_Number_Number {Converter::ArkValue(7), - Converter::ArkValue(7)}, - }), - .adaptiveColor = Converter::ArkValue(ARK_ADAPTIVE_COLOR_AVERAGE), + auto style = ArkValue(ARK_BLUR_STYLE_COMPONENT_ULTRA_THIN); + int32_t grayscaleArray[2] = { 7, 8 }; + auto scale = 2.3f; + Ark_BlurOptions blurOption = { + .grayscale = { + .value0 = ArkValue(grayscaleArray[0]), + .value1 = ArkValue(grayscaleArray[1]), + } }; - auto optOptions = Converter::ArkValue(options); + Ark_ForegroundBlurStyleOptions options = { + .scale = ArkValue(scale), + .colorMode = ArkValue(ARK_THEME_COLOR_MODE_DARK), + .blurOptions = ArkValue(blurOption), + .adaptiveColor = ArkValue(ARK_ADAPTIVE_COLOR_AVERAGE) + }; + auto optOptions = ArkValue(options); modifier_->setForegroundBlurStyle0(node_, &style, &optOptions); - auto strResult = GetStringAttribute(node_, ATTRIBUTE_FOREGROUND_BLUR_STYLE_NAME); - EXPECT_EQ(strResult, ""); + auto json = GetJsonValue(node_); + ASSERT_TRUE(json); + auto forergorundBlurStyleJSON = + GetAttrValue>(json, ATTRIBUTE_FOREGROUND_BLUR_STYLE_NAME); + ASSERT_TRUE(forergorundBlurStyleJSON); + EXPECT_EQ(GetAttrValue(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_STYLE_NAME), "BlurStyle.COMPONENT_ULTRA_THIN"); + auto optionsJSON = GetAttrValue>(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_OPTIONS_NAME); + ASSERT_TRUE(optionsJSON); + EXPECT_EQ(GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_COLOR_MODE_NAME), + "ThemeColorMode.DARK"); + EXPECT_EQ(GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_ADAPTIVE_COLOR_MODE_NAME), + "AdaptiveColor.AVERAGE"); + auto blurOptionsJSON = GetAttrValue>(optionsJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_BLUR_OPTIONS_NAME); + ASSERT_TRUE(blurOptionsJSON); + auto grayscaleString = GetAttrValue(blurOptionsJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_GRAYSCALE_NAME); + auto grayscaleCehck = "[" + std::to_string(grayscaleArray[0]) + "," + std::to_string(grayscaleArray[1]) + "]"; + EXPECT_EQ(grayscaleString, grayscaleCehck); + auto scaleJSON = GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_SCALE_NAME); + EXPECT_NEAR(scale, scaleJSON, DBL_EPSILON); + auto sysOptionsJSON = GetAttrValue>(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYS_OPTIONS_NAME); + ASSERT_TRUE(sysOptionsJSON); + EXPECT_TRUE(GetAttrValue(sysOptionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYSTEM_ADAPTAION_NAME)); +} + +/* + * @tc.name: setForegroundBlurStyle1Test + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(CommonMethodModifierTest2, setForegroundBlurStyle1Test, TestSize.Level1) +{ + auto style = ArkValue(ARK_BLUR_STYLE_THIN); + int32_t grayscaleArray[2] = { 5, 6 }; + auto scale = 4.6f; + Ark_BlurOptions blurOption = { + .grayscale = { + .value0 = ArkValue(grayscaleArray[0]), + .value1 = ArkValue(grayscaleArray[1]), + } + }; + Ark_ForegroundBlurStyleOptions options = { + .scale = ArkValue(scale), + .colorMode = ArkValue(ARK_THEME_COLOR_MODE_LIGHT), + .blurOptions = ArkValue(blurOption), + .adaptiveColor = ArkValue(ARK_ADAPTIVE_COLOR_DEFAULT) + }; + auto optOptions = ArkValue(options); + Ark_SystemAdaptiveOptions sysOptions = { + .disableSystemAdaptation = ArkValue(false), + }; + auto sysOptionsOpt = ArkValue(sysOptions); + modifier_->setForegroundBlurStyle1(node_, &style, &optOptions, &sysOptionsOpt); + auto json = GetJsonValue(node_); + ASSERT_TRUE(json); + auto forergorundBlurStyleJSON = + GetAttrValue>(json, ATTRIBUTE_FOREGROUND_BLUR_STYLE_NAME); + ASSERT_TRUE(forergorundBlurStyleJSON); + EXPECT_EQ(GetAttrValue(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_STYLE_NAME), "BlurStyle.THIN"); + auto optionsJSON = GetAttrValue>(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_OPTIONS_NAME); + ASSERT_TRUE(optionsJSON); + EXPECT_EQ(GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_COLOR_MODE_NAME), + "ThemeColorMode.LIGHT"); + EXPECT_EQ(GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_ADAPTIVE_COLOR_MODE_NAME), + "AdaptiveColor.DEFAULT"); + auto blurOptionsJSON = GetAttrValue>(optionsJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_BLUR_OPTIONS_NAME); + ASSERT_TRUE(blurOptionsJSON); + auto grayscaleString = GetAttrValue(blurOptionsJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_GRAYSCALE_NAME); + auto grayscaleCehck = "[" + std::to_string(grayscaleArray[0]) + "," + std::to_string(grayscaleArray[1]) + "]"; + EXPECT_EQ(grayscaleString, grayscaleCehck); + auto scaleJSON = GetAttrValue(optionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_SCALE_NAME); + EXPECT_NEAR(scale, scaleJSON, DBL_EPSILON); + auto sysOptionsJSON = GetAttrValue>(forergorundBlurStyleJSON, + ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYS_OPTIONS_NAME); + ASSERT_TRUE(sysOptionsJSON); + EXPECT_FALSE(GetAttrValue(sysOptionsJSON, ATTRIBUTE_FOREGROUND_BLUR_STYLE_SYSTEM_ADAPTAION_NAME)); } /* diff --git a/test/unittest/capi/modifiers/common_method_modifier_test4.cpp b/test/unittest/capi/modifiers/common_method_modifier_test4.cpp index 1b63d4f168b17a5d041779cf61e9ed21ee703f37..a5f303d7dedbb2813254d1da54398cb8d00b721c 100644 --- a/test/unittest/capi/modifiers/common_method_modifier_test4.cpp +++ b/test/unittest/capi/modifiers/common_method_modifier_test4.cpp @@ -23,6 +23,7 @@ using namespace testing; using namespace testing::ext; +using namespace OHOS::Ace::NG::Converter; void AssignArkValue(Ark_InvertOptions& dst, const float& value) { @@ -57,7 +58,9 @@ namespace { const auto ATTRIBUTE_HUE_ROTATE_NAME = "hueRotate"; const auto ATTRIBUTE_HUE_ROTATE_DEFAULT_VALUE = 0; const auto ATTRIBUTE_USE_EFFECT_NAME = "useEffect"; - const auto ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE = false; + const auto ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE = "false"; + const auto ATTRIBUTE_USE_EFFECT_TYPE_NAME = "useEffectType"; + const auto ATTRIBUTE_USE_EFFECT_TYPE_DEFAULT_VALUE = "EffectType.DEFAULT"; const auto ATTRIBUTE_RENDER_GROUP_NAME = "renderGroup"; const auto ATTRIBUTE_RENDER_GROUP_DEFAULT_VALUE = true; const auto ATTRIBUTE_FREEZE_NAME = "freeze"; @@ -74,66 +77,80 @@ namespace { const auto ATTRIBUTE_PIXEL_STRETCH_EFFECT_DEFAULT_VALUE = "{\"left\":\"0.00px\",\"right\":\"0.00px\",\"top\":\"0.00px\",\"bottom\":\"0.00px\"}"; const auto ATTRIBUTE_ALIGN_RULES_NAME = "alignRules"; -const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_NAME = "left"; -const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_NAME = "right"; -const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_NAME = "middle"; -const auto ATTRIBUTE_ALIGN_RULES_I_TOP_NAME = "top"; -const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_NAME = "bottom"; -const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_NAME = "center"; -const auto ATTRIBUTE_ALIGN_RULES_I_START_NAME = "start"; -const auto ATTRIBUTE_ALIGN_RULES_I_END_NAME = "end"; -const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_NAME = "bias"; -const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_HORIZONTAL_NAME = "horizontal"; -const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_HORIZONTAL_DEFAULT_VALUE = "0.5"; -const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_VERTICAL_NAME = "vertical"; -const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_VERTICAL_DEFAULT_VALUE = "0.5"; -const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ANCHOR_NAME = "anchor"; -const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ANCHOR_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ALIGN_NAME = "align"; -const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ALIGN_DEFAULT_VALUE = ""; -const auto ATTRIBUTE_OBSCURED_NAME = "obscured"; -const auto ATTRIBUTE_EXPAND_SAFE_AREA_NAME = "expandSafeArea"; -const auto ATTRIBUTE_EXPAND_SAFE_AREA_I_TYPES_NAME = "types"; -const auto ATTRIBUTE_EXPAND_SAFE_AREA_I_EDGES_NAME = "edges"; -const auto ATTRIBUTE_SAFE_AREA_PADDING_NAME = "safeAreaPadding"; -const auto ATTRIBUTE_SAFE_AREA_PADDING_DEFAULT_VALUE = "0.00vp"; -const auto ATTRIBUTE_SAFE_AREA_LEFT_NAME = "left"; -const auto ATTRIBUTE_SAFE_AREA_TOP_NAME = "top"; -const auto ATTRIBUTE_SAFE_AREA_RIGHT_NAME = "right"; -const auto ATTRIBUTE_SAFE_AREA_BOTTOM_NAME = "bottom"; -const auto ATTRIBUTE_ROTATE_NAME = "rotate"; -const auto ATTRIBUTE_ROTATE_I_CENTER_Z_NAME = "centerZ"; -const auto ATTRIBUTE_ROTATE_I_ANGLE_NAME = "angle"; -const auto ATTRIBUTE_ROTATE_I_CENTER_Z_DEFAULT_VALUE = "0.00px"; -const auto ATTRIBUTE_ARRAY_DEFAULT_SIZE = 0; + const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_NAME = "left"; + const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_NAME = "right"; + const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_NAME = "middle"; + const auto ATTRIBUTE_ALIGN_RULES_I_TOP_NAME = "top"; + const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_NAME = "bottom"; + const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_NAME = "center"; + const auto ATTRIBUTE_ALIGN_RULES_I_START_NAME = "start"; + const auto ATTRIBUTE_ALIGN_RULES_I_END_NAME = "end"; + const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_NAME = "bias"; + const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_LEFT_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_RIGHT_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_MIDDLE_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_TOP_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_BOTTOM_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_CENTER_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_HORIZONTAL_NAME = "horizontal"; + const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_HORIZONTAL_DEFAULT_VALUE = "0.5"; + const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_VERTICAL_NAME = "vertical"; + const auto ATTRIBUTE_ALIGN_RULES_I_BIAS_I_VERTICAL_DEFAULT_VALUE = "0.5"; + const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_START_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ANCHOR_NAME = "anchor"; + const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ANCHOR_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ALIGN_NAME = "align"; + const auto ATTRIBUTE_ALIGN_RULES_I_END_I_ALIGN_DEFAULT_VALUE = ""; + const auto ATTRIBUTE_OBSCURED_NAME = "obscured"; + const auto ATTRIBUTE_EXPAND_SAFE_AREA_NAME = "expandSafeArea"; + const auto ATTRIBUTE_EXPAND_SAFE_AREA_I_TYPES_NAME = "types"; + const auto ATTRIBUTE_EXPAND_SAFE_AREA_I_EDGES_NAME = "edges"; + const auto ATTRIBUTE_SAFE_AREA_PADDING_NAME = "safeAreaPadding"; + const auto ATTRIBUTE_SAFE_AREA_PADDING_DEFAULT_VALUE = "0.00vp"; + const auto ATTRIBUTE_SAFE_AREA_LEFT_NAME = "left"; + const auto ATTRIBUTE_SAFE_AREA_TOP_NAME = "top"; + const auto ATTRIBUTE_SAFE_AREA_RIGHT_NAME = "right"; + const auto ATTRIBUTE_SAFE_AREA_BOTTOM_NAME = "bottom"; + const auto ATTRIBUTE_ROTATE_NAME = "rotate"; + const auto ATTRIBUTE_ROTATE_I_CENTER_Z_NAME = "centerZ"; + const auto ATTRIBUTE_ROTATE_I_ANGLE_NAME = "angle"; + const auto ATTRIBUTE_ROTATE_I_CENTER_Z_DEFAULT_VALUE = "0.00px"; + const auto ATTRIBUTE_ARRAY_DEFAULT_SIZE = 0; + + static const std::vector> testFixtureEnumUseEffect = { + { ArkValue(true), "true"}, + { ArkValue(false), "false"}, + { ArkValue(), ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE }, + }; + static const std::vector> testFixtureEnumUseEffectType = { + { "ARK_EFFECT_TYPE_DEFAULT", ArkValue(ARK_EFFECT_TYPE_DEFAULT), "EffectType.DEFAULT" }, + { "EMPTY_VALUE", ArkValue(), ATTRIBUTE_USE_EFFECT_TYPE_DEFAULT_VALUE }, + { "ARK_EFFECT_TYPE_WINDOW_EFFECT", ArkValue(ARK_EFFECT_TYPE_WINDOW_EFFECT), + "EffectType.WINDOW_EFFECT" }, + { "INVALID_VALUE", ArkValue(INVALID_ENUM_VAL), + ATTRIBUTE_USE_EFFECT_TYPE_DEFAULT_VALUE }, + }; } struct PixelStretchEffect { float left = 0.0; @@ -351,35 +368,76 @@ HWTEST_F(CommonMethodModifierTest4, setHueRotateInvalidValues, TestSize.Level1) } ////////////// UseEffect /* - * @tc.name: setUseEffectDefaultValues + * @tc.name: setUseEffectTestDefaultValues * @tc.desc: * @tc.type: FUNC */ -HWTEST_F(CommonMethodModifierTest4, setUseEffectDefaultValues, TestSize.Level1) +HWTEST_F(CommonMethodModifierTest4, setUseEffectTestDefaultValues, TestSize.Level1) { - std::unique_ptr jsonValue = GetJsonValue(node_); - auto resultValue = jsonValue->GetBool(ATTRIBUTE_USE_EFFECT_NAME, ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE); + auto fullJson = GetJsonValue(node_); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_NAME); EXPECT_EQ(resultValue, ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE); + resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_TYPE_NAME); + EXPECT_EQ(resultValue, ATTRIBUTE_USE_EFFECT_TYPE_DEFAULT_VALUE); } /* - * @tc.name: setUseEffectValidValues + * @tc.name: setUseEffect0TestValidValues * @tc.desc: * @tc.type: FUNC */ -HWTEST_F(CommonMethodModifierTest4, DISABLED_setUseEffectValidValues, TestSize.Level1) +HWTEST_F(CommonMethodModifierTest4, setUseEffect0Test, TestSize.Level1) { ASSERT_NE(modifier_->setUseEffect0, nullptr); - using OneTestStep = std::tuple; - static const std::vector testPlan = { - {Converter::ArkValue(true), true}, - {Converter::ArkValue(false), false}, - }; - for (auto [inputValue, expectedValue]: testPlan) { + for (auto &[inputValue, expectedValue]: testFixtureEnumUseEffect) { modifier_->setUseEffect0(node_, &inputValue); auto fullJson = GetJsonValue(node_); - auto resultValue = fullJson->GetBool(ATTRIBUTE_USE_EFFECT_NAME, ATTRIBUTE_USE_EFFECT_DEFAULT_VALUE); - EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << (expectedValue ? "true" : "false"); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_NAME); + EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << expectedValue; + } +} + +/* + * @tc.name: setUseEffect1TestValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(CommonMethodModifierTest4, setUseEffect1Test, TestSize.Level1) +{ + ASSERT_NE(modifier_->setUseEffect0, nullptr); + for (auto &[inputValue, expectedValue] : testFixtureEnumUseEffect) { + modifier_->setUseEffect2(node_, &inputValue, nullptr); + auto fullJson = GetJsonValue(node_); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_NAME); + EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << expectedValue; + } + for (auto &[message, inputValue, expectedValue] : testFixtureEnumUseEffectType) { + modifier_->setUseEffect1(node_, nullptr, &inputValue); + auto fullJson = GetJsonValue(node_); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_TYPE_NAME); + EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << expectedValue; + } +} + +/* + * @tc.name: setUseEffect1TestValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(CommonMethodModifierTest4, setUseEffect2Test, TestSize.Level1) +{ + ASSERT_NE(modifier_->setUseEffect0, nullptr); + for (auto &[inputValue, expectedValue] : testFixtureEnumUseEffect) { + modifier_->setUseEffect2(node_, &inputValue, nullptr); + auto fullJson = GetJsonValue(node_); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_NAME); + EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << expectedValue; + } + for (auto &[message, inputValue, expectedValue] : testFixtureEnumUseEffectType) { + modifier_->setUseEffect2(node_, nullptr, &inputValue); + auto fullJson = GetJsonValue(node_); + auto resultValue = GetAttrValue(fullJson, ATTRIBUTE_USE_EFFECT_TYPE_NAME); + EXPECT_EQ(resultValue, expectedValue) << "Passed value is: " << expectedValue; } } ////////////// RenderGroup diff --git a/test/unittest/capi/modifiers/select_modifier_test.h b/test/unittest/capi/modifiers/select_modifier_test.h index b18746866ac2aafcb89485fa8978ef040e25a348..3bec0c858fe4f03e1c95c060ec3fe28af39452de 100755 --- a/test/unittest/capi/modifiers/select_modifier_test.h +++ b/test/unittest/capi/modifiers/select_modifier_test.h @@ -30,6 +30,8 @@ #include "core/interfaces/native/utility/converter.h" #include "core/interfaces/native/utility/reverse_converter.h" +#include "test/mock/core/render/mock_render_context.h" + namespace OHOS::Ace::NG { using namespace testing; using namespace testing::ext; @@ -154,29 +156,29 @@ const auto ATTRIBUTE_SELECTED_OPTION_FONT_COLOR_DEFAULT_VALUE = "#FFAABBC4"; const auto ATTRIBUTE_OPTION_BG_COLOR_NAME = "optionBgColor"; const auto ATTRIBUTE_OPTION_BG_COLOR_DEFAULT_VALUE = "#00000000"; const auto ATTRIBUTE_OPTION_FONT_I_SIZE_NAME = "size"; -const auto ATTRIBUTE_OPTION_FONT_I_SIZE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_FONT_I_SIZE_DEFAULT_VALUE = "0.00px"; const auto ATTRIBUTE_OPTION_FONT_I_WEIGHT_NAME = "weight"; -const auto ATTRIBUTE_OPTION_FONT_I_WEIGHT_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_FONT_I_WEIGHT_DEFAULT_VALUE = "FontWeight.Regular"; const auto ATTRIBUTE_OPTION_FONT_I_FAMILY_NAME = "family"; -const auto ATTRIBUTE_OPTION_FONT_I_FAMILY_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_FONT_I_FAMILY_DEFAULT_VALUE = ""; const auto ATTRIBUTE_OPTION_FONT_I_STYLE_NAME = "style"; -const auto ATTRIBUTE_OPTION_FONT_I_STYLE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_FONT_I_STYLE_DEFAULT_VALUE = "FontStyle.Normal"; const auto ATTRIBUTE_OPTION_FONT_COLOR_NAME = "optionFontColor"; -const auto ATTRIBUTE_OPTION_FONT_COLOR_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_FONT_COLOR_DEFAULT_VALUE = "#FFAABBC3"; const auto ATTRIBUTE_SPACE_NAME = "space"; -const auto ATTRIBUTE_SPACE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_SPACE_DEFAULT_VALUE = "23.00px"; const auto ATTRIBUTE_ARROW_POSITION_NAME = "arrowPosition"; -const auto ATTRIBUTE_ARROW_POSITION_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_ARROW_POSITION_DEFAULT_VALUE = "ArrowPosition.END"; const auto ATTRIBUTE_OPTION_WIDTH_NAME = "optionWidth"; -const auto ATTRIBUTE_OPTION_WIDTH_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_WIDTH_DEFAULT_VALUE = "0.000000"; const auto ATTRIBUTE_OPTION_HEIGHT_NAME = "optionHeight"; -const auto ATTRIBUTE_OPTION_HEIGHT_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_OPTION_HEIGHT_DEFAULT_VALUE = "0.000000"; const auto ATTRIBUTE_MENU_BACKGROUND_COLOR_NAME = "menuBackgroundColor"; -const auto ATTRIBUTE_MENU_BACKGROUND_COLOR_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_MENU_BACKGROUND_COLOR_DEFAULT_VALUE = "#00000000"; const auto ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_NAME = "menuBackgroundBlurStyle"; -const auto ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_DEFAULT_VALUE = "BlurStyle.COMPONENT_ULTRA_THICK"; const auto ATTRIBUTE_CONTROL_SIZE_NAME = "controlSize"; -const auto ATTRIBUTE_CONTROL_SIZE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_CONTROL_SIZE_DEFAULT_VALUE = "ControlSize.NORMAL"; const auto ATTRIBUTE_DIVIDER_I_STROKE_WIDTH_NAME = "strokeWidth"; const auto ATTRIBUTE_DIVIDER_I_STROKE_WIDTH_DEFAULT_VALUE = "!NOT-DEFINED!"; const auto ATTRIBUTE_DIVIDER_I_COLOR_NAME = "color"; @@ -186,11 +188,13 @@ const auto ATTRIBUTE_DIVIDER_I_START_MARGIN_DEFAULT_VALUE = "!NOT-DEFINED!"; const auto ATTRIBUTE_DIVIDER_I_END_MARGIN_NAME = "endMargin"; const auto ATTRIBUTE_DIVIDER_I_END_MARGIN_DEFAULT_VALUE = "!NOT-DEFINED!"; const auto ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_NAME = "alignType"; -const auto ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_DEFAULT_VALUE = "MenuAlignType.Start"; const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_NAME = "dx"; -const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_DEFAULT_VALUE = "0"; const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_NAME = "dy"; -const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_DEFAULT_VALUE = "!NOT-DEFINED!"; +const auto ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_DEFAULT_VALUE = "0"; +const auto ATTRIBUTE_AVOIDANCE_NAME = "avoidance"; +const auto ATTRIBUTE_AVOIDANCE_DEFAULT_VALUE = "AvoidanceMode.COVER_TARGET"; extern std::vector> testColorsResValidValues; extern std::vector> testStringResValidValues; @@ -233,10 +237,12 @@ public: SetupTheme(); SetupTheme(); SetupTheme(); + #ifdef WRONG_GEN for (auto& [id, strid, res] : resourceInitTable) { AddResource(id, res); AddResource(strid, res); } + #endif } void SetUp(void) override @@ -261,8 +267,27 @@ public: ASSERT_TRUE(pattern); pattern->OnModifyDone(); // Init selectTheme } -}; + RefPtr GetMockRenderContext() const + { + if (auto fnode = reinterpret_cast(node_); fnode) { + return AceType::DynamicCast(fnode->GetRenderContext()); + } + return nullptr; + } + + RefPtr GetMenuMockRenderContext() const + { + if (auto fnode = reinterpret_cast(node_); fnode) { + auto pattern = fnode->GetPattern(); + CHECK_NULL_RETURN(pattern, nullptr); + auto node = pattern->GetMenuNode(); + CHECK_NULL_RETURN(node, nullptr); + return AceType::DynamicCast(node->GetRenderContext()); + } + return nullptr; + } +}; } // namespace OHOS::Ace::NG #endif // GENERATED_FOUNDATION_ACE_CAPI_TEST_SELECT_H diff --git a/test/unittest/capi/modifiers/select_modifier_test_2.cpp b/test/unittest/capi/modifiers/select_modifier_test_2.cpp new file mode 100755 index 0000000000000000000000000000000000000000..07c495e313c9b1a7845a292b3a473b38fdb8d092 --- /dev/null +++ b/test/unittest/capi/modifiers/select_modifier_test_2.cpp @@ -0,0 +1,1861 @@ +/* + * Copyright (c) 2024-2025 Huawei Device 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 "select_modifier_test.h" + +namespace OHOS::Ace::NG { +using namespace SelectTest; + +std::vector> testInvalidValues = { + { "-1", static_cast(-1) }, + { "INT_MAX", static_cast(INT_MAX) }, +}; +std::vector> testArrowPositionValidValues = { + { "ARK_ARROW_POSITION_END", ARK_ARROW_POSITION_END, "ArrowPosition.END" }, + { "ARK_ARROW_POSITION_START", ARK_ARROW_POSITION_START, "ArrowPosition.START" }, +}; + +std::vector> testMenuAlignTypeValidValues = { + { "ARK_MENU_ALIGN_TYPE_START", ARK_MENU_ALIGN_TYPE_START, "MenuAlignType.Start" }, + { "ARK_MENU_ALIGN_TYPE_CENTER", ARK_MENU_ALIGN_TYPE_CENTER, "MenuAlignType.Center" }, + { "ARK_MENU_ALIGN_TYPE_END", ARK_MENU_ALIGN_TYPE_END, "MenuAlignType.End" }, +}; + +std::vector> testAvoidanceModeFixture = { + { "ARK_AVOIDANCE_MODE_COVER_TARGET", ARK_AVOIDANCE_MODE_COVER_TARGET, "AvoidanceMode.COVER_TARGET" }, + { "ARK_AVOIDANCE_MODE_AVOID_AROUND_TARGET", ARK_AVOIDANCE_MODE_AVOID_AROUND_TARGET, + "AvoidanceMode.AVOID_AROUND_TARGET" }, + { "INVALID_ENUM_VAL", INVALID_ENUM_VAL, "AvoidanceMode.COVER_TARGET" }, +}; + +std::vector> testDeviderModeFixture = { + { "ARK_DIVIDER_MODE_EMBEDDED_IN_MENU", ARK_DIVIDER_MODE_EMBEDDED_IN_MENU, "DividerMode.EMBEDDED_IN_MENU" }, + { "ARK_DIVIDER_MODE_FLOATING_ABOVE_MENU", ARK_DIVIDER_MODE_FLOATING_ABOVE_MENU, + "DividerMode.FLOATING_ABOVE_MENU" }, + { "INVALID_ENUM_VAL", INVALID_ENUM_VAL, "DividerMode.EMBEDDED_IN_MENU" }, +}; + +typedef std::pair OneTestStep; +static const std::vector offsetTestPlan = { + { Converter::ArkValue(2.5f), 2.5 }, + { Converter::ArkValue(-2.5f), -2.5 }, + { Converter::ArkValue(5.0_px), 5 }, + { Converter::ArkValue(-5.0_px), -5 }, + { Converter::ArkValue(22.5_px), 22.5 }, + { Converter::ArkValue(-22.5_px), -22.5 }, + { Converter::ArkValue(7.0_vp), 7 }, + { Converter::ArkValue(-7.0_vp), -7 }, + { Converter::ArkValue(1.5_vp), 1.5 }, + { Converter::ArkValue(-1.5_vp), -1.5 }, + { Converter::ArkValue(65.0_fp), 65 }, + { Converter::ArkValue(-65.0_fp), -65 }, + { Converter::ArkValue(4.5_fp), 4.5 }, + { Converter::ArkValue(-4.5_fp), -4.5 }, + { Converter::ArkValue(0.12_pct), 0.12 }, + { Converter::ArkValue(-0.12_pct), -0.12 }, +}; + +static const std::vector>> lengthTestPlan = { + { "5.0_px", Converter::ArkValue(5.0_px), 5.0_px }, + { "-5.0_px", Converter::ArkValue(-5.0_px), std::nullopt }, + { "22.5_px", Converter::ArkValue(22.5_px), 22.5_px }, + { "-22.5_px", Converter::ArkValue(-22.5_px), std::nullopt }, + { "7.0_vp", Converter::ArkValue(7.0_vp), 7.0_vp }, + { "-7.0_vp", Converter::ArkValue(-7.0_vp), std::nullopt }, + { "1.5_vp", Converter::ArkValue(1.5_vp), 1.5_vp }, + { "-1.5_vp", Converter::ArkValue(-1.5_vp), std::nullopt }, + { "65.0_fp", Converter::ArkValue(65.0_fp), 65.0_fp }, + { "-65.0_fp", Converter::ArkValue(-65.0_fp), std::nullopt }, + { "4.5_fp", Converter::ArkValue(4.5_fp), 4.5_fp }, + { "-4.5_fp", Converter::ArkValue(-4.5_fp), std::nullopt }, + { "0.12_pct", Converter::ArkValue(0.12_pct), std::nullopt }, + { "-0.12_pct", Converter::ArkValue(-0.12_pct), std::nullopt }, +}; + +/* + * @tc.name: setOptionFont1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::unique_ptr resultOptionFont = + GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + std::string resultStr; + resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_SIZE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_SIZE_DEFAULT_VALUE) << "Default value for attribute 'optionFont.size'"; + + resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_WEIGHT_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_WEIGHT_DEFAULT_VALUE) << + "Default value for attribute 'optionFont.weight'"; + + resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_FAMILY_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_FAMILY_DEFAULT_VALUE) << + "Default value for attribute 'optionFont.family'"; + + resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_STYLE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_STYLE_DEFAULT_VALUE) << + "Default value for attribute 'optionFont.style'"; +} + +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontSizeValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontSizeValidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont]( + const std::string& input, const std::string& expectedStr, const Opt_Length& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + WriteTo(inputValueOptionFont).size = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_SIZE_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.size"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureLengthNonNegNonPctValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} +#endif + +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontSizeInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setOptionFont1TestOptionFontSizeInvalidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont](const std::string& input, const Opt_Length& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + modifier_->setOptionFont1(node_, &inputValueOptionFont); + WriteTo(inputValueOptionFont).size = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_SIZE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_SIZE_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.size"; + }; + + for (auto& [input, value] : Fixtures::testFixtureLengthNonNegNonPctInvalidValues) { + checkValue(input, ArkValue(value)); + } + // Check empty optional + checkValue("undefined", ArkValue()); +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontWeightValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontWeightValidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont](const std::string& input, const std::string& expectedStr, + const Opt_Union_FontWeight_Number_String& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + WriteTo(inputValueOptionFont).weight = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_WEIGHT_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.weight"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureEnumFontWeightValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testWeightNumberValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testWeightStringValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontWeightInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setOptionFont1TestOptionFontWeightInvalidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont]( + const std::string& input, const Opt_Union_FontWeight_Number_String& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + modifier_->setOptionFont1(node_, &inputValueOptionFont); + WriteTo(inputValueOptionFont).weight = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_WEIGHT_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_WEIGHT_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.weight"; + }; + + for (auto& [input, value] : Fixtures::testFixtureEnumFontWeightInvalidValues) { + checkValue(input, ArkUnion(value)); + } + // Check invalid union + checkValue("invalid union", ArkUnion(nullptr)); + // Check empty optional + checkValue("undefined", ArkValue()); +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontFamilyValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontFamilyValidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont](const std::string& input, const std::string& expectedStr, + const Opt_Union_String_Resource& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + WriteTo(inputValueOptionFont).family = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_FAMILY_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.family"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureStringValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + //todo Ark_Resource +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontFamilyInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontFamilyInvalidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont](const std::string& input, const Opt_Union_String_Resource& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + modifier_->setOptionFont1(node_, &inputValueOptionFont); + WriteTo(inputValueOptionFont).family = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_FAMILY_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_FAMILY_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.family"; + }; + + //todo Ark_Resource + // Check invalid union + checkValue("invalid union", ArkUnion(nullptr)); + // Check empty optional + checkValue("undefined", ArkValue()); +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontStyleValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontStyleValidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont]( + const std::string& input, const std::string& expectedStr, const Opt_FontStyle& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + WriteTo(inputValueOptionFont).style = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_STYLE_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.style"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureEnumFontStyleValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} +#endif +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFont1TestOptionFontStyleInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFont1TestOptionFontStyleInvalidValues, TestSize.Level1) +{ + Opt_Font initValueOptionFont; + + // Initial setup + WriteTo(initValueOptionFont).size = + ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + WriteTo(initValueOptionFont).weight = ArkUnion( + std::get<1>(Fixtures::testFixtureEnumFontWeightValidValues[0])); + WriteTo(initValueOptionFont).family = + ArkUnion(std::get<1>(Fixtures::testFixtureStringValidValues[0])); + WriteTo(initValueOptionFont).style = + ArkValue(std::get<1>(Fixtures::testFixtureEnumFontStyleValidValues[0])); + + auto checkValue = [this, &initValueOptionFont](const std::string& input, const Opt_FontStyle& value) { + Opt_Font inputValueOptionFont = initValueOptionFont; + + modifier_->setOptionFont1(node_, &inputValueOptionFont); + WriteTo(inputValueOptionFont).style = value; + modifier_->setOptionFont1(node_, &inputValueOptionFont); + auto jsonValue = GetJsonValue(node_); + auto resultOptionFont = GetAttrValue>(jsonValue, ATTRIBUTE_OPTION_FONT_NAME); + auto resultStr = GetAttrValue(resultOptionFont, ATTRIBUTE_OPTION_FONT_I_STYLE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_I_STYLE_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionFont1, attribute: optionFont.style"; + }; + + for (auto& [input, value] : Fixtures::testFixtureEnumFontStyleInvalidValues) { + checkValue(input, ArkValue(value)); + } +} +#endif +/* + * @tc.name: setOptionFontColor0TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFontColor0TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_FONT_COLOR_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_COLOR_DEFAULT_VALUE) << "Default value for attribute 'optionFontColor'"; +} +#ifdef WRONG_GEN +/* + * @tc.name: setOptionFontColor1TestOptionFontColorValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFontColor1TestOptionFontColorValidValues, TestSize.Level1) +{ + Opt_ResourceColor initValueOptionFontColor; + + // Initial setup + initValueOptionFontColor = + ArkUnion(std::get<1>(Fixtures::testFixtureColorsEnumValidValues[0])); + + auto checkValue = [this, &initValueOptionFontColor]( + const std::string& input, const std::string& expectedStr, const Opt_ResourceColor& value) { + Opt_ResourceColor inputValueOptionFontColor = initValueOptionFontColor; + + inputValueOptionFontColor = value; + modifier_->setOptionFontColor1(node_, &inputValueOptionFontColor); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_FONT_COLOR_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionFontColor1, attribute: optionFontColor"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +/* + * @tc.name: setOptionFontColor1TestOptionFontColorInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionFontColor1TestOptionFontColorInvalidValues, TestSize.Level1) +{ + Opt_ResourceColor initValueOptionFontColor; + + // Initial setup + initValueOptionFontColor = + ArkUnion(std::get<1>(Fixtures::testFixtureColorsEnumValidValues[0])); + + auto checkValue = [this, &initValueOptionFontColor](const std::string& input, const Opt_ResourceColor& value) { + Opt_ResourceColor inputValueOptionFontColor = initValueOptionFontColor; + + modifier_->setOptionFontColor1(node_, &inputValueOptionFontColor); + inputValueOptionFontColor = value; + modifier_->setOptionFontColor1(node_, &inputValueOptionFontColor); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_FONT_COLOR_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_FONT_COLOR_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionFontColor1, attribute: optionFontColor"; + }; + + for (auto& [input, value] : Fixtures::testFixtureColorsStrInvalidValues) { + checkValue(input, ArkUnion(value)); + } + for (auto& [input, value] : Fixtures::testFixtureColorsEnumInvalidValues) { + checkValue(input, ArkUnion(value)); + } + // Check invalid union + checkValue("invalid union", ArkUnion(nullptr)); + // Check empty optional + checkValue("undefined", ArkValue()); +} + +/* + * @tc.name: setSpace0TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setSpace0TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_SPACE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_SPACE_DEFAULT_VALUE) << "Default value for attribute 'space'"; +} + +/* + * @tc.name: setSpace1TestSpaceValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setSpace1TestSpaceValidValues, TestSize.Level1) +{ + Opt_Length initValueSpace; + + // Initial setup + initValueSpace = ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + + auto checkValue = [this, &initValueSpace]( + const std::string& input, const std::string& expectedStr, const Opt_Length& value) { + Opt_Length inputValueSpace = initValueSpace; + + inputValueSpace = value; + modifier_->setSpace1(node_, &inputValueSpace); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_SPACE_NAME); + EXPECT_EQ(resultStr, expectedStr) << "Input value is: " << input << ", method: setSpace1, attribute: space"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureLengthNonNegNonPctValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} + +/* + * @tc.name: setSpace1TestSpaceInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setSpace1TestSpaceInvalidValues, TestSize.Level1) +{ + Opt_Length initValueSpace; + + // Initial setup + initValueSpace = ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + + auto checkValue = [this, &initValueSpace](const std::string& input, const Opt_Length& value) { + Opt_Length inputValueSpace = initValueSpace; + + modifier_->setSpace1(node_, &inputValueSpace); + inputValueSpace = value; + modifier_->setSpace1(node_, &inputValueSpace); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_SPACE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_SPACE_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setSpace1, attribute: space"; + }; + + for (auto& [input, value] : Fixtures::testFixtureLengthNonNegNonPctInvalidValues) { + checkValue(input, ArkValue(value)); + } + // Check empty optional + checkValue("undefined", ArkValue()); +} + +/* + * @tc.name: setArrowPosition1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setArrowPosition1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_ARROW_POSITION_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_ARROW_POSITION_DEFAULT_VALUE) << "Default value for attribute 'arrowPosition'"; +} + +/* + * @tc.name: setArrowPosition1TestArrowPositionValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setArrowPosition1TestArrowPositionValidValues, TestSize.Level1) +{ + Opt_ArrowPosition initValueArrowPosition; + + // Initial setup + initValueArrowPosition = + ArkValue(Ark_ArrowPosition::ARK_ARROW_POSITION_START); + + auto checkValue = [this, &initValueArrowPosition]( + const std::string& input, const std::string& expectedStr, const Opt_ArrowPosition& value) { + Opt_ArrowPosition inputValueArrowPosition = initValueArrowPosition; + + inputValueArrowPosition = value; + modifier_->setArrowPosition1(node_, &inputValueArrowPosition); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_ARROW_POSITION_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setArrowPosition1, attribute: arrowPosition"; + }; + checkValue("ARK_ARROW_POSITION_START", "ArrowPosition.START", + ArkValue(Ark_ArrowPosition::ARK_ARROW_POSITION_START)); + checkValue("ARK_ARROW_POSITION_END", "ArrowPosition.END", + ArkValue(Ark_ArrowPosition::ARK_ARROW_POSITION_END)); +} + +/* + * @tc.name: setArrowPosition1TestArrowPositionInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setArrowPosition1TestArrowPositionInvalidValues, TestSize.Level1) +{ + Opt_ArrowPosition initValueArrowPosition; + + // Initial setup + initValueArrowPosition = + ArkValue(Ark_ArrowPosition::ARK_ARROW_POSITION_START); + + auto checkValue = [this, &initValueArrowPosition](const std::string& input, const Opt_ArrowPosition& value) { + Opt_ArrowPosition inputValueArrowPosition = initValueArrowPosition; + + modifier_->setArrowPosition1(node_, &inputValueArrowPosition); + inputValueArrowPosition = value; + modifier_->setArrowPosition1(node_, &inputValueArrowPosition); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_ARROW_POSITION_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_ARROW_POSITION_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setArrowPosition1, attribute: arrowPosition"; + }; + std::vector> testInvalidValues = { + { "-1", static_cast(-1) }, + { "INT_MAX", static_cast(INT_MAX) }, + }; + for (auto& [input, value] : testInvalidValues) { + checkValue(input, ArkValue(value)); + } +} + +/* + * @tc.name: setOptionWidth1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionWidth1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_WIDTH_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_WIDTH_DEFAULT_VALUE) << "Default value for attribute 'optionWidth'"; +} + +/* + * @tc.name: setOptionWidth1TestOptionWidthValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionWidth1TestOptionWidthValidValues, TestSize.Level1) +{ + Opt_Union_Dimension_OptionWidthMode initValueOptionWidth; + initValueOptionWidth = ArkUnion( + Ark_OptionWidthMode::ARK_OPTION_WIDTH_MODE_FIT_TRIGGER); + auto checkValue = [this, &initValueOptionWidth](const std::string& input, const std::string& expectedStr, + const Opt_Union_Dimension_OptionWidthMode& value) { + Opt_Union_Dimension_OptionWidthMode inputValueOptionWidth = initValueOptionWidth; + inputValueOptionWidth = value; + modifier_->setOptionWidth1(node_, &inputValueOptionWidth); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_WIDTH_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionWidth1, attribute: optionWidth"; + }; + checkValue("ARK_OPTION_WIDTH_MODE_FIT_TRIGGER", "OptionWidthMode.FIT_TRIGGER", + ArkUnion( + Ark_OptionWidthMode::ARK_OPTION_WIDTH_MODE_FIT_TRIGGER)); + auto initialWidth = "0.000000"; + checkValue("ARK_OPTION_WIDTH_MODE_FIT_CONTENT", initialWidth, + ArkUnion( + Ark_OptionWidthMode::ARK_OPTION_WIDTH_MODE_FIT_CONTENT)); + + for (auto& [input, value, expected] : Fixtures::testFixtureLengthPositivelValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + auto lastSetWidth = "1.230000"; + checkValue("ARK_OPTION_WIDTH_MODE_FIT_CONTENT", lastSetWidth, + ArkUnion( + Ark_OptionWidthMode::ARK_OPTION_WIDTH_MODE_FIT_CONTENT)); +} + +#ifdef WRONG_GEN +/* + * @tc.name: setOptionWidth1TestOptionWidthInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionWidth1TestOptionWidthInvalidValues, TestSize.Level1) +{ + Opt_Union_Dimension_OptionWidthMode initValueOptionWidth; + + // Initial setup + initValueOptionWidth = ArkUnion( + Ark_OptionWidthMode::ARK_OPTION_WIDTH_MODE_FIT_TRIGGER); + + auto checkValue = [this, &initValueOptionWidth]( + const std::string& input, const Opt_Union_Dimension_OptionWidthMode& value) { + Opt_Union_Dimension_OptionWidthMode inputValueOptionWidth = initValueOptionWidth; + + modifier_->setOptionWidth1(node_, &inputValueOptionWidth); + inputValueOptionWidth = value; + modifier_->setOptionWidth1(node_, &inputValueOptionWidth); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_WIDTH_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_WIDTH_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionWidth1, attribute: optionWidth"; + }; + + for (auto& [input, value] : Fixtures::testFixtureLengthNonNegNonPctInvalidValues) { + checkValue(input, ArkUnion(value)); + } + std::vector> testInvalidValues = { + { "-1", static_cast(-1) }, + { "INT_MAX", static_cast(INT_MAX) }, + }; + for (auto& [input, value] : testInvalidValues) { + checkValue(input, ArkUnion(value)); + } + // Check invalid union + checkValue("invalid union", ArkUnion(nullptr)); + // Check empty optional + checkValue("undefined", ArkValue()); +} +#endif + +/* + * @tc.name: setOptionHeight1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionHeight1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_HEIGHT_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_HEIGHT_DEFAULT_VALUE) << "Default value for attribute 'optionHeight'"; +} + +/* + * @tc.name: setOptionHeight1TestOptionHeightValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setOptionHeight1TestOptionHeightValidValues, TestSize.Level1) +{ + Opt_Length initValueOptionHeight; + + // Initial setup + initValueOptionHeight = ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + + auto checkValue = [this, &initValueOptionHeight]( + const std::string& input, const std::string& expectedStr, const Opt_Length& value) { + Opt_Length inputValueOptionHeight = initValueOptionHeight; + + inputValueOptionHeight = value; + modifier_->setOptionHeight1(node_, &inputValueOptionHeight); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_HEIGHT_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setOptionHeight1, attribute: optionHeight"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureLengthPositivelValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} + +/* + * @tc.name: setOptionHeight1TestOptionHeightInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setOptionHeight1TestOptionHeightInvalidValues, TestSize.Level1) +{ + Opt_Length initValueOptionHeight; + + // Initial setup + initValueOptionHeight = ArkValue(std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0])); + + auto checkValue = [this, &initValueOptionHeight](const std::string& input, const Opt_Length& value) { + Opt_Length inputValueOptionHeight = initValueOptionHeight; + + modifier_->setOptionHeight1(node_, &inputValueOptionHeight); + inputValueOptionHeight = value; + modifier_->setOptionHeight1(node_, &inputValueOptionHeight); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_OPTION_HEIGHT_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_OPTION_HEIGHT_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setOptionHeight1, attribute: optionHeight"; + }; + + for (auto& [input, value] : Fixtures::testFixtureLengthNonNegNonPctInvalidValues) { + checkValue(input, ArkValue(value)); + } + // Check empty optional + checkValue("undefined", ArkValue()); +} + +/* + * @tc.name: setMenuBackgroundColor1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuBackgroundColor1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_COLOR_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_BACKGROUND_COLOR_DEFAULT_VALUE) << + "Default value for attribute 'menuBackgroundColor'"; +} + +#ifdef WRONG_GEN +/* + * @tc.name: setMenuBackgroundColor1TestMenuBackgroundColorValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuBackgroundColor1TestMenuBackgroundColorValidValues, TestSize.Level1) +{ + Opt_ResourceColor initValueMenuBackgroundColor; + + // Initial setup + initValueMenuBackgroundColor = + ArkUnion(std::get<1>(Fixtures::testFixtureColorsEnumValidValues[0])); + + auto checkValue = [this, &initValueMenuBackgroundColor]( + const std::string& input, const std::string& expectedStr, const Opt_ResourceColor& value) { + Opt_ResourceColor inputValueMenuBackgroundColor = initValueMenuBackgroundColor; + + inputValueMenuBackgroundColor = value; + modifier_->setMenuBackgroundColor1(node_, &inputValueMenuBackgroundColor); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_COLOR_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setMenuBackgroundColor1, attribute: menuBackgroundColor"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +/* + * @tc.name: setMenuBackgroundColor1TestMenuBackgroundColorInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setMenuBackgroundColor1TestMenuBackgroundColorInvalidValues, TestSize.Level1) +{ + Opt_ResourceColor initValueMenuBackgroundColor; + + // Initial setup + initValueMenuBackgroundColor = + ArkUnion(std::get<1>(Fixtures::testFixtureColorsEnumValidValues[0])); + + auto checkValue = [this, &initValueMenuBackgroundColor](const std::string& input, const Opt_ResourceColor& value) { + Opt_ResourceColor inputValueMenuBackgroundColor = initValueMenuBackgroundColor; + + modifier_->setMenuBackgroundColor1(node_, &inputValueMenuBackgroundColor); + inputValueMenuBackgroundColor = value; + modifier_->setMenuBackgroundColor1(node_, &inputValueMenuBackgroundColor); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_COLOR_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_BACKGROUND_COLOR_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setMenuBackgroundColor1, attribute: menuBackgroundColor"; + }; + + for (auto& [input, value] : Fixtures::testFixtureColorsStrInvalidValues) { + checkValue(input, ArkUnion(value)); + } + for (auto& [input, value] : Fixtures::testFixtureColorsEnumInvalidValues) { + checkValue(input, ArkUnion(value)); + } + // Check invalid union + checkValue("invalid union", ArkUnion(nullptr)); + // Check empty optional + checkValue("undefined", ArkValue()); +} + +/* + * @tc.name: setMenuBackgroundBlurStyle1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuBackgroundBlurStyle1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_DEFAULT_VALUE) << + "Default value for attribute 'menuBackgroundBlurStyle'"; +} + +/* + * @tc.name: setMenuBackgroundBlurStyle1TestMenuBackgroundBlurStyleValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuBackgroundBlurStyle1TestMenuBackgroundBlurStyleValidValues, TestSize.Level1) +{ + Opt_BlurStyle initValueMenuBackgroundBlurStyle; + + // Initial setup + initValueMenuBackgroundBlurStyle = + ArkValue(std::get<1>(Fixtures::testFixtureEnumBlurStyleValidValues[0])); + + auto checkValue = [this, &initValueMenuBackgroundBlurStyle]( + const std::string& input, const std::string& expectedStr, const Opt_BlurStyle& value) { + Opt_BlurStyle inputValueMenuBackgroundBlurStyle = initValueMenuBackgroundBlurStyle; + + inputValueMenuBackgroundBlurStyle = value; + modifier_->setMenuBackgroundBlurStyle1(node_, &inputValueMenuBackgroundBlurStyle); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input + << ", method: setMenuBackgroundBlurStyle1, attribute: menuBackgroundBlurStyle"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureEnumBlurStyleValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} + +/* + * @tc.name: setMenuBackgroundBlurStyle1TestMenuBackgroundBlurStyleInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setMenuBackgroundBlurStyle1TestMenuBackgroundBlurStyleInvalidValues, + TestSize.Level1) +{ + Opt_BlurStyle initValueMenuBackgroundBlurStyle; + + // Initial setup + initValueMenuBackgroundBlurStyle = + ArkValue(std::get<1>(Fixtures::testFixtureEnumBlurStyleValidValues[0])); + + auto checkValue = [this, &initValueMenuBackgroundBlurStyle](const std::string& input, const Opt_BlurStyle& value) { + Opt_BlurStyle inputValueMenuBackgroundBlurStyle = initValueMenuBackgroundBlurStyle; + + modifier_->setMenuBackgroundBlurStyle1(node_, &inputValueMenuBackgroundBlurStyle); + inputValueMenuBackgroundBlurStyle = value; + modifier_->setMenuBackgroundBlurStyle1(node_, &inputValueMenuBackgroundBlurStyle); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_BACKGROUND_BLUR_STYLE_DEFAULT_VALUE) << + "Input value is: " << input + << ", method: setMenuBackgroundBlurStyle1, attribute: menuBackgroundBlurStyle"; + }; + + for (auto& [input, value] : Fixtures::testFixtureEnumBlurStyleInvalidValues) { + checkValue(input, ArkValue(value)); + } +} + +/* + * @tc.name: setControlSize1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setControlSize1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::string resultStr; + + resultStr = GetAttrValue(jsonValue, ATTRIBUTE_CONTROL_SIZE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_CONTROL_SIZE_DEFAULT_VALUE) << "Default value for attribute 'controlSize'"; +} + +/* + * @tc.name: setControlSize1TestControlSizeValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setControlSize1TestControlSizeValidValues, TestSize.Level1) +{ + Opt_ControlSize initValueControlSize; + + // Initial setup + initValueControlSize = ArkValue(std::get<1>(Fixtures::testFixtureEnumControlSizeValidValues[0])); + + auto checkValue = [this, &initValueControlSize]( + const std::string& input, const std::string& expectedStr, const Opt_ControlSize& value) { + Opt_ControlSize inputValueControlSize = initValueControlSize; + + inputValueControlSize = value; + modifier_->setControlSize1(node_, &inputValueControlSize); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_CONTROL_SIZE_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setControlSize1, attribute: controlSize"; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureEnumControlSizeValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} + +/* + * @tc.name: setControlSize1TestControlSizeInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, DISABLED_setControlSize1TestControlSizeInvalidValues, TestSize.Level1) +{ + Opt_ControlSize initValueControlSize; + + // Initial setup + initValueControlSize = ArkValue(std::get<1>(Fixtures::testFixtureEnumControlSizeValidValues[0])); + + auto checkValue = [this, &initValueControlSize](const std::string& input, const Opt_ControlSize& value) { + Opt_ControlSize inputValueControlSize = initValueControlSize; + + modifier_->setControlSize1(node_, &inputValueControlSize); + inputValueControlSize = value; + modifier_->setControlSize1(node_, &inputValueControlSize); + auto jsonValue = GetJsonValue(node_); + auto resultStr = GetAttrValue(jsonValue, ATTRIBUTE_CONTROL_SIZE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_CONTROL_SIZE_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setControlSize1, attribute: controlSize"; + }; + + for (auto& [input, value] : Fixtures::testFixtureEnumControlSizeInvalidValues) { + checkValue(input, ArkValue(value)); + } +} + +/* + * @tc.name: setMenuAlign1TestDefaultValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuAlign1TestDefaultValues, TestSize.Level1) +{ + std::unique_ptr jsonValue = GetJsonValue(node_); + std::unique_ptr resultMenuAlign = + GetAttrValue>(jsonValue, ATTRIBUTE_MENU_ALIGN_NAME); + std::unique_ptr resultOffset = + GetAttrValue>(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_OFFSET_NAME); + std::string resultStr; + + resultStr = GetAttrValue(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_DEFAULT_VALUE) << + "Default value for attribute 'menuAlign.alignType'"; + + resultStr = GetAttrValue(resultOffset, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_DEFAULT_VALUE) << + "Default value for attribute 'menuAlign.offset.dx'"; + + resultStr = GetAttrValue(resultOffset, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_DEFAULT_VALUE) << + "Default value for attribute 'menuAlign.offset.dy'"; +} + +/* + * @tc.name: setMenuAlign1TestMenuAlignAlignTypeValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuAlign1TestMenuAlignAlignTypeValidValues, TestSize.Level1) +{ + Opt_MenuAlignType initValueAlignType; + Opt_Offset initValueOffset; + + // Initial setup + initValueAlignType = ArkValue(std::get<1>(testMenuAlignTypeValidValues[0])); + WriteTo(initValueOffset).dx = std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0]); + WriteTo(initValueOffset).dy = std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0]); + + auto checkValue = [this, &initValueAlignType, &initValueOffset]( + const std::string& input, const std::string& expectedStr, const Opt_MenuAlignType& value) { + Opt_MenuAlignType inputValueAlignType = initValueAlignType; + Opt_Offset inputValueOffset = initValueOffset; + + inputValueAlignType = value; + modifier_->setMenuAlign1(node_, &inputValueAlignType, &inputValueOffset); + auto jsonValue = GetJsonValue(node_); + auto resultMenuAlign = GetAttrValue>(jsonValue, ATTRIBUTE_MENU_ALIGN_NAME); + auto resultStr = GetAttrValue(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_NAME); + EXPECT_EQ(resultStr, expectedStr) << + "Input value is: " << input << ", method: setMenuAlign1, attribute: menuAlign.alignType"; + }; + + for (auto& [input, value, expected] : testMenuAlignTypeValidValues) { + checkValue(input, expected, ArkValue(value)); + } +} + +/* + * @tc.name: setMenuAlign1TestMenuAlignAlignTypeInvalidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuAlign1TestMenuAlignAlignTypeInvalidValues, TestSize.Level1) +{ + Opt_MenuAlignType initValueAlignType; + Opt_Offset initValueOffset; + + // Initial setup + initValueAlignType = ArkValue(std::get<1>(testMenuAlignTypeValidValues[0])); + WriteTo(initValueOffset).dx = std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0]); + WriteTo(initValueOffset).dy = std::get<1>(Fixtures::testFixtureLengthNonNegNonPctValidValues[0]); + + auto checkValue = [this, &initValueAlignType, &initValueOffset]( + const std::string& input, const Opt_MenuAlignType& value) { + Opt_MenuAlignType inputValueAlignType = initValueAlignType; + Opt_Offset inputValueOffset = initValueOffset; + + modifier_->setMenuAlign1(node_, &inputValueAlignType, &inputValueOffset); + inputValueAlignType = value; + modifier_->setMenuAlign1(node_, &inputValueAlignType, &inputValueOffset); + auto jsonValue = GetJsonValue(node_); + auto resultMenuAlign = GetAttrValue>(jsonValue, ATTRIBUTE_MENU_ALIGN_NAME); + auto resultStr = GetAttrValue(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_NAME); + EXPECT_EQ(resultStr, ATTRIBUTE_MENU_ALIGN_I_ALIGN_TYPE_DEFAULT_VALUE) << + "Input value is: " << input << ", method: setMenuAlign1, attribute: menuAlign.alignType"; + }; + std::vector> testAlignTypeInvalidValues = { + { "-1", static_cast(-1) }, + { "INT_MAX", static_cast(INT_MAX) }, + }; + for (auto& [input, value] : testAlignTypeInvalidValues) { + checkValue(input, ArkValue(value)); + } +} + +/* + * @tc.name: setMenuAlign1TestMenuAlignOffsetDxValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuAlign1TestMenuAlignOffsetDxValidValues, TestSize.Level1) +{ + Opt_MenuAlignType initValueAlignType; + Opt_Offset initValueOffset; + + // Initial setup + initValueAlignType = ArkValue(std::get<1>(testMenuAlignTypeValidValues[0])); + WriteTo(initValueOffset).dx = Converter::ArkValue(0.0f); + WriteTo(initValueOffset).dy = Converter::ArkValue(0.0f); + + auto checkValue = [this, &initValueAlignType, &initValueOffset]( + const double expected, const Ark_Length& value) { + Opt_MenuAlignType inputValueAlignType = initValueAlignType; + Opt_Offset inputValueOffset = initValueOffset; + + WriteTo(inputValueOffset).dx = value; + modifier_->setMenuAlign1(node_, &inputValueAlignType, &inputValueOffset); + auto jsonValue = GetJsonValue(node_); + auto resultMenuAlign = GetAttrValue>(jsonValue, ATTRIBUTE_MENU_ALIGN_NAME); + auto resultOffset = + GetAttrValue>(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_OFFSET_NAME); + auto resultStr = GetAttrValue(resultOffset, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DX_NAME); + EXPECT_FLOAT_EQ(std::stof(resultStr), expected); + }; + + for (auto& [value, expected] : offsetTestPlan) { + checkValue(expected, value); + } +} + +/* + * @tc.name: setMenuAlign1TestMenuAlignOffsetDyValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuAlign1TestMenuAlignOffsetDyValidValues, TestSize.Level1) +{ + Opt_MenuAlignType initValueAlignType; + Opt_Offset initValueOffset; + + // Initial setup + initValueAlignType = ArkValue(std::get<1>(testMenuAlignTypeValidValues[0])); + WriteTo(initValueOffset).dx = Converter::ArkValue(0.0f); + WriteTo(initValueOffset).dy = Converter::ArkValue(0.0f); + auto checkValue = [this, &initValueAlignType, &initValueOffset]( + const double expected, const Ark_Length& value) { + Opt_MenuAlignType inputValueAlignType = initValueAlignType; + Opt_Offset inputValueOffset = initValueOffset; + + WriteTo(inputValueOffset).dy = value; + modifier_->setMenuAlign1(node_, &inputValueAlignType, &inputValueOffset); + auto jsonValue = GetJsonValue(node_); + auto resultMenuAlign = GetAttrValue>(jsonValue, ATTRIBUTE_MENU_ALIGN_NAME); + auto resultOffset = + GetAttrValue>(resultMenuAlign, ATTRIBUTE_MENU_ALIGN_I_OFFSET_NAME); + auto resultStr = GetAttrValue(resultOffset, ATTRIBUTE_MENU_ALIGN_I_OFFSET_I_DY_NAME); + EXPECT_FLOAT_EQ(std::stof(resultStr), expected); + }; + + for (auto& [value, expected] : offsetTestPlan) { + checkValue(expected, value); + } +} + +/* + * @tc.name: setMenuAlign1TestMenuAlignOffsetDyValidValues + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setsetAvoidanceTest, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setAvoidance); + auto jsonValue = GetJsonValue(node_); + auto resultAvoidance = GetAttrValue(jsonValue, ATTRIBUTE_AVOIDANCE_NAME); + EXPECT_EQ(resultAvoidance, ATTRIBUTE_AVOIDANCE_DEFAULT_VALUE); + + for (auto& [input, value, expected] : testAvoidanceModeFixture) { + auto avoidance = Converter::ArkValue(value); + modifier_->setAvoidance(node_, &avoidance); + jsonValue = GetJsonValue(node_); + resultAvoidance = GetAttrValue(jsonValue, ATTRIBUTE_AVOIDANCE_NAME); + EXPECT_EQ(resultAvoidance, expected); + } +} + +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setDividerStyleTest, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setDividerStyle); + // default values + auto fullJson = GetJsonValue(node_); + auto dividerObject = GetAttrValue>(fullJson, "divider"); + auto dividerCheckValue = dividerObject->ToString(); + EXPECT_EQ(dividerCheckValue, ""); + + auto lengthMetrics = Converter::ArkCreate(ARK_LENGTH_UNIT_VP, 12.f); + auto optLengthMetrics = Converter::ArkValue(lengthMetrics); + Ark_DividerStyleOptions dividerOptions = { + .strokeWidth = optLengthMetrics, + .startMargin = optLengthMetrics, + .endMargin = optLengthMetrics, + .color = Converter::ArkUnion(ARK_COLOR_WHITE), + .mode = Converter::ArkValue(ARK_DIVIDER_MODE_EMBEDDED_IN_MENU), + }; + + auto checkValue = [this, ÷rOptions, &fullJson, ÷rObject]( + const std::string& message, const Ark_DividerMode& value, const std::string& expected) { + // set valid values, color as Ark_Color aka int + dividerOptions.mode = ArkValue(value); + auto divider = ArkValue(dividerOptions); + modifier_->setDividerStyle(node_, ÷r); + fullJson = GetJsonValue(node_); + dividerObject = GetAttrValue>(fullJson, "divider"); + auto strokeWidthCheckValue = GetAttrValue(dividerObject, "strokeWidth"); + EXPECT_EQ(strokeWidthCheckValue, "12.00vp"); + auto startMarginCheckValue = GetAttrValue(dividerObject, "startMargin"); + EXPECT_EQ(startMarginCheckValue, "12.00vp"); + auto endMarginCheckValue = GetAttrValue(dividerObject, "endMargin"); + EXPECT_EQ(endMarginCheckValue, "12.00vp"); + auto colorCheckValue = GetAttrValue(dividerObject, "color"); + EXPECT_EQ(colorCheckValue, "#FFFFFFFF"); + auto modeValue = GetAttrValue(dividerObject, "mode"); + EXPECT_EQ(modeValue, expected) << "check value is " << message; + }; + + for (auto& [message, value, expected] : testDeviderModeFixture) { + checkValue(message, value, expected); + } + auto divider = ArkValue(); + modifier_->setDividerStyle(node_, ÷r); + fullJson = GetJsonValue(node_); + dividerObject = GetAttrValue>(fullJson, "divider"); + dividerCheckValue = dividerObject->ToString(); + EXPECT_EQ(dividerCheckValue, ""); +} + +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestWidthLenth, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + auto singleUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderWidth = renderBorder->propOuterBorderWidth; + ASSERT_TRUE(borderWidth); + EXPECT_FALSE(borderWidth->topDimen) << "undefined"; + EXPECT_FALSE(borderWidth->rightDimen) << "undefined"; + EXPECT_FALSE(borderWidth->bottomDimen) << "undefined"; + EXPECT_FALSE(borderWidth->leftDimen) << "undefined"; + + for (auto& [message, value, expected] : lengthTestPlan) { + singleUnion = ArkUnion(value); + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorderFor = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorderFor); + borderWidth = renderBorderFor->propOuterBorderWidth; + ASSERT_TRUE(borderWidth); + EXPECT_EQ(borderWidth->topDimen, expected) << "value: " << message; + EXPECT_EQ(borderWidth->rightDimen, expected) << "value: " << message; + EXPECT_EQ(borderWidth->bottomDimen, expected) << "value: " << message; + EXPECT_EQ(borderWidth->leftDimen, expected) << "value: " << message; + } +} + +/** + * @tc.name: setMenuOutlineTestWidthEdgeOutlineTop + * @tc.desc: Check the functionality of SelectModifier.setMenuOutline + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestWidthEdgeOutlineTop, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeOutlineWidths multiUnion = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto checkUnion = [this, &multiUnion](const Ark_EdgeOutlineWidths& value) -> std::optional { + auto singleUnion = ArkUnion(value); + Ark_MenuOutlineOptions options; + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + CHECK_NULL_RETURN(renderMock, std::nullopt); + const auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + CHECK_NULL_RETURN(renderBorder, std::nullopt); + auto borderWidth = renderBorder->propOuterBorderWidth; + return borderWidth; + }; + const auto emptyMessage = "empty"; + auto borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_EQ(borderWidth->topDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->rightDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->bottomDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->leftDimen, std::nullopt) << "value: " << emptyMessage; + for (auto& [message, value, expected] : lengthTestPlan) { + multiUnion.top = ArkValue(value); + borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_TRUE(borderWidth->multiValued); + EXPECT_EQ(borderWidth->topDimen, expected) << "value: " << message; + } +} + +/** + * @tc.name: setMenuOutlineTestWidthEdgeOutlineRight + * @tc.desc: Check the functionality of SelectModifier.setMenuOutline + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestWidthEdgeOutlineRight, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeOutlineWidths multiUnion = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto checkUnion = [this, &multiUnion](const Ark_EdgeOutlineWidths& value) -> std::optional { + auto singleUnion = ArkUnion(value); + Ark_MenuOutlineOptions options; + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + CHECK_NULL_RETURN(renderMock, std::nullopt); + const auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + CHECK_NULL_RETURN(renderBorder, std::nullopt); + auto borderWidth = renderBorder->propOuterBorderWidth; + return borderWidth; + }; + const auto emptyMessage = "empty"; + auto borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_EQ(borderWidth->topDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->rightDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->bottomDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->leftDimen, std::nullopt) << "value: " << emptyMessage; + for (auto& [message, value, expected] : lengthTestPlan) { + multiUnion.right = ArkValue(value); + borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_TRUE(borderWidth->multiValued); + EXPECT_EQ(borderWidth->rightDimen, expected) << "value: " << message; + } +} + +/** + * @tc.name: setMenuOutlineTestWidthEdgeOutlineRight + * @tc.desc: Check the functionality of SelectModifier.setMenuOutline + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestWidthEdgeOutlineBottom, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeOutlineWidths multiUnion = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto checkUnion = [this, &multiUnion](const Ark_EdgeOutlineWidths& value) -> std::optional { + auto singleUnion = ArkUnion(value); + Ark_MenuOutlineOptions options; + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + CHECK_NULL_RETURN(renderMock, std::nullopt); + const auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + CHECK_NULL_RETURN(renderBorder, std::nullopt); + auto borderWidth = renderBorder->propOuterBorderWidth; + return borderWidth; + }; + const auto emptyMessage = "empty"; + auto borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_EQ(borderWidth->topDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->rightDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->bottomDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->leftDimen, std::nullopt) << "value: " << emptyMessage; + for (auto& [message, value, expected] : lengthTestPlan) { + multiUnion.bottom = ArkValue(value); + borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_TRUE(borderWidth->multiValued); + EXPECT_EQ(borderWidth->bottomDimen, expected) << "value: " << message; + } +} + +/** + * @tc.name: setMenuOutlineTestWidthEdgeOutlineLeft + * @tc.desc: Check the functionality of SelectModifier.setMenuOutline + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestWidthEdgeOutlineLeft, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeOutlineWidths multiUnion = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto checkUnion = [this, &multiUnion](const Ark_EdgeOutlineWidths& value) -> std::optional { + auto singleUnion = ArkUnion(value); + Ark_MenuOutlineOptions options; + options.width = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + CHECK_NULL_RETURN(renderMock, std::nullopt); + const auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + CHECK_NULL_RETURN(renderBorder, std::nullopt); + auto borderWidth = renderBorder->propOuterBorderWidth; + return borderWidth; + }; + const auto emptyMessage = "empty"; + auto borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_EQ(borderWidth->topDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->rightDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->bottomDimen, std::nullopt) << "value: " << emptyMessage; + EXPECT_EQ(borderWidth->leftDimen, std::nullopt) << "value: " << emptyMessage; + for (auto& [message, value, expected] : lengthTestPlan) { + multiUnion.left = ArkValue(value); + borderWidth = checkUnion(multiUnion); + ASSERT_TRUE(borderWidth); + EXPECT_TRUE(borderWidth->multiValued); + EXPECT_EQ(borderWidth->leftDimen, expected) << "value: " << message; + } +} + +#ifdef WRONG +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorColor, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + auto singleUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + EXPECT_FALSE(borderColor->leftColor) << "undefined"; + EXPECT_FALSE(borderColor->rightColor) << "undefined"; + EXPECT_FALSE(borderColor->topColor) << "undefined"; + EXPECT_FALSE(borderColor->bottomColor) << "undefined"; + + auto checkValue = [this, &singleUnion, &options, &renderMock, &borderColor]( + const std::string& message, const std::string& expected, const Ark_ResourceColor& value) { + singleUnion = ArkUnion(value); + options.color = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + ASSERT_TRUE(borderColor->leftColor); + EXPECT_EQ(borderColor->leftColor->ToString(), expected) << "value: " << message; + ASSERT_TRUE(borderColor->rightColor); + EXPECT_EQ(borderColor->rightColor->ToString(), expected) << "value: " << message; + ASSERT_TRUE(borderColor->topColor); + EXPECT_EQ(borderColor->topColor->ToString(), expected) << "value: " << message; + ASSERT_TRUE(borderColor->bottomColor); + EXPECT_EQ(borderColor->bottomColor->ToString(), expected) << "value: " << message; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorColorInvalid, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + auto singleUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + + auto checkValue = [this, &singleUnion, &options, &renderMock, &borderColor]( + const std::string& message, const Ark_ResourceColor& value) { + singleUnion = ArkUnion(value); + options.color = singleUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + EXPECT_FALSE(borderColor->leftColor) << "undefined"; + EXPECT_FALSE(borderColor->rightColor) << "undefined"; + EXPECT_FALSE(borderColor->topColor) << "undefined"; + EXPECT_FALSE(borderColor->bottomColor) << "undefined"; + }; + for (auto& [input, value] : Fixtures::testFixtureColorsStrInvalidValues) { + checkValue(input, Converter::ArkUnion(value)); + } + + for (auto& [input, value] : Fixtures::testFixtureColorsEnumInvalidValues) { + checkValue(input, Converter::ArkUnion(value)); + } +} + +#ifdef WRONG_GEN +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorEdgeColorsLeft, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeColors edgeColors = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto multiUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto checkValue = [this, &multiUnion, &options, &renderMock, &edgeColors]( + const std::string& message, const std::string& expected, const Ark_ResourceColor& value) { + edgeColors.left = ArkValue(value); + multiUnion = ArkUnion(edgeColors); + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + ASSERT_TRUE(borderColor->leftColor); + EXPECT_EQ(borderColor->leftColor->ToString(), expected) << "value: " << message; + EXPECT_FALSE(borderColor->rightColor) << "value: " << message; + EXPECT_FALSE(borderColor->topColor) << "value: " << message; + EXPECT_FALSE(borderColor->bottomColor) << "value: " << message; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +#ifdef WRONG_GEN +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorEdgeColorsRight, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeColors edgeColors = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto multiUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto checkValue = [this, &multiUnion, &options, &renderMock, &edgeColors]( + const std::string& message, const std::string& expected, const Ark_ResourceColor& value) { + edgeColors.right = ArkValue(value); + multiUnion = ArkUnion(edgeColors); + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + ASSERT_TRUE(borderColor->rightColor); + EXPECT_EQ(borderColor->rightColor->ToString(), expected) << "value: " << message; + EXPECT_FALSE(borderColor->leftColor) << "value: " << message; + EXPECT_FALSE(borderColor->topColor) << "value: " << message; + EXPECT_FALSE(borderColor->bottomColor) << "value: " << message; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +#ifdef WRONG_GEN +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorEdgeColorsTop, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeColors edgeColors = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto multiUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto checkValue = [this, &multiUnion, &options, &renderMock, &edgeColors]( + const std::string& message, const std::string& expected, const Ark_ResourceColor& value) { + edgeColors.top = ArkValue(value); + multiUnion = ArkUnion(edgeColors); + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + ASSERT_TRUE(borderColor->topColor); + EXPECT_EQ(borderColor->topColor->ToString(), expected) << "value: " << message; + EXPECT_FALSE(borderColor->leftColor) << "value: " << message; + EXPECT_FALSE(borderColor->rightColor) << "value: " << message; + EXPECT_FALSE(borderColor->bottomColor) << "value: " << message; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +#ifdef WRONG_GEN +/** + * @tc.name: setDividerTest + * @tc.desc: Check the functionality of SelectModifier.setDivider + * @tc.type: FUNC + */ +HWTEST_F(SelectModifierTest, setMenuOutlineTestColorEdgeColorsBottom, TestSize.Level1) +{ + ASSERT_TRUE(modifier_->setMenuOutline); + Ark_EdgeColors edgeColors = { + .top = ArkValue(), + .right = ArkValue(), + .bottom = ArkValue(), + .left = ArkValue(), + }; + auto multiUnion = ArkValue(); + Ark_MenuOutlineOptions options; + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto renderMock = GetMenuMockRenderContext(); + ASSERT_TRUE(renderMock); + auto checkValue = [this, &multiUnion, &options, &renderMock, &edgeColors]( + const std::string& message, const std::string& expected, const Ark_ResourceColor& value) { + edgeColors.bottom = ArkValue(value); + multiUnion = ArkUnion(edgeColors); + options.color = multiUnion; + auto optOptions = ArkValue(options); + modifier_->setMenuOutline(node_, &optOptions); + auto& renderBorder = renderMock->GetOrCreateOuterBorder(); + ASSERT_TRUE(renderBorder); + auto borderColor = renderBorder->propOuterBorderColor; + ASSERT_TRUE(borderColor); + ASSERT_TRUE(borderColor->bottomColor); + EXPECT_EQ(borderColor->bottomColor->ToString(), expected) << "value: " << message; + EXPECT_FALSE(borderColor->leftColor) << "value: " << message; + EXPECT_FALSE(borderColor->rightColor) << "value: " << message; + EXPECT_FALSE(borderColor->topColor) << "value: " << message; + }; + + for (auto& [input, value, expected] : Fixtures::testFixtureColorsEnumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsNumValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : testColorsResValidValues) { + checkValue(input, expected, ArkUnion(value)); + } + for (auto& [input, value, expected] : Fixtures::testFixtureColorsStrValidValues) { + checkValue(input, expected, ArkUnion(value)); + } +} +#endif +} // namespace OHOS::Ace::NG