Merge branch 'master' of gitee.com:openharmony/arkui_ace_engine into master

Signed-off-by: cq_0418 <chenqian73@huawei.com>
This commit is contained in:
cq_0418 2024-09-05 07:43:08 +00:00 committed by Gitee
commit 079f32582d
86 changed files with 905 additions and 260 deletions

View File

@ -152,6 +152,7 @@ bool AIWriteAdapter::IsSentenceBoundary(const wchar_t value)
void AIWriteAdapter::CloseModalUIExtension()
{
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "CloseModalUIExtension.");
auto context = pipelineContext_.Upgrade();
CHECK_NULL_VOID(context);
auto overlayManager = context->GetOverlayManager();
@ -163,6 +164,7 @@ void AIWriteAdapter::CloseModalUIExtension()
void AIWriteAdapter::ShowModalUIExtension(const AIWriteInfo& info,
std::function<void(std::vector<uint8_t>&)> resultCallback)
{
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "ShowModalUIExtension.");
AAFwk::Want want;
SetWantParams(info, want);
Ace::ModalUIExtensionCallbacks callbacks;

View File

@ -127,6 +127,7 @@ const std::unordered_map<AceLogTag, const char*> g_DOMAIN_CONTENTS_MAP = {
{ AceLogTag::ACE_SECURITY_COMPONENT, "AceSecurityComponent"},
{ AceLogTag::ACE_LAYOUT_INSPECTOR, "AceLayoutInspector" },
{ AceLogTag::ACE_MEDIA_QUERY, "AceMediaQuery" },
{ AceLogTag::ACE_LAYOUT, "AceLayout" },
{ AceLogTag::ACE_STYLUS, "AceStylus"},
};
// initial static member object

View File

@ -204,7 +204,8 @@ enum AceLogTag : uint8_t {
ACE_SECURITY_COMPONENT, // C03956
ACE_LAYOUT_INSPECTOR, // C03957
ACE_MEDIA_QUERY, // C03958
ACE_STYLUS, // C03959
ACE_LAYOUT, // C03959
ACE_STYLUS, // C03960
FORM_RENDER = 255, // C039FF FormRenderer, last domain, do not add
};

View File

@ -6505,7 +6505,7 @@ void JSViewAbstract::JsBindPopup(const JSCallbackInfo& info)
} else {
JSRef<JSObject> showObj = JSRef<JSObject>::Cast(info[0]);
auto callback = ParseDoubleBindCallback(info, showObj);
popupParam->SetOnStateChange(std::move(callback));
popupParam->SetDoubleBindCallback(std::move(callback));
popupParam->SetIsShow(showObj->GetProperty("value")->ToBoolean());
}
// Set popup to popupParam

View File

@ -92,6 +92,10 @@ void ViewFunctions::ExecuteMeasureSize(NG::LayoutWrapper* layoutWrapper)
JSRef<JSVal> params[3] = { selfLayoutInfo, childArray, constraint };
JSRef<JSObject> result = jsMeasureSizeFunc_.Lock()->Call(jsObject_.Lock(), 3, params); /* 3:params number */
if (result->IsUndefined()) {
TAG_LOGW(AceLogTag::ACE_LAYOUT, "app return val of onMeasureSize API is empty or undefined");
return;
}
CalcDimension measureWidth;
CalcDimension measureHeight;

View File

@ -1942,6 +1942,7 @@ void JSWeb::JSBind(BindingTarget globalObj)
JSClass<JSWeb>::StaticMethod("forceDisplayScrollBar", &JSWeb::ForceDisplayScrollBar);
JSClass<JSWeb>::StaticMethod("keyboardAvoidMode", &JSWeb::KeyboardAvoidMode);
JSClass<JSWeb>::StaticMethod("editMenuOptions", &JSWeb::EditMenuOptions);
JSClass<JSWeb>::StaticMethod("enableHapticFeedback", &JSWeb::EnableHapticFeedback);
JSClass<JSWeb>::InheritAndBind<JSViewAbstract>(globalObj);
JSWebDialog::JSBind(globalObj);
@ -5147,4 +5148,13 @@ void JSWeb::EditMenuOptions(const JSCallbackInfo& info)
WebModel::GetInstance()->SetEditMenuOptions(std::move(onCreateMenuCallback), std::move(onMenuItemClick));
}
void JSWeb::EnableHapticFeedback(const JSCallbackInfo& args)
{
if (args.Length() < 1 || !args[0]->IsBoolean()) {
return;
}
bool isEnabled = args[0]->ToBoolean();
WebModel::GetInstance()->SetEnabledHapticFeedback(isEnabled);
}
} // namespace OHOS::Ace::Framework

View File

@ -164,6 +164,7 @@ public:
static void ForceDisplayScrollBar(const JSCallbackInfo& args);
static void KeyboardAvoidMode(int32_t mode);
static void EditMenuOptions(const JSCallbackInfo& info);
static void EnableHapticFeedback(const JSCallbackInfo& args);
protected:
static void OnCommonDialog(const JSCallbackInfo& args, int dialogEventType);

View File

@ -490,6 +490,16 @@ public:
return isCaretMode_;
}
StateChangeFunc GetDoubleBindCallback()
{
return doubleBindCallback_;
}
void SetDoubleBindCallback(StateChangeFunc&& callback)
{
doubleBindCallback_ = callback;
}
private:
bool isShow_ = true;
bool hasAction_ = false;
@ -538,6 +548,7 @@ private:
OnWillDismiss onWillDismiss_;
bool hasTransition_ = false;
RefPtr<NG::ChainedTransitionEffect> transitionEffects_ = nullptr;
StateChangeFunc doubleBindCallback_;
};
} // namespace OHOS::Ace

View File

@ -35,7 +35,6 @@
#include "core/components/container_modal/container_modal_constants.h"
#include "core/components/web/render_web.h"
#include "adapter/ohos/capability/html/span_to_html.h"
#include "core/common/vibrator/vibrator_utils.h"
#ifdef ENABLE_ROSEN_BACKEND
#include "core/components_ng/render/adapter/rosen_render_context.h"
#endif
@ -5197,7 +5196,6 @@ bool WebDelegate::OnContextMenuShow(const std::shared_ptr<BaseEventInfo>& info)
CHECK_NULL_VOID(webEventHub);
auto propOnContextMenuShowEvent = webEventHub->GetOnContextMenuShowEvent();
CHECK_NULL_VOID(propOnContextMenuShowEvent);
NG::VibratorUtils::StartVibraFeedback("longPress.light");
result = propOnContextMenuShowEvent(info);
return;
#else
@ -5212,7 +5210,6 @@ bool WebDelegate::OnContextMenuShow(const std::shared_ptr<BaseEventInfo>& info)
CHECK_NULL_VOID(webEventHub);
auto propOnContextMenuShowEvent = webEventHub->GetOnContextMenuShowEvent();
CHECK_NULL_VOID(propOnContextMenuShowEvent);
NG::VibratorUtils::StartVibraFeedback("longPress.light");
result = propOnContextMenuShowEvent(info);
return;
}
@ -7236,7 +7233,8 @@ std::string WebDelegate::SpanstringConvertHtml(const std::vector<uint8_t> &conte
void WebDelegate::StartVibraFeedback(const std::string& vibratorType)
{
TAG_LOGI(AceLogTag::ACE_WEB, "WebDelegate::StartVibraFeedback vibratorType = %{public}s", vibratorType.c_str());
NG::VibratorUtils::StartVibraFeedback(vibratorType);
auto webPattern = webPattern_.Upgrade();
CHECK_NULL_VOID(webPattern);
webPattern->StartVibraFeedback(vibratorType);
}
} // namespace OHOS::Ace

View File

@ -845,6 +845,132 @@ void FrameNode::DumpOverlayInfo()
std::string("OverlayOffset: ").append(offsetX.ToString()).append(std::string(", ")).append(offsetY.ToString()));
}
void FrameNode::DumpSimplifyCommonInfo(std::unique_ptr<JsonValue>& json)
{
if (geometryNode_->GetFrameRect() != RectF(0.0, 0.0, 0.0, 0.0)) {
json->Put("FrameRect", geometryNode_->GetFrameRect().ToString().c_str());
}
if (renderContext_->GetPaintRectWithoutTransform() != RectF(0.0, 0.0, 0.0, 0.0)) {
json->Put("PaintRectWithoutTransform", renderContext_->GetPaintRectWithoutTransform().ToString().c_str());
}
if (renderContext_->GetBackgroundColor()->ColorToString().compare("#00000000") != 0) {
json->Put("BackgroundColor", renderContext_->GetBackgroundColor()->ColorToString().c_str());
}
if (GetOffsetRelativeToWindow() != OffsetF(0.0, 0.0)) {
json->Put("Offset", GetOffsetRelativeToWindow().ToString().c_str());
}
VisibleType visible = layoutProperty_->GetVisibility().value_or(VisibleType::VISIBLE);
if (visible != VisibleType::VISIBLE) {
json->Put("Visible", static_cast<int32_t>(visible));
}
DumpPadding(layoutProperty_->GetPaddingProperty(), std::string("Padding"), json);
DumpPadding(layoutProperty_->GetSafeAreaPaddingProperty(), std::string("SafeAreaPadding"), json);
DumpBorder(layoutProperty_->GetBorderWidthProperty(), std::string("Border"), json);
DumpPadding(layoutProperty_->GetMarginProperty(), std::string("Margin"), json);
if (layoutProperty_->GetLayoutRect()) {
json->Put("LayoutRect", layoutProperty_->GetLayoutRect().value().ToString().c_str());
}
if (layoutProperty_->GetCalcLayoutConstraint()) {
json->Put("UserDefinedConstraint", layoutProperty_->GetCalcLayoutConstraint()->ToString().c_str());
}
if (layoutProperty_->GetPaddingProperty() || layoutProperty_->GetBorderWidthProperty() ||
layoutProperty_->GetMarginProperty() || layoutProperty_->GetCalcLayoutConstraint()) {
if (layoutProperty_->GetContentLayoutConstraint().has_value()) {
json->Put("ContentConstraint", layoutProperty_->GetContentLayoutConstraint().value().ToString().c_str());
}
}
if (geometryNode_->GetParentLayoutConstraint().has_value()) {
json->Put("ParentLayoutConstraint", geometryNode_->GetParentLayoutConstraint().value().ToString().c_str());
}
}
void FrameNode::DumpPadding(const std::unique_ptr<NG::PaddingProperty>& padding, std::string label,
std::unique_ptr<JsonValue>& json)
{
CHECK_NULL_VOID(padding);
NG::CalcLength defaultValue = NG::CalcLength(
Dimension(0, padding->left.value_or(CalcLength()).GetDimension().Unit()));
if (padding->left.value_or(defaultValue) != defaultValue && padding->right.value_or(defaultValue) != defaultValue &&
padding->top.value_or(defaultValue) != defaultValue && padding->bottom.value_or(defaultValue) != defaultValue) {
json->Put(label.c_str(), padding->ToString().c_str());
}
}
void FrameNode::DumpBorder(const std::unique_ptr<NG::BorderWidthProperty>& border, std::string label,
std::unique_ptr<JsonValue>& json)
{
CHECK_NULL_VOID(border);
Dimension defaultValue(0, border->leftDimen.value_or(Dimension()).Unit());
if (border->leftDimen.value_or(defaultValue) != defaultValue &&
border->rightDimen.value_or(defaultValue) != defaultValue &&
border->topDimen.value_or(defaultValue) != defaultValue &&
border->bottomDimen.value_or(defaultValue) != defaultValue) {
json->Put(label.c_str(), border->ToString().c_str());
}
}
void FrameNode::DumpSimplifySafeAreaInfo(std::unique_ptr<JsonValue>& json)
{
auto&& opts = layoutProperty_->GetSafeAreaExpandOpts();
if (opts && opts->type != NG::SAFE_AREA_TYPE_NONE && opts->edges != NG::SAFE_AREA_EDGE_NONE) {
json->Put("SafeAreaExpandOpts", opts->ToString().c_str());
}
if (layoutProperty_->GetSafeAreaInsets()) {
json->Put("SafeAreaInsets", layoutProperty_->GetSafeAreaInsets()->ToString().c_str());
}
if (SelfOrParentExpansive()) {
RectF defaultValue(0.0, 0.0, 0.0, 0.0);
auto rect = geometryNode_->GetSelfAdjust();
auto parentRect = geometryNode_->GetParentAdjust();
if (rect != defaultValue) {
json->Put("SelfAdjust", rect.ToString().c_str());
}
if (parentRect != defaultValue) {
json->Put("ParentSelfAdjust", parentRect.ToString().c_str());
}
CHECK_EQUAL_VOID(GetTag(), V2::PAGE_ETS_TAG);
auto pipeline = GetContext();
CHECK_NULL_VOID(pipeline);
auto manager = pipeline->GetSafeAreaManager();
CHECK_NULL_VOID(manager);
if (!manager->IsIgnoreAsfeArea()) {
json->Put("IgnoreSafeArea", manager->IsIgnoreAsfeArea());
}
if (!manager->IsNeedAvoidWindow()) {
json->Put("IsNeedAvoidWindow", manager->IsNeedAvoidWindow());
}
if (!manager->IsFullScreen()) {
json->Put("IsFullScreen", manager->IsFullScreen());
}
if (!manager->KeyboardSafeAreaEnabled()) {
json->Put("IsKeyboardAvoidMode", manager->KeyboardSafeAreaEnabled());
}
if (!pipeline->GetUseCutout()) {
json->Put("IsUseCutout", pipeline->GetUseCutout());
}
}
}
void FrameNode::DumpSimplifyOverlayInfo(std::unique_ptr<JsonValue>& json)
{
if (!layoutProperty_->IsOverlayNode()) {
return;
}
json->Put("IsOverlayNode", true);
Dimension offsetX;
Dimension offsetY;
layoutProperty_->GetOverlayOffset(offsetX, offsetY);
json->Put("OverlayOffset", (offsetX.ToString() + "," + offsetY.ToString()).c_str());
}
void FrameNode::DumpSimplifyInfo(std::unique_ptr<JsonValue>& json)
{
CHECK_NULL_VOID(json);
DumpSimplifyCommonInfo(json);
DumpSimplifySafeAreaInfo(json);
DumpSimplifyOverlayInfo(json);
}
void FrameNode::DumpInfo()
{
DumpCommonInfo();
@ -5151,6 +5277,22 @@ void FrameNode::GetInspectorValue()
UINode::GetInspectorValue();
}
void FrameNode::ClearSubtreeLayoutAlgorithm(bool includeSelf, bool clearEntireTree)
{
// return when reaches a child that has no layoutAlgorithm and no need to clear the entire tree
if (!layoutAlgorithm_ && !clearEntireTree) {
return;
}
// include Self might be false for the first ClearSubtreeLayoutAlgorithm enter,
// but children should always include themselves
if (includeSelf) {
layoutAlgorithm_.Reset();
}
for (const auto& child : GetChildren()) {
child->ClearSubtreeLayoutAlgorithm(true, clearEntireTree);
}
}
void FrameNode::OnSyncGeometryFrameFinish(const RectF& paintRect)
{
if (syncedFramePaintRect_.has_value() && syncedFramePaintRect_.value() != paintRect) {

View File

@ -1035,6 +1035,8 @@ public:
return changeInfoFlag_;
}
void ClearSubtreeLayoutAlgorithm(bool includeSelf = true, bool clearEntireTree = false) override;
void ClearChangeInfoFlag()
{
changeInfoFlag_ = FRAME_NODE_CHANGE_INFO_NONE;
@ -1054,6 +1056,11 @@ public:
layoutAlgorithm_.Reset();
}
bool HasLayoutAlgorithm()
{
return layoutAlgorithm_ != nullptr;
}
bool GetDragHitTestBlock() const
{
return dragHitTestBlock_;
@ -1077,6 +1084,7 @@ protected:
std::list<std::function<void()>> destroyCallbacks_;
std::unordered_map<std::string, std::function<void()>> destroyCallbacksMap_;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override;
private:
OPINC_TYPE_E IsOpIncValidNode(const SizeF& boundary, int32_t childNumber = 0);
@ -1121,6 +1129,13 @@ private:
void DumpOverlayInfo();
void DumpCommonInfo();
void DumpCommonInfo(std::unique_ptr<JsonValue>& json);
void DumpSimplifyCommonInfo(std::unique_ptr<JsonValue>& json);
void DumpSimplifySafeAreaInfo(std::unique_ptr<JsonValue>& json);
void DumpSimplifyOverlayInfo(std::unique_ptr<JsonValue>& json);
void DumpBorder(const std::unique_ptr<NG::BorderWidthProperty>& border, std::string label,
std::unique_ptr<JsonValue>& json);
void DumpPadding(const std::unique_ptr<NG::PaddingProperty>& border, std::string label,
std::unique_ptr<JsonValue>& json);
void DumpOverlayInfo(std::unique_ptr<JsonValue>& json);
void DumpDragInfo(std::unique_ptr<JsonValue>& json);
void DumpAlignRulesInfo(std::unique_ptr<JsonValue>& json);

View File

@ -865,6 +865,40 @@ void UINode::DumpTree(int32_t depth, bool hasJson)
}
}
void UINode::DumpSimplifyTree(int32_t depth, std::unique_ptr<JsonValue>& current)
{
current->Put("ID", nodeId_);
current->Put("Type", tag_.c_str());
auto nodeChildren = GetChildren();
DumpSimplifyInfo(current);
bool hasChildren = !nodeChildren.empty() || !disappearingChildren_.empty();
if (hasChildren) {
current->Put("ChildrenSize", static_cast<int32_t>(nodeChildren.size()));
auto array = JsonUtil::CreateArray();
if (!nodeChildren.empty()) {
for (const auto& item : nodeChildren) {
auto child = JsonUtil::Create();
item->DumpSimplifyTree(depth + 1, child);
array->PutRef(std::move(child));
}
}
if (!disappearingChildren_.size()) {
for (const auto& [item, index, branch] : disappearingChildren_) {
auto child = JsonUtil::Create();
item->DumpSimplifyTree(depth + 1, child);
array->PutRef(std::move(child));
}
}
current->PutRef("Children", std::move(array));
}
auto frameNode = AceType::DynamicCast<FrameNode>(this);
if (frameNode && frameNode->GetOverlayNode()) {
auto overlay = JsonUtil::Create();
frameNode->GetOverlayNode()->DumpSimplifyTree(depth + 1, overlay);
current->PutRef("Overlay", std::move(overlay));
}
}
bool UINode::DumpTreeById(int32_t depth, const std::string& id, bool hasJson)
{
if (hasJson) {
@ -1599,6 +1633,13 @@ void UINode::GetInspectorValue()
}
}
void UINode::ClearSubtreeLayoutAlgorithm(bool includeSelf, bool clearEntireTree)
{
for (const auto& child : GetChildren()) {
child->ClearSubtreeLayoutAlgorithm(includeSelf, clearEntireTree);
}
}
void UINode::NotifyWebPattern(bool isRegister)
{
for (const auto& item : GetChildren()) {

View File

@ -197,6 +197,7 @@ public:
bool NeedRequestAutoSave();
// DFX info.
void DumpTree(int32_t depth, bool hasJson = false);
void DumpSimplifyTree(int32_t depth, std::unique_ptr<JsonValue>& current);
virtual bool IsContextTransparent();
bool DumpTreeById(int32_t depth, const std::string& id, bool hasJson = false);
@ -676,6 +677,8 @@ public:
return rootNodeType_;
}
virtual void ClearSubtreeLayoutAlgorithm(bool includeSelf = true, bool clearEntireTree = false);
void GetPageNodeCountAndDepth(int32_t* count, int32_t* depth);
virtual void RegisterUpdateJSInstanceCallback(std::function<void(int32_t)>&& callback)
@ -790,6 +793,7 @@ protected:
// dump self info.
virtual void DumpInfo() {}
virtual void DumpInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpAdvanceInfo() {}
virtual void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) {}

View File

@ -1791,7 +1791,7 @@ void ViewAbstract::BindPopup(const RefPtr<PopupParam>& param, const RefPtr<Frame
if (popupNode) {
popupNode->MarkModifyDone();
popupPattern = popupNode->GetPattern<BubblePattern>();
popupPattern->RegisterPopupStateChangeCallback(param->GetOnStateChange());
popupPattern->RegisterDoubleBindCallback(param->GetDoubleBindCallback());
}
popupInfo.focusable = param->GetFocusable();
popupInfo.target = AceType::WeakClaim(AceType::RawPtr(targetNode));

View File

@ -434,7 +434,10 @@ void FocusManager::WindowFocus(bool isFocus)
auto rootFocusHub = root->GetFocusHub();
CHECK_NULL_VOID(rootFocusHub);
if (!rootFocusHub->IsCurrentFocus()) {
auto focusDepend = rootFocusHub->GetFocusDependence();
rootFocusHub->SetFocusDependence(FocusDependence::SELF);
rootFocusHub->RequestFocusImmediately();
rootFocusHub->SetFocusDependence(focusDepend);
}
pipeline->RequestFrame();
}

View File

@ -55,6 +55,7 @@ private:
void OnModifyDone() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
int32_t textNodeId_ = -2;
};
} // namespace OHOS::Ace::NG

View File

@ -35,6 +35,7 @@ public:
void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void BeforeCreateLayoutWrapper() override;
RefPtr<LayoutProperty> CreateLayoutProperty() override

View File

@ -235,15 +235,15 @@ public:
return hostWindowRect_;
}
void RegisterPopupStateChangeCallback(const std::function<void(const std::string&)>& callback)
void RegisterDoubleBindCallback(const std::function<void(const std::string&)>& callback)
{
onStateChangeCallback_ = callback;
doubleBindCallback_ = callback;
}
void CallPopupStateChangeCallback(const std::string& value)
void CallDoubleBindCallback(const std::string& value)
{
if (onStateChangeCallback_) {
onStateChangeCallback_(value);
if (doubleBindCallback_) {
doubleBindCallback_(value);
}
}
@ -335,6 +335,7 @@ private:
bool enableHoverMode_ = false;
int32_t halfFoldHoverCallbackId_ = -1;
std::function<void(const std::string&)> onStateChangeCallback_ = nullptr;
std::function<void(const std::string&)> doubleBindCallback_ = nullptr;
};
} // namespace OHOS::Ace::NG

View File

@ -168,6 +168,7 @@ public:
void Reset();
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
private:
void OnAttachToFrameNode() override;

View File

@ -187,6 +187,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
bool AvoidBottom() const override
{
return false;

View File

@ -86,6 +86,8 @@ public:
DumpLog::GetInstance().AddDesc(std::string("Type: ").append(isWrap_ ? "Wrap" : "NoWrap"));
}
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
bool GetIsWrap() const
{
return isWrap_;

View File

@ -87,6 +87,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
bool GetNeedCallBack()
{
return needCallBack_;

View File

@ -211,6 +211,7 @@ public:
void BeforeCreatePaintWrapper() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpLayoutInfo();
void DumpLayoutInfo(std::unique_ptr<JsonValue>& json);
void DumpRenderInfo();

View File

@ -104,6 +104,7 @@ private:
bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void BuildArrayValueItems();
void BuildFullArrayValue();
void CollapseArrayValue();

View File

@ -59,6 +59,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
private:
void OnModifyDone() override;

View File

@ -101,6 +101,7 @@ private:
void OnWindowShow() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void StartAnimation();
void StopAnimation();
void FireBuilder();

View File

@ -83,6 +83,7 @@ public:
void OnColorConfigurationUpdate() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void OnVisibleChange(bool isVisible) override;
void OnWindowHide() override;
void OnWindowShow() override;

View File

@ -36,7 +36,6 @@
#include "core/components_ng/pattern/option/option_view.h"
#include "core/components_ng/pattern/scroll/scroll_pattern.h"
#include "core/components_ng/pattern/stack/stack_pattern.h"
#include "core/components_ng/pattern/stage/page_pattern.h"
#include "core/components_ng/pattern/text/text_layout_property.h"
#include "core/components_ng/property/border_property.h"
#include "core/components_v2/inspector/inspector_constants.h"
@ -174,79 +173,6 @@ void ShowMenuOpacityAnimation(const RefPtr<MenuTheme>& menuTheme, const RefPtr<R
}
} // namespace
void MenuPattern::OnDetachFromMainTree()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto pipelineContext = host->GetContext();
CHECK_NULL_VOID(pipelineContext);
if (outterMenuId_ != 0) {
pipelineContext->UnregisterPageChangedCallback(pageId_, outterMenuId_);
}
}
void MenuPattern::SendMenuAccessibilityMessage(bool isShow)
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto accessibilityProperty = host->GetAccessibilityProperty<MenuAccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetAccessibilityIsShow(isShow);
if (isPageChangeClose_) {
isPageChangeClose_ = false;
return;
}
if (isShow) {
host->OnAccessibilityEvent(AccessibilityEventType::PAGE_OPEN,
WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
TAG_LOGI(AceLogTag::ACE_MENU, "Send event to %{public}d",
static_cast<int32_t>(AccessibilityEventType::PAGE_OPEN));
} else {
host->OnAccessibilityEvent(AccessibilityEventType::PAGE_CLOSE,
WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
TAG_LOGI(AceLogTag::ACE_MENU, "Send event to %{public}d",
static_cast<int32_t>(AccessibilityEventType::PAGE_CLOSE));
}
}
void MenuPattern::OnPageChanged(int32_t pageId, bool isOnShow)
{
TAG_LOGD(AceLogTag::ACE_MENU, "On page change, pageId = %{private}d, isOnShow = %{public}d", pageId, isOnShow);
auto host = GetHost();
CHECK_NULL_VOID(host);
if (outterMenuId_ != 0) {
host->OnAccessibilityEvent(AccessibilityEventType::PAGE_CLOSE,
WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
isPageChangeClose_ = true;
}
}
void MenuPattern::OnAttachToMainTree()
{
auto host = GetHost();
CHECK_NULL_VOID(host);
auto pipelineContext = host->GetContext();
CHECK_NULL_VOID(pipelineContext);
auto stageManager = pipelineContext->GetStageManager();
CHECK_NULL_VOID(stageManager);
RefPtr<FrameNode> pageNode = stageManager->GetLastPage();
CHECK_NULL_VOID(pageNode);
auto pagePattern = pageNode->GetPattern<PagePattern>();
CHECK_NULL_VOID(pagePattern);
CHECK_NULL_VOID(pagePattern->GetPageInfo());
int32_t pageId = pagePattern->GetPageInfo()->GetPageId();
auto menuWarpper = GetMenuWrapper();
CHECK_NULL_VOID(menuWarpper);
auto menuWrapperPattern = menuWarpper->GetPattern<MenuWrapperPattern>();
CHECK_NULL_VOID(menuWrapperPattern);
auto outterMenu = menuWrapperPattern->GetMenu();
if (outterMenu->GetId() == host->GetId()) {
outterMenuId_ = outterMenu->GetId();
pageId_ = pageId;
pipelineContext->RegisterPageChangedCallback(pageId, WeakClaim(RawPtr(outterMenu)));
}
}
void MenuPattern::OnAttachToFrameNode()
{
RegisterOnTouch();

View File

@ -341,6 +341,7 @@ public:
RefPtr<FrameNode> GetFirstInnerMenu() const;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void SetFirstShow()
{
isFirstShow_ = true;
@ -511,7 +512,6 @@ public:
{
return isStackSubmenu_;
}
void SendMenuAccessibilityMessage(bool isShow);
protected:
void UpdateMenuItemChildren(RefPtr<UINode>& host);
void SetMenuAttribute(RefPtr<FrameNode>& host);
@ -533,9 +533,6 @@ private:
void RegisterOnTouch();
void OnTouchEvent(const TouchEventInfo& info);
bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
void OnAttachToMainTree() override;
void OnDetachFromMainTree() override;
void OnPageChanged(int32_t pageId, bool isOnShow) override;
// If CustomBuilder is declared with <Menu> and <MenuItem>,
// reset outer menu container and only apply theme on the inner <Menu> node.
@ -587,9 +584,6 @@ private:
MenuPreviewMode previewMode_ = MenuPreviewMode::NONE;
MenuPreviewAnimationOptions previewAnimationOptions_;
bool isShowHoverImage_ = false;
bool isPageChangeClose_ = false;
int32_t outterMenuId_ = 0;
int32_t pageId_ = 0;
MenuPreviewAnimationOptions hoverImageAnimationOptions_;
bool isFirstShow_ = false;
bool isExtensionMenuShow_ = false;

View File

@ -356,6 +356,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
MenuDumpInfo GetDumpInfo() const
{

View File

@ -326,6 +326,7 @@ public:
void NotifyPageHide(const std::string& pageName);
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void SetIsCustomAnimation(bool isCustom)
{
isCustomAnimation_ = isCustom;

View File

@ -387,6 +387,7 @@ private:
void ApplyTitleModifier(const RefPtr<FrameNode>& textNode,
const TextStyleApplyFunc& applyFunc, bool needCheckFontSizeIsSetted);
void DumpInfo() override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
RefPtr<FrameNode> GetParentSideBarContainerNode(const RefPtr<TitleBarNode>& titleBarNode);
void UpdateTitlePositionInfo();

View File

@ -187,6 +187,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
uint64_t GetNavDestinationId() const
{

View File

@ -41,6 +41,7 @@ public:
return targetId_;
}
void DumpInfo() override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void OnModifyDone() override;
void OnAreaChangedInner() override;

View File

@ -1091,9 +1091,20 @@ void OverlayManager::SendToAccessibility(const WeakPtr<FrameNode> node, bool isS
CHECK_NULL_VOID(wrapperPattern);
auto menu = wrapperPattern->GetMenu();
CHECK_NULL_VOID(menu);
auto pattern = menu->GetPattern<MenuPattern>();
CHECK_NULL_VOID(pattern);
pattern->SendMenuAccessibilityMessage(isShow);
auto accessibilityProperty = menu->GetAccessibilityProperty<MenuAccessibilityProperty>();
CHECK_NULL_VOID(accessibilityProperty);
accessibilityProperty->SetAccessibilityIsShow(isShow);
if (isShow) {
menu->OnAccessibilityEvent(AccessibilityEventType::PAGE_OPEN,
WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
TAG_LOGI(AceLogTag::ACE_OVERLAY, "Send event to %{public}d",
static_cast<int32_t>(AccessibilityEventType::PAGE_OPEN));
} else {
menu->OnAccessibilityEvent(AccessibilityEventType::PAGE_CLOSE,
WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
TAG_LOGI(AceLogTag::ACE_OVERLAY, "Send event to %{public}d",
static_cast<int32_t>(AccessibilityEventType::PAGE_CLOSE));
}
}
void OverlayManager::SetPatternFirstShow(const RefPtr<FrameNode>& menu)
@ -1789,7 +1800,7 @@ void OverlayManager::HidePopup(int32_t targetId, const PopupInfo& popupInfo)
subwindow->HideSubWindowNG();
}
};
popupPattern->CallPopupStateChangeCallback("false");
popupPattern->CallDoubleBindCallback("false");
HidePopupAnimation(popupNode, onFinish);
RemoveEventColumn();
RemovePixelMapAnimation(false, 0, 0);

View File

@ -386,6 +386,7 @@ public:
virtual void DumpInfo() {}
virtual void DumpInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpAdvanceInfo() {}
virtual void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) {}
virtual void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) {}
@ -614,8 +615,6 @@ public:
virtual void OnFrameNodeChanged(FrameNodeChangeInfoFlag flag) {}
virtual void OnPageChanged(int32_t pageId, bool isOnShow) {}
virtual bool OnAccessibilityHoverEvent(const PointF& point)
{
return false;

View File

@ -129,6 +129,7 @@ private:
void OnModifyDone() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void OnLanguageConfigurationUpdate() override;
void InitTouchEvent();
void RemoveTouchEvent();

View File

@ -55,6 +55,7 @@ public:
void OnModifyDone() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
FocusPattern GetFocusPattern() const override;
private:

View File

@ -149,6 +149,7 @@ private:
void UpdateLoadingTextOpacity(float opacity);
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
RefreshStatus refreshStatus_ = RefreshStatus::INACTIVE;
RefPtr<PanEvent> panEvent_;
float scrollOffset_;

View File

@ -65,6 +65,8 @@ public:
DumpLog::GetInstance().AddDesc(std::string("topologicalResult:").append(topologicalResult_));
}
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
private:
std::string topologicalResult_;

View File

@ -449,6 +449,7 @@ void RichEditorPattern::AfterStyledStringChange(int32_t start, int32_t length, c
void RichEditorPattern::OnModifyDone()
{
Pattern::CheckLocalized();
auto host = GetHost();
CHECK_NULL_VOID(host);
auto layoutProperty = host->GetLayoutProperty<TextLayoutProperty>();

View File

@ -675,6 +675,7 @@ public:
}
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void MouseDoubleClickParagraphEnd(int32_t& index);
void AdjustSelectionExcludeSymbol(int32_t& start, int32_t& end);
void InitSelection(const Offset& pos);

View File

@ -124,8 +124,8 @@ void SearchTextFieldPattern::ResetSearchRequestStopTwinkling()
searchRequestStopTwinkling_ = false;
}
bool SearchTextFieldPattern::IsSearchTextField()
bool SearchTextFieldPattern::IsNeedProcessAutoFill()
{
return true;
return false;
}
} // namespace OHOS::Ace::NG

View File

@ -36,7 +36,7 @@ public:
void SearchRequestStartTwinkling();
void SearchRequestStopTwinkling();
void ResetSearchRequestStopTwinkling();
bool IsSearchTextField() override;
bool IsNeedProcessAutoFill() override;
private:
bool searchRequestStopTwinkling_ = false;

View File

@ -181,7 +181,7 @@ RefPtr<LayoutAlgorithm> SwiperPattern::CreateLayoutAlgorithm()
void SwiperPattern::OnIndexChange()
{
auto totalCount = RealTotalCount();
auto totalCount = TotalCount();
if (NonPositive(totalCount)) {
return;
}
@ -472,11 +472,14 @@ void SwiperPattern::BeforeCreateLayoutWrapper()
auto userSetCurrentIndex = CurrentIndex();
userSetCurrentIndex = CheckUserSetIndex(userSetCurrentIndex);
auto oldIndex = GetLoopIndex(oldIndex_);
if (oldChildrenSize_.has_value() && oldChildrenSize_.value() != RealTotalCount()) {
if (oldChildrenSize_.has_value() && oldChildrenSize_.value() != TotalCount()) {
oldIndex = GetLoopIndex(oldIndex_, oldChildrenSize_.value());
UpdateIndicatorOnChildChange();
StartAutoPlay();
InitArrow();
if (IsLoop() && oldIndex != GetLoopIndex(currentIndex_)) {
currentIndex_ = oldIndex >= TotalCount() ? 0 : oldIndex;
}
}
auto index = CheckIndexRange(userSetCurrentIndex);
if (index != userSetCurrentIndex) {
@ -1055,7 +1058,7 @@ bool SwiperPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
contentMainSize_ = algo->GetContentMainSize();
crossMatchChild_ = algo->IsCrossMatchChild();
oldIndex_ = currentIndex_;
oldChildrenSize_ = RealTotalCount();
oldChildrenSize_ = TotalCount();
needFireCustomAnimationEvent_ = true;
if (windowSizeChangeReason_ == WindowSizeChangeReason::ROTATION) {

View File

@ -590,6 +590,7 @@ public:
protected:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
private:
std::list<RefPtr<SpanNode>> spanChildren_;

View File

@ -165,6 +165,7 @@ public:
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) override;
void SetTextStyleDumpInfo(std::unique_ptr<JsonValue>& json);
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpScaleInfo();
void DumpTextEngineInfo();
void DumpParagraphsInfo();

View File

@ -128,6 +128,7 @@ private:
void OnDetachFromFrameNode(FrameNode* frameNode) override;
void OnLanguageConfigurationUpdate() override;
void DumpInfo() override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void InitTextClockController();
void InitUpdateTimeTextCallBack();

View File

@ -1779,7 +1779,7 @@ void TextFieldPattern::UpdateCaretByTouchMove(const TouchEventInfo& info)
}
} else {
selectController_->UpdateCaretInfoByOffset(touchOffset);
if (magnifierController_) {
if (magnifierController_ && IsOperation()) {
magnifierController_->SetLocalOffset({ touchOffset.GetX(), touchOffset.GetY() });
}
if (selectController_->GetCaretIndex() != preCaretIndex) {
@ -2298,8 +2298,13 @@ void TextFieldPattern::HandleSingleClickEvent(GestureEvent& info, bool firstGetF
void TextFieldPattern::DoProcessAutoFill()
{
CHECK_NULL_VOID(!IsSearchTextField());
TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "DoProcessAutoFill");
if (!IsNeedProcessAutoFill()) {
if (RequestKeyboardNotByFocusSwitch(RequestKeyboardReason::SINGLE_CLICK)) {
NotifyOnEditChanged(true);
}
return;
}
bool isPopup = false;
auto isSuccess = ProcessAutoFill(isPopup);
if (!isPopup && isSuccess) {
@ -6706,6 +6711,7 @@ void TextFieldPattern::StopEditing()
}
auto host = GetHost();
CHECK_NULL_VOID(host);
ContainerScope scope(host->GetInstanceId());
TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "textfield %{public}d Stop Editing", host->GetId());
FocusHub::LostFocusToViewRoot();
UpdateSelection(selectController_->GetCaretIndex());
@ -8243,7 +8249,7 @@ void TextFieldPattern::OnTextGestureSelectionUpdate(int32_t start, int32_t end,
void TextFieldPattern::UpdateSelectionByLongPress(int32_t start, int32_t end, const Offset& localOffset)
{
if (magnifierController_ && (longPressFingerNum_ == 1)) {
if (magnifierController_ && IsOperation() && (longPressFingerNum_ == 1)) {
contentScroller_.updateMagniferEpsilon = 0.0f - contentScroller_.updateMagniferEpsilon;
magnifierController_->SetLocalOffset(
{ localOffset.GetX(), localOffset.GetY() + contentScroller_.updateMagniferEpsilon });
@ -8603,7 +8609,7 @@ TextFieldInfo TextFieldPattern::GenerateTextFieldInfo()
void TextFieldPattern::AddTextFieldInfo()
{
CHECK_NULL_VOID(!IsSearchTextField());
CHECK_NULL_VOID(IsNeedProcessAutoFill());
auto pipeline = PipelineContext::GetCurrentContextSafely();
CHECK_NULL_VOID(pipeline);
auto textFieldManager = DynamicCast<TextFieldManagerNG>(pipeline->GetTextFieldManager());
@ -8614,7 +8620,7 @@ void TextFieldPattern::AddTextFieldInfo()
void TextFieldPattern::RemoveTextFieldInfo()
{
CHECK_NULL_VOID(!IsSearchTextField());
CHECK_NULL_VOID(IsNeedProcessAutoFill());
auto pipeline = PipelineContext::GetCurrentContextSafely();
CHECK_NULL_VOID(pipeline);
auto textFieldManager = DynamicCast<TextFieldManagerNG>(pipeline->GetTextFieldManager());
@ -8630,7 +8636,7 @@ void TextFieldPattern::RemoveTextFieldInfo()
void TextFieldPattern::UpdateTextFieldInfo()
{
CHECK_NULL_VOID(!IsSearchTextField());
CHECK_NULL_VOID(IsNeedProcessAutoFill());
auto pipeline = PipelineContext::GetCurrentContextSafely();
CHECK_NULL_VOID(pipeline);
auto textFieldManager = DynamicCast<TextFieldManagerNG>(pipeline->GetTextFieldManager());
@ -8688,8 +8694,8 @@ bool TextFieldPattern::IsTriggerAutoFillPassword()
return HasAutoFillPasswordNode();
}
bool TextFieldPattern::IsSearchTextField()
bool TextFieldPattern::IsNeedProcessAutoFill()
{
return false;
return true;
}
} // namespace OHOS::Ace::NG

View File

@ -1187,6 +1187,7 @@ public:
}
void DumpInfo() override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpAdvanceInfo() override;
void DumpPlaceHolderInfo();
void DumpTextEngineInfo();
@ -1537,7 +1538,7 @@ protected:
void StartGestureSelection(int32_t start, int32_t end, const Offset& startOffset) override;
void UpdateSelection(int32_t both);
void UpdateSelection(int32_t start, int32_t end);
virtual bool IsSearchTextField();
virtual bool IsNeedProcessAutoFill();
RefPtr<ContentController> contentController_;
RefPtr<TextSelectController> selectController_;

View File

@ -103,6 +103,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
private:
void OnAttachToFrameNode() override;

View File

@ -70,6 +70,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void SetTextNode(RefPtr<FrameNode> textNode)
{

View File

@ -58,6 +58,7 @@ public:
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void FireOnErrorCallbackOnUI(
int32_t code, const std::string& name, const std::string& msg);

View File

@ -134,7 +134,7 @@ OverScrollOffset WaterFlowLayoutInfoSW::GetOverScrolledDelta(float delta) const
if (!itemEnd_) {
return res;
}
float disToBot = EndPosWithMargin() + footerHeight_ - lastMainSize_;
float disToBot = EndPosWithMargin() + footerHeight_ - std::min(lastMainSize_, maxHeight_);
if (!offsetEnd_) {
res.end = std::min(0.0f, disToBot + delta);
} else if (Negative(delta)) {

View File

@ -140,13 +140,10 @@ void WaterFlowLayoutSW::SingleInit(const SizeF& frameSize)
}
crossGaps_[0] = cross.second;
itemsCrossSize_.resize(1);
itemsCrossSize_ = std::vector<std::vector<float>>(1);
for (const auto& len : cross.first) {
itemsCrossSize_[0].push_back(static_cast<float>(len));
}
if (itemsCrossSize_.empty()) {
itemsCrossSize_[0].push_back(crossSize);
}
info_->lanes_[0].resize(itemsCrossSize_[0].size());
}

View File

@ -1313,4 +1313,14 @@ void WebPattern::UpdateEditMenuOptions(const NG::OnCreateMenuCallback&& onCreate
{
// cross platform is not support now;
}
void WebPattern::OnEnabledHapticFeedbackUpdate(bool enable)
{
// cross platform is not support now;
}
void WebPattern::StartVibraFeedback(const std::string& vibratorType)
{
// cross platform is not support now;
}
} // namespace OHOS::Ace::NG

View File

@ -518,6 +518,7 @@ private:
void OnMetaViewportUpdate(bool value);
void OnOverlayScrollbarEnabledUpdate(bool value);
void OnKeyboardAvoidModeUpdate(const WebKeyboardAvoidMode& mode);
void OnEnabledHapticFeedbackUpdate(bool enable);
void InitEvent();
void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub);
@ -573,6 +574,7 @@ private:
void UpdateBackgroundColorRightNow(int32_t color);
void UpdateContentOffset(const RefPtr<LayoutWrapper>& dirty);
void PostTaskToUI(const std::function<void()>&& task) const;
void StartVibraFeedback(const std::string& vibratorType);
std::optional<std::string> webSrc_;
std::optional<std::string> webData_;

View File

@ -191,6 +191,7 @@ public:
virtual void SetKeyboardAvoidMode(const WebKeyboardAvoidMode& mode) {}
virtual void SetEditMenuOptions(const NG::OnCreateMenuCallback&& onCreateMenuCallback,
const NG::OnMenuItemClickCallback&& onMenuItemClick) {};
virtual void SetEnabledHapticFeedback(bool isEnabled) {}
private:
static std::unique_ptr<WebModel> instance_;
static std::mutex mutex_;

View File

@ -1182,4 +1182,11 @@ void WebModelNG::SetKeyboardAvoidMode(const WebKeyboardAvoidMode& mode)
CHECK_NULL_VOID(webPattern);
webPattern->UpdateKeyboardAvoidMode(mode);
}
void WebModelNG::SetEnabledHapticFeedback(bool isEnabled)
{
auto webPattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<WebPattern>();
CHECK_NULL_VOID(webPattern);
webPattern->UpdateEnabledHapticFeedback(isEnabled);
}
} // namespace OHOS::Ace::NG

View File

@ -193,6 +193,7 @@ public:
void SetKeyboardAvoidMode(const WebKeyboardAvoidMode& mode) override;
void SetEditMenuOptions(const NG::OnCreateMenuCallback&& onCreateMenuCallback,
const NG::OnMenuItemClickCallback&& onMenuItemClick) override;
void SetEnabledHapticFeedback(bool isEnabled) override;
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_MODEL_NG_H

View File

@ -429,7 +429,6 @@ void WebPattern::OnContextMenuShow(const std::shared_ptr<BaseEventInfo>& info)
CHECK_NULL_VOID(contextMenuParam_);
contextMenuResult_ = eventInfo->GetContextMenuResult();
CHECK_NULL_VOID(contextMenuResult_);
VibratorUtils::StartVibraFeedback("longPress.light");
ShowContextSelectOverlay(RectF(), RectF());
}
@ -2428,6 +2427,11 @@ void WebPattern::OnKeyboardAvoidModeUpdate(const WebKeyboardAvoidMode& mode)
keyBoardAvoidMode_ = mode;
}
void WebPattern::OnEnabledHapticFeedbackUpdate(bool enable)
{
isEnabledHapticFeedback_ = enable;
}
bool WebPattern::IsRootNeedExportTexture()
{
auto host = GetHost();
@ -6507,4 +6511,11 @@ int32_t WebPattern::GetBufferSizeByDeviceType()
return (SystemProperties::GetDeviceType() == DeviceType::PHONE) ? ASYNC_SURFACE_QUEUE_SIZE_FOR_PHONE :
ASYNC_SURFACE_QUEUE_SIZE_FOR_OTHERS;
}
void WebPattern::StartVibraFeedback(const std::string& vibratorType)
{
if (isEnabledHapticFeedback_) {
NG::VibratorUtils::StartVibraFeedback(vibratorType);
}
}
} // namespace OHOS::Ace::NG

View File

@ -484,6 +484,7 @@ public:
ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, SelectionMenuOptions, WebMenuOptionsParam);
ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, OverlayScrollbarEnabled, bool);
ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, KeyboardAvoidMode, WebKeyboardAvoidMode);
ACE_DEFINE_PROPERTY_FUNC_WITH_GROUP(WebProperty, EnabledHapticFeedback, bool);
bool IsFocus() const
{
@ -683,6 +684,7 @@ public:
void OnSetAccessibilityChildTree(int32_t childWindowId, int32_t childTreeId);
bool OnAccessibilityChildTreeRegister();
bool OnAccessibilityChildTreeDeregister();
void StartVibraFeedback(const std::string& vibratorType);
int32_t GetTreeId()
{
return treeId_;
@ -773,6 +775,7 @@ private:
void OnSmoothDragResizeEnabledUpdate(bool value);
void OnOverlayScrollbarEnabledUpdate(bool enable);
void OnKeyboardAvoidModeUpdate(const WebKeyboardAvoidMode& mode);
void OnEnabledHapticFeedbackUpdate(bool enable);
int GetWebId();
void InitEvent();
@ -1110,6 +1113,7 @@ private:
bool isAutoFillClosing_ = true;
ViewDataCommon viewDataCommon_;
bool isPasswordFill_ = false;
bool isEnabledHapticFeedback_ = true;
NestedScrollOptionsExt nestedScroll_ = {
.scrollUp = NestedScrollMode::SELF_ONLY,
.scrollDown = NestedScrollMode::SELF_ONLY,

View File

@ -79,6 +79,7 @@ struct WebPatternProperty {
ACE_DEFINE_PROPERTY_GROUP_ITEM(SelectionMenuOptions, WebMenuOptionsParam);
ACE_DEFINE_PROPERTY_GROUP_ITEM(OverlayScrollbarEnabled, bool);
ACE_DEFINE_PROPERTY_GROUP_ITEM(KeyboardAvoidMode, WebKeyboardAvoidMode);
ACE_DEFINE_PROPERTY_GROUP_ITEM(EnabledHapticFeedback, bool);
};
} // namespace OHOS::Ace::NG

View File

@ -322,6 +322,7 @@ private:
void OnModifyDone() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpAdvanceInfo() override;
void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) override;
void OnAttachContext(PipelineContext *context) override;

View File

@ -2548,8 +2548,11 @@ bool PipelineContext::OnDumpInfo(const std::vector<std::string>& params) const
} else if (params[0] == "--stylus") {
StylusDetectorDefault::GetInstance()->ExecuteCommand(params);
} else if (params[0] == "-simplify") {
rootNode_->DumpTree(0, true);
DumpLog::GetInstance().OutPutDefault();
auto root = JsonUtil::Create(true);
rootNode_->DumpSimplifyTree(0, root);
auto json = root->ToString();
json.erase(std::remove(json.begin(), json.end(), ' '), json.end());
DumpLog::GetInstance().Print(json);
}
return true;
}
@ -3480,37 +3483,12 @@ void PipelineContext::RemoveNavigationNode(int32_t pageId, int32_t nodeId)
}
}
void PipelineContext::RegisterPageChangedCallback(int32_t pageId, WeakPtr<FrameNode> notifiedNode)
{
CHECK_RUN_ON(UI);
auto node = notifiedNode.Upgrade();
CHECK_NULL_VOID(node);
pageNotifiedNodes_[pageId][node->GetId()] = notifiedNode;
}
void PipelineContext::UnregisterPageChangedCallback(int32_t pageId, int32_t nodeId)
{
CHECK_RUN_ON(UI);
auto it = pageNotifiedNodes_.find(pageId);
if (it != pageNotifiedNodes_.end() && !it->second.empty()) {
it->second.erase(nodeId);
}
}
void PipelineContext::FirePageChanged(int32_t pageId, bool isOnShow)
{
CHECK_RUN_ON(UI);
for (auto navigationNode : pageToNavigationNodes_[pageId]) {
NavigationPattern::FireNavigationChange(navigationNode.Upgrade(), isOnShow, true);
}
for (auto& notifiedNodePair : pageNotifiedNodes_[pageId]) {
auto node = notifiedNodePair.second.Upgrade();
if (node) {
auto pattern = node->GetPattern();
CHECK_NULL_VOID(pattern);
pattern->OnPageChanged(pageId, isOnShow);
}
}
}
void PipelineContext::FlushWindowSizeChangeCallback(int32_t width, int32_t height, WindowSizeChangeReason type)

View File

@ -398,10 +398,6 @@ public:
void RemoveNavigationNode(int32_t pageId, int32_t nodeId);
void RegisterPageChangedCallback(int32_t pageId, WeakPtr<FrameNode> notifiedNode);
void UnregisterPageChangedCallback(int32_t pageId, int32_t nodeId);
void FirePageChanged(int32_t pageId, bool isOnShow);
bool HasDifferentDirectionGesture() const;
@ -1105,7 +1101,6 @@ private:
std::unordered_map<int32_t, WeakPtr<FrameNode>> storeNode_;
std::unordered_map<int32_t, std::string> restoreNodeInfo_;
std::unordered_map<int32_t, std::vector<WeakPtr<UINode>>> pageToNavigationNodes_;
std::unordered_map<int32_t, std::unordered_map<int32_t, WeakPtr<FrameNode>>> pageNotifiedNodes_;
std::unordered_map<int32_t, std::vector<TouchEvent>> historyPointsById_;
std::list<FrameInfo> dumpFrameInfos_;

View File

@ -333,6 +333,10 @@ static napi_value JSCreate(napi_env env, napi_callback_info info)
napi_value jsDisplaySync = nullptr;
displaySync->NapiSerializer(env, jsDisplaySync);
if (!jsDisplaySync) {
delete displaySync;
return nullptr;
}
napi_property_descriptor resultFuncs[] = {
DECLARE_NAPI_FUNCTION("setExpectedFrameRateRange", JSSetExpectedFrameRateRange),
@ -342,7 +346,7 @@ static napi_value JSCreate(napi_env env, napi_callback_info info)
DECLARE_NAPI_FUNCTION("stop", JSStop),
};
TAG_LOGI(AceLogTag::ACE_DISPLAY_SYNC, "Create UIDisplaySync Id: %{public}" PRIu64 "",
TAG_LOGD(AceLogTag::ACE_DISPLAY_SYNC, "Create UIDisplaySync Id: %{public}" PRIu64 "",
uiDisplaySync->GetId());
NAPI_CALL(env, napi_define_properties(
env, jsDisplaySync, sizeof(resultFuncs) / sizeof(resultFuncs[0]), resultFuncs));

View File

@ -18,7 +18,8 @@
namespace OHOS::Ace::NG {
void MockAnimationManager::CancelAnimations()
{
for (auto&& prop : activeProps_) {
const auto props = std::move(activeProps_);
for (const auto& prop : props) {
auto it = propToAnimation_.find(prop);
if (it == propToAnimation_.end()) {
continue;
@ -42,7 +43,7 @@ std::vector<RefPtr<MockImplicitAnimation>> MockAnimationManager::CloseAnimation(
}
// capture active props in animation
std::vector<RefPtr<MockImplicitAnimation>> res;
for (auto&& prop : activeProps_) {
for (const auto& prop : activeProps_) {
auto anim = propToAnimation_[prop].Upgrade();
if (anim) {
// update existing animation instead
@ -57,29 +58,35 @@ std::vector<RefPtr<MockImplicitAnimation>> MockAnimationManager::CloseAnimation(
return res;
}
void MockAnimationManager::Tick()
namespace {
void PruneAnimation(std::list<RefPtr<MockImplicitAnimation>>& animations)
{
for (auto it = animations_.begin(); it != animations_.end();) {
for (auto it = animations.begin(); it != animations.end();) {
auto&& anim = *it;
if (!anim || anim->Finished()) {
it = animations_.erase(it);
it = animations.erase(it);
} else {
anim->Next();
++it;
}
}
}
} // namespace
void MockAnimationManager::Tick()
{
PruneAnimation(animations_);
const auto anims = animations_;
for (const auto& anim : anims) {
anim->Next();
}
}
void MockAnimationManager::TickByVelocity(float velocity)
{
for (auto it = animations_.begin(); it != animations_.end();) {
auto&& anim = *it;
if (!anim || anim->Finished()) {
it = animations_.erase(it);
} else {
anim->ForceUpdate(velocity);
++it;
}
PruneAnimation(animations_);
const auto anims = animations_;
for (const auto& anim : anims) {
anim->ForceUpdate(velocity);
}
}
@ -92,4 +99,20 @@ void MockAnimationManager::Reset()
ticks_ = 1;
inScope_ = false;
}
bool MockAnimationManager::AllFinished()
{
PruneAnimation(animations_);
return animations_.empty();
}
void MockAnimationManager::SetParams(const AnimationOption& option, AnimationCallbacks&& cbs)
{
params_.callbacks = std::move(cbs);
if (AceType::InstanceOf<InterpolatingSpring>(option.GetCurve()) || option.GetDuration() > 0) {
params_.type = AnimationOperation::PLAY;
} else {
params_.type = AnimationOperation::CANCEL;
}
}
} // namespace OHOS::Ace::NG

View File

@ -65,19 +65,17 @@ public:
{
callbacks.finishCb = nullptr;
callbacks.repeatCb = nullptr;
type = AnimationOperation::CANCEL;
type = AnimationOperation::PLAY;
}
};
void SetParams(int32_t duration, AnimationCallbacks&& param)
{
params_.callbacks = std::move(param);
params_.type = (duration <= 0) ? AnimationOperation::CANCEL : AnimationOperation::PLAY;
}
void SetParams(const AnimationOption& option, AnimationCallbacks&& cbs);
void AddActiveProp(const WeakPtr<PropertyBase>& prop)
{
activeProps_.insert(prop);
if (inScope_) {
activeProps_.insert(prop);
}
}
/**
@ -94,6 +92,8 @@ public:
void Reset();
bool AllFinished();
private:
void CancelAnimations();

View File

@ -69,7 +69,7 @@ void AnimationUtils::Animate(const AnimationOption& option, const PropertyCallba
const FinishCallback& finishCallback, const RepeatCallback& repeatCallback)
{
#ifdef ENHANCED_ANIMATION
AnimManager::GetInstance().SetParams(option.GetDuration(), { finishCallback, repeatCallback });
AnimManager::GetInstance().SetParams(option, { finishCallback, repeatCallback });
AnimManager::GetInstance().OpenAnimation();
#endif
if (callback) {
@ -116,7 +116,7 @@ std::shared_ptr<AnimationUtils::Animation> AnimationUtils::StartAnimation(const
const PropertyCallback& callback, const FinishCallback& finishCallback, const RepeatCallback& repeatCallback)
{
#ifdef ENHANCED_ANIMATION
AnimManager::GetInstance().SetParams(option.GetDuration(), { finishCallback, repeatCallback });
AnimManager::GetInstance().SetParams(option, { finishCallback, repeatCallback });
AnimManager::GetInstance().OpenAnimation();
if (callback) {
callback();

View File

@ -28,7 +28,7 @@ void NodeAnimatableProperty<float, AnimatablePropertyFloat>::AnimateWithVelocity
if (!MockAnimationManager::Enabled()) {
return;
}
MockAnimationManager::GetInstance().SetParams(option.GetDuration(), { finishCallback, nullptr });
MockAnimationManager::GetInstance().SetParams(option, { finishCallback, nullptr });
MockAnimationManager::GetInstance().OpenAnimation();
Set(value);
MockAnimationManager::GetInstance().CloseAnimation();

View File

@ -30,7 +30,7 @@ void InitProp(const RefPtr<PropertyBase>& propBase)
prop->SetUpCallbacks(
[weak = WeakPtr(prop)]() { return MockAnimationProxy<float>::GetInstance().GetEndValue(weak.Upgrade()); },
[weak = WeakPtr(prop)](
float value) { MockAnimationProxy<float>::GetInstance().RecordPropChange(weak.Upgrade(), value); },
float value) { MockAnimationProxy<float>::GetInstance().RecordPropChange(weak, value); },
[weak = WeakPtr(prop)]() {
return MockAnimationProxy<float>::GetInstance().GetStagingValue(weak.Upgrade());
});
@ -41,7 +41,7 @@ void InitProp(const RefPtr<PropertyBase>& propBase)
prop->SetUpCallbacks(
[weak = WeakPtr(prop)]() { return MockAnimationProxy<OffsetF>::GetInstance().GetEndValue(weak.Upgrade()); },
[weak = WeakPtr(prop)](
OffsetF value) { MockAnimationProxy<OffsetF>::GetInstance().RecordPropChange(weak.Upgrade(), value); },
OffsetF value) { MockAnimationProxy<OffsetF>::GetInstance().RecordPropChange(weak, value); },
[weak = WeakPtr(prop)]() {
return MockAnimationProxy<OffsetF>::GetInstance().GetStagingValue(weak.Upgrade());
});

View File

@ -35,6 +35,7 @@ ace_unittest("frame_node_test_ng") {
"frame_node_test_ng_coverage.cpp",
"frame_node_test_ng_coverage_new.cpp",
"frame_node_test_ng_new.cpp",
"frame_node_test_ng_v3.cpp",
]
}

View File

@ -0,0 +1,144 @@
/*
* Copyright (c) 2024 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 "test/unittest/core/base/frame_node_test_ng.h"
#include "core/event/touch_event.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS::Ace::NG {
namespace {} // namespace
/**
* @tc.name: ResetLayoutAlgorithmTest1
* @tc.desc: Test the function ResetLayoutAlgorithm with default param
* @tc.type: FUNC
*/
HWTEST_F(FrameNodeTestNg, ResetLayoutAlgorithmTest1, TestSize.Level1)
{
/**
* @tc.steps: step1. create frameNode.
*/
auto frameNode1 = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
auto frameNode2 = FrameNode::CreateFrameNode("framenode", 2, AceType::MakeRefPtr<Pattern>());
auto frameNode3 = FrameNode::CreateFrameNode("framenode", 3, AceType::MakeRefPtr<Pattern>());
/**
* @tc.steps: step2. mount nodes and create layoutAlgorithm
*/
frameNode2->MountToParent(frameNode1);
frameNode3->MountToParent(frameNode2);
EXPECT_NE(frameNode1->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode2->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode3->GetLayoutAlgorithm(), nullptr);
/**
* @tc.steps: step2. start to clear. layoutAlgo of frameNode1 will not not be cleared
*/
frameNode1->ClearSubtreeLayoutAlgorithm(false);
EXPECT_TRUE(frameNode1->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode2->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode3->HasLayoutAlgorithm());
}
/**
* @tc.name: ResetLayoutAlgorithmTest2
* @tc.desc: Test the function ResetLayoutAlgorithm with default param
* @tc.type: FUNC
*/
HWTEST_F(FrameNodeTestNg, ResetLayoutAlgorithmTest2, TestSize.Level1)
{
/**
* @tc.steps: step1. create frameNode.
*/
auto frameNode1 = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
auto frameNode2 = FrameNode::CreateFrameNode("framenode", 2, AceType::MakeRefPtr<Pattern>());
auto frameNode3 = FrameNode::CreateFrameNode("framenode", 3, AceType::MakeRefPtr<Pattern>());
/**
* @tc.steps: step2. mount nodes and create layoutAlgorithm
*/
frameNode2->MountToParent(frameNode1);
frameNode3->MountToParent(frameNode2);
EXPECT_NE(frameNode1->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode2->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode3->GetLayoutAlgorithm(), nullptr);
/**
* @tc.steps: step3. start to clear. layoutAlgo of frameNode1 will not not be cleared
*/
frameNode1->ClearSubtreeLayoutAlgorithm(true);
EXPECT_FALSE(frameNode1->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode2->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode3->HasLayoutAlgorithm());
}
/**
* @tc.name: ResetLayoutAlgorithmTest3
* @tc.desc: Test the function ResetLayoutAlgorithm and node3 should still have layoutAlgorithm
* because chain broke at node2
* @tc.type: FUNC
*/
HWTEST_F(FrameNodeTestNg, ResetLayoutAlgorithmTest3, TestSize.Level1)
{
/**
* @tc.steps: step1. create frameNode.
*/
auto frameNode1 = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
auto frameNode2 = FrameNode::CreateFrameNode("framenode", 2, AceType::MakeRefPtr<Pattern>());
auto frameNode3 = FrameNode::CreateFrameNode("framenode", 3, AceType::MakeRefPtr<Pattern>());
/**
* @tc.steps: step2. mount nodes and create layoutAlgorithm
*/
frameNode2->MountToParent(frameNode1);
frameNode3->MountToParent(frameNode2);
EXPECT_NE(frameNode1->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode3->GetLayoutAlgorithm(), nullptr);
/**
* @tc.steps: step3. start to clear. layoutAlgo of frameNode1 will not not be cleared
*/
frameNode1->ClearSubtreeLayoutAlgorithm(true);
EXPECT_FALSE(frameNode1->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode2->HasLayoutAlgorithm());
EXPECT_TRUE(frameNode3->HasLayoutAlgorithm());
}
/**
* @tc.name: ResetLayoutAlgorithmTest4
* @tc.desc: Test the function ResetLayoutAlgorithm with clearing the whole tree
* @tc.type: FUNC
*/
HWTEST_F(FrameNodeTestNg, ResetLayoutAlgorithmTest4, TestSize.Level1)
{
/**
* @tc.steps: step1. create frameNode.
*/
auto frameNode1 = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
auto frameNode2 = FrameNode::CreateFrameNode("framenode", 2, AceType::MakeRefPtr<Pattern>());
auto frameNode3 = FrameNode::CreateFrameNode("framenode", 3, AceType::MakeRefPtr<Pattern>());
/**
* @tc.steps: step2. mount nodes and create layoutAlgorithm
*/
frameNode2->MountToParent(frameNode1);
frameNode3->MountToParent(frameNode2);
EXPECT_NE(frameNode1->GetLayoutAlgorithm(), nullptr);
EXPECT_NE(frameNode3->GetLayoutAlgorithm(), nullptr);
/**
* @tc.steps: step3. start to clear. layoutAlgo of frameNode1 will not not be cleared
*/
frameNode1->ClearSubtreeLayoutAlgorithm(true, true);
EXPECT_FALSE(frameNode1->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode2->HasLayoutAlgorithm());
EXPECT_FALSE(frameNode3->HasLayoutAlgorithm());
}
} // namespace OHOS::Ace::NG

View File

@ -937,14 +937,14 @@ HWTEST_F(GridOptionLayoutTestNg, Refresh001, TestSize.Level1)
FlushLayoutTask(frameNode_);
EXPECT_EQ(refreshNode->GetGeometryNode()->GetFrameOffset().GetY(), 0.f);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "245.45px");
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "445.45px");
EXPECT_EQ(refreshNode->GetGeometryNode()->GetFrameOffset().GetY(), 0.f);
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(refreshNode->GetGeometryNode()->GetFrameOffset().GetY(), 0.f);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "245.45px");
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
EXPECT_EQ(refreshNode->GetGeometryNode()->GetFrameOffset().GetY(), 0.f);
}
} // namespace OHOS::Ace::NG

View File

@ -1279,8 +1279,8 @@ HWTEST_F(RichEditorBaseTestNg, RichEditorController012, TestSize.Level1)
* @tc.steps: step4. update symbol span style
*/
struct UpdateSpanStyle updateSpanStyle;
updateSpanStyle.updateFontSize = FONT_SIZE_VALUE_2;
updateSpanStyle.updateFontWeight = FONT_WEIGHT_BOLD;
updateSpanStyle.updateSymbolFontSize = FONT_SIZE_VALUE_2;
updateSpanStyle.updateSymbolFontWeight = FONT_WEIGHT_BOLD;
updateSpanStyle.updateSymbolColor = SYMBOL_COLOR_LIST_2;
updateSpanStyle.updateSymbolRenderingStrategy = RENDER_STRATEGY_MULTI_COLOR;
updateSpanStyle.updateSymbolEffectStrategy = EFFECT_STRATEGY_SCALE;

View File

@ -25,8 +25,6 @@ int32_t testOnIMEInputComplete = 0;
int32_t testAboutToDelete = 0;
int32_t testOnDeleteComplete = 0;
const Ace::TextDecoration TEXT_DECORATION_VALUE_2 = Ace::TextDecoration::UNDERLINE;
const Dimension LETTER_SPACING_2 = Dimension(12, DimensionUnit::PX);
const Dimension LINE_HEIGHT_VALUE_2 = Dimension(30, DimensionUnit::PX);
const Dimension IMAGE_WIDTH = 50.0_vp;
const Dimension IMAGE_HEIGHT = 50.0_vp;
const ImageSpanSize TEST_IMAGE_SIZE_1 = { .width = 50.0_vp, .height = 50.0_vp };
@ -493,65 +491,6 @@ HWTEST_F(RichEditorClickTestNg, MouseRightFocus001, TestSize.Level1)
EXPECT_EQ(richEditorPattern->caretPosition_, 0);
}
/**
* @tc.name: RichEditorController018
* @tc.desc: test UpdateSymbolStyle
* @tc.type: FUNC
*/
HWTEST_F(RichEditorClickTestNg, RichEditorController018, TestSize.Level1)
{
/**
* @tc.steps: step1. get richEditorController
*/
ASSERT_NE(richEditorNode_, nullptr);
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
ASSERT_NE(richEditorPattern, nullptr);
auto richEditorController = richEditorPattern->GetRichEditorController();
ASSERT_NE(richEditorController, nullptr);
/**
* @tc.steps: step2. initalize symbol span properties
*/
TextStyle style;
style.SetFontSize(FONT_SIZE_VALUE);
style.SetLineHeight(LINE_HEIGHT_VALUE);
style.SetLetterSpacing(LETTER_SPACING);
SymbolSpanOptions options;
options.symbolId = SYMBOL_ID;
options.style = style;
/**
* @tc.steps: step3. add symbol span
*/
auto index1 = richEditorController->AddSymbolSpan(options);
EXPECT_EQ(index1, 0);
/**
* @tc.steps: step4. test UpdateSymbolStyle
*/
struct UpdateSpanStyle updateSpanStyle;
updateSpanStyle.updateLineHeight = LINE_HEIGHT_VALUE_2;
updateSpanStyle.updateLetterSpacing = LETTER_SPACING_2;
richEditorController->SetUpdateSpanStyle(updateSpanStyle);
ImageSpanAttribute imageStyle;
style.SetLineHeight(LINE_HEIGHT_VALUE_2);
style.SetLetterSpacing(LETTER_SPACING_2);
richEditorController->UpdateSpanStyle(0, 2, style, imageStyle);
/**
* @tc.steps: step5. test symbol span style
*/
auto newSpan1 = AceType::DynamicCast<SpanNode>(richEditorNode_->GetChildAtIndex(0));
ASSERT_NE(newSpan1, nullptr);
EXPECT_EQ(newSpan1->GetFontSize(), FONT_SIZE_VALUE);
EXPECT_EQ(newSpan1->GetLineHeight(), LINE_HEIGHT_VALUE_2);
EXPECT_EQ(newSpan1->GetLetterSpacing(), LETTER_SPACING_2);
ClearSpan();
}
/**
* @tc.name: RichEditorController019
* @tc.desc: test UpdateImageStyle

View File

@ -597,6 +597,113 @@ HWTEST_F(RichEditorEditTestOneNg, HandleOnPaste001, TestSize.Level1)
EXPECT_EQ(richEditorPattern->textSelector_.baseOffset, 0);
}
/**
* @tc.name: HandleAIWrite001
* @tc.desc: test GetAIWriteInfo
* @tc.type: FUNC
*/
HWTEST_F(RichEditorEditTestOneNg, HandleAIWrite001, TestSize.Level1)
{
ASSERT_NE(richEditorNode_, nullptr);
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
ASSERT_NE(richEditorPattern, nullptr);
auto richEditorController = richEditorPattern->GetRichEditorController();
ASSERT_NE(richEditorController, nullptr);
TextSpanOptions options;
options.value = INIT_VALUE_3;
richEditorController->AddTextSpan(options);
richEditorPattern->textSelector_.Update(0, 5);
AIWriteInfo info;
richEditorPattern->GetAIWriteInfo(info);
EXPECT_EQ(info.selectStart, 0);
EXPECT_EQ(info.selectEnd, 5);
EXPECT_EQ(info.selectLength, 5);
EXPECT_EQ(info.firstHandle, richEditorPattern->textSelector_.firstHandle.ToString());
EXPECT_EQ(info.secondHandle, richEditorPattern->textSelector_.secondHandle.ToString());
RefPtr<SpanString> spanString = SpanString::DecodeTlv(info.selectBuffer);
ASSERT_NE(spanString, nullptr);
auto textContent = spanString->GetString();
EXPECT_EQ(textContent.empty(), false);
}
/**
* @tc.name: HandleAIWrite001
* @tc.desc: test HandleOnAIWrite
* @tc.type: FUNC
*/
HWTEST_F(RichEditorEditTestOneNg, HandleAIWrite002, TestSize.Level1)
{
ASSERT_NE(richEditorNode_, nullptr);
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
ASSERT_NE(richEditorPattern, nullptr);
auto richEditorController = richEditorPattern->GetRichEditorController();
ASSERT_NE(richEditorController, nullptr);
TextSpanOptions options;
options.value = INIT_VALUE_3;
richEditorController->AddTextSpan(options);
richEditorPattern->textSelector_.Update(0, 5);
richEditorPattern->HandleOnAIWrite();
auto start = richEditorPattern->operationRecords_.size();
std::vector<uint8_t> buff;
auto spanStr = AceType::MakeRefPtr<SpanString>("dddd结果回填123456");
spanStr->EncodeTlv(buff);
richEditorPattern->HandleAIWriteResult(0, 5, buff);
EXPECT_EQ(richEditorPattern->operationRecords_.size(), start + 2);
}
/**
* @tc.name: HandleAIWrite001
* @tc.desc: test AddSpansAndReplacePlaceholder&SetSubSpansWithAIWrite
* @tc.type: FUNC
*/
HWTEST_F(RichEditorEditTestOneNg, HandleAIWrite003, TestSize.Level1)
{
/**
* @tc.steps: step1. get richEditor controller
*/
ASSERT_NE(richEditorNode_, nullptr);
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
ASSERT_NE(richEditorPattern, nullptr);
auto richEditorController = richEditorPattern->GetRichEditorController();
ASSERT_NE(richEditorController, nullptr);
/**
* @tc.steps: step2. add span
*/
SymbolSpanOptions options1;
options1.symbolId = SYMBOL_ID;
TextSpanOptions options2;
options2.value = INIT_VALUE_1;
ImageSpanOptions options3;
options3.image = IMAGE_VALUE;
auto builderId1 = ElementRegister::GetInstance()->MakeUniqueId();
auto builderNode1 = FrameNode::GetOrCreateFrameNode(
V2::ROW_ETS_TAG, builderId1, []() { return AceType::MakeRefPtr<LinearLayoutPattern>(false); });
auto index1 = richEditorController->AddPlaceholderSpan(builderNode1, {});
EXPECT_EQ(index1, 0);
richEditorController->AddTextSpan(options2);
richEditorController->AddSymbolSpan(options1);
richEditorController->AddTextSpan(options2);
richEditorController->AddImageSpan(options3);
EXPECT_EQ(static_cast<int32_t>(richEditorNode_->GetChildren().size()), 5);
/**
* @tc.steps: step3. replace and recover placeholder for non-text.
*/
RefPtr<SpanString> spanString = AceType::MakeRefPtr<SpanString>("");
ASSERT_NE(spanString, nullptr);
richEditorPattern->SetSubSpansWithAIWrite(spanString, 0, 12);
auto spanStr = AceType::MakeRefPtr<SpanString>("test![id1]占位符![id2]");
richEditorPattern->textSelector_.Update(0, 10);
auto start = richEditorPattern->operationRecords_.size();
richEditorPattern->AddSpansAndReplacePlaceholder(spanStr);
EXPECT_EQ(richEditorPattern->operationRecords_.size(), start + 4);
}
/**
* @tc.name: GetTextBoxes001
* @tc.desc: test GetTextBoxes

View File

@ -1159,7 +1159,7 @@ HWTEST_F(RichEditorKeyboardShortcutTestNg, GetSelectArea101, TestSize.Level1)
TestParagraphRect paragraphRect = { .start = 0, .end = 6, .rects = { { 0.0, 10.0, 200.0, 200.0 } } };
TestParagraphItem paragraphItem = { .start = 0, .end = 6, .testParagraphRects = { paragraphRect } };
AddParagraph(paragraphItem);
richEditorPattern->textSelector_ = TextSelector(10, 50);
richEditorPattern->textSelector_ = TextSelector(0, 6);
richEditorPattern->contentRect_ = { 0.0, 10.0, 500.0, 500.0 };
richEditorPattern->isShowPlaceholder_ = true;
auto res = richEditorPattern->GetSelectArea();

View File

@ -1400,7 +1400,7 @@ HWTEST_F(RichEditorOverlayTestNg, HandleLevel001, TestSize.Level1)
*/
richEditorNode_->AddFrameNodeChangeInfoFlag(FRAME_NODE_CHANGE_START_SCROLL);
richEditorNode_->ProcessFrameNodeChangeFlag();
EXPECT_EQ(richEditorPattern->selectOverlay_->handleLevelMode_, HandleLevelMode::EMBED);
EXPECT_EQ(richEditorPattern->selectOverlay_->handleLevelMode_, HandleLevelMode::OVERLAY);
}
/**

View File

@ -169,6 +169,7 @@ HWTEST_F(ScrollControllerTestNg, AnimateTo004, TestSize.Level1)
EXPECT_TRUE(VerifyTickPosition(-200.f));
EXPECT_TRUE(VerifyTickPosition(-400.f));
EXPECT_TRUE(VerifyTickPosition(-VERTICAL_SCROLLABLE_DISTANCE));
EXPECT_TRUE(VerifyTickPosition(-800.f)); // Tick doesn't advance new animations created within the same tick
EXPECT_TRUE(VerifyTickPosition(-760.f));
EXPECT_TRUE(VerifyTickPosition(-720.f));
EXPECT_TRUE(VerifyTickPosition(-680.f));

View File

@ -492,4 +492,63 @@ HWTEST_F(TextFieldPatternTestThree, OnTextGestureSelectionUpdate001, TestSize.Le
pattern_->OnTextGestureSelectionUpdate(start, end, info);
EXPECT_FALSE(pattern_->magnifierController_);
}
/**
* @tc.name: HandleAIWrite001
* @tc.desc: test GetAIWriteInfo
* @tc.type: FUNC
*/
HWTEST_F(TextFieldPatternTestThree, HandleAIWrite001, TestSize.Level0)
{
/**
* @tc.steps: step1. create target node.
*/
CreateTextField(DEFAULT_TEXT);
GetFocus();
/**
* @tc.steps: step2. test GetAIWriteInfo
*/
pattern_->HandleSetSelection(5, 10, false);
auto selectController = pattern_->GetTextSelectController();
AIWriteInfo info;
pattern_->GetAIWriteInfo(info);
EXPECT_EQ(info.selectStart, 5);
EXPECT_EQ(info.selectEnd, 10);
EXPECT_EQ(info.selectLength, 5);
EXPECT_EQ(info.firstHandle, selectController->GetFirstHandleRect().ToString());
EXPECT_EQ(info.secondHandle, selectController->GetSecondHandleRect().ToString());
RefPtr<SpanString> spanString = SpanString::DecodeTlv(info.selectBuffer);
ASSERT_NE(spanString, nullptr);
auto textContent = spanString->GetString();
EXPECT_EQ(textContent.empty(), false);
}
/**
* @tc.name: HandleAIWrite001
* @tc.desc: test HandleOnAIWrite
* @tc.type: FUNC
*/
HWTEST_F(TextFieldPatternTestThree, HandleAIWrite002, TestSize.Level0)
{
/**
* @tc.steps: step1. create target node.
*/
CreateTextField(DEFAULT_TEXT);
GetFocus();
/**
* @tc.steps: step2. test HandleOnAIWrite
*/
pattern_->HandleSetSelection(0, 5, false);
pattern_->HandleOnAIWrite();
std::vector<uint8_t> buff;
auto spanStr = AceType::MakeRefPtr<SpanString>("dddd结果回填123456");
spanStr->EncodeTlv(buff);
pattern_->HandleAIWriteResult(0, 5, buff);
auto contentController = pattern_->GetTextContentController();
auto sentenceContent = contentController->GetSelectedValue(0, spanStr->GetLength());
ASSERT_EQ(sentenceContent, spanStr->GetString());
}
} // namespace OHOS::Ace::NG

View File

@ -18,6 +18,13 @@
#include "core/components_ng/property/property.h"
#include "core/components_ng/syntax/if_else_node.h"
#define protected public
#define private public
#include "core/components_ng/pattern/waterflow/layout/sliding_window/water_flow_layout_sw.h"
#include "core/components_ng/pattern/waterflow/layout/top_down/water_flow_layout_algorithm.h"
#undef protected
#undef private
namespace OHOS::Ace::NG {
// TEST non-segmented layout
@ -354,4 +361,27 @@ HWTEST_F(WaterFlowTestNg, Cache003, TestSize.Level1)
EXPECT_EQ(GetChildY(frameNode_, 35), -250.0f);
EXPECT_EQ(GetChildY(frameNode_, 34), -250.0f);
}
/**
* @tc.name: Remeasure001
* @tc.desc: Test triggering measure multiple times on the same Algo object
* @tc.type: FUNC
*/
HWTEST_F(WaterFlowTestNg, Remeasure001, TestSize.Level1)
{
WaterFlowModelNG model = CreateWaterFlow();
model.SetColumnsTemplate("1fr 1fr");
model.SetCachedCount(3);
CreateItemsInRepeat(50, [](int32_t i) { return i % 2 ? 100.0f : 200.0f; });
CreateDone();
auto algo = pattern_->GetCacheLayoutAlgo();
ASSERT_TRUE(algo);
algo->Measure(AceType::RawPtr(frameNode_));
if (auto swAlgo = AceType::DynamicCast<WaterFlowLayoutSW>(algo); swAlgo) {
EXPECT_EQ(swAlgo->itemsCrossSize_[0].size(), 2);
} else {
EXPECT_EQ(AceType::DynamicCast<WaterFlowLayoutAlgorithm>(algo)->itemsCrossSize_.size(), 2);
}
}
} // namespace OHOS::Ace::NG

View File

@ -550,6 +550,7 @@ HWTEST_F(WaterFlowScrollerTestNg, Refresh001, TestSize.Level1)
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_FALSE(pattern_->OutBoundaryCallback());
scrollable->HandleTouchUp();
scrollable->HandleDragEnd(info);
FlushLayoutTask(frameNode_);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "245.45px");
@ -559,12 +560,17 @@ HWTEST_F(WaterFlowScrollerTestNg, Refresh001, TestSize.Level1)
MockAnimationManager::GetInstance().TickByVelocity(200.0f);
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "245.45px");
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "445.45px");
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.ToString(), "245.45px");
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
}
/**

View File

@ -13,15 +13,13 @@
* limitations under the License.
*/
#include "test/mock/core/animation/mock_animation_manager.h"
#include "water_flow_item_maps.h"
#include "water_flow_test_ng.h"
#include "core/components_ng/pattern/refresh/refresh_model_ng.h"
#include "core/components_ng/pattern/waterflow/layout/sliding_window/water_flow_layout_info_sw.h"
#define private public
#include "test/mock/core/pipeline/mock_pipeline_context.h"
#undef private
namespace OHOS::Ace::NG {
class WaterFlowSWTest : public WaterFlowTestNg {
protected:
@ -324,7 +322,6 @@ HWTEST_F(WaterFlowSWTest, Update001, TestSize.Level1)
}
auto secObj = pattern_->GetOrCreateWaterFlowSections();
secObj->ChangeData(0, 0, SECTION_11);
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
CreateDone();
EXPECT_EQ(GetChildY(frameNode_, 3), 325.0f);
@ -336,7 +333,6 @@ HWTEST_F(WaterFlowSWTest, Update001, TestSize.Level1)
section.itemsCount += 4;
section.crossCount = 3;
secObj->ChangeData(1, 1, { section });
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
frameNode_->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 5.0f);
@ -350,7 +346,6 @@ HWTEST_F(WaterFlowSWTest, Update001, TestSize.Level1)
section.itemsCount -= 4;
section.crossCount = 2;
secObj->ChangeData(1, 1, { section });
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
for (int i = 0; i < 4; ++i) {
frameNode_->RemoveChildAtIndex(3);
}
@ -591,7 +586,6 @@ HWTEST_F(WaterFlowSWTest, Misaligned002, TestSize.Level1)
}
auto secObj = pattern_->GetOrCreateWaterFlowSections();
secObj->ChangeData(0, 0, SECTION_10);
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
CreateDone();
EXPECT_FALSE(info_->IsMisaligned());
@ -806,7 +800,6 @@ HWTEST_F(WaterFlowSWTest, ResetSections001, TestSize.Level1)
CreateWaterFlowItems(60);
auto secObj = pattern_->GetOrCreateWaterFlowSections();
secObj->ChangeData(0, 0, SECTION_5);
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
CreateDone();
UpdateCurrentOffset(-205.0f);
@ -837,7 +830,6 @@ HWTEST_F(WaterFlowSWTest, ChangeLayoutMode001, TestSize.Level1)
CreateWaterFlowItems(60);
auto secObj = pattern_->GetOrCreateWaterFlowSections();
secObj->ChangeData(0, 0, SECTION_5);
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
CreateDone();
UpdateCurrentOffset(-205.0f);
@ -956,7 +948,6 @@ HWTEST_F(WaterFlowSWTest, NotifyDataChange002, TestSize.Level1)
secObj->ChangeData(2, 2, newSections);
AddItems(2);
info_->NotifyDataChange(5, 2);
MockPipelineContext::GetCurrent()->FlushBuildFinishCallbacks();
EXPECT_EQ(info_->newStartIndex_, 13);
/**
@ -1038,4 +1029,65 @@ HWTEST_F(WaterFlowSWTest, Cache002, TestSize.Level1)
EXPECT_EQ(GetChildY(frameNode_, 22), -440.0f);
EXPECT_FALSE(GetChildFrameNode(frameNode_, 22)->IsActive());
}
/**
* @tc.name: Refresh002
* @tc.desc: Test WaterFlow nested in refresh. Currently have different friction from TOP_DOWN mode
* @tc.type: FUNC
*/
HWTEST_F(WaterFlowSWTest, Refresh002, TestSize.Level1)
{
MockAnimationManager::GetInstance().SetTicks(1);
MockAnimationManager::GetInstance().Reset();
RefreshModelNG refreshModel;
refreshModel.Create();
auto refreshNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
auto model = CreateWaterFlow();
model.SetColumnsTemplate("1fr 1fr");
model.SetEdgeEffect(EdgeEffect::SPRING, true);
CreateWaterFlowItems(3);
CreateDone();
GestureEvent info;
info.SetMainVelocity(-1200.f);
info.SetMainDelta(-100.f);
auto scrollable = pattern_->GetScrollableEvent()->GetScrollable();
scrollable->HandleTouchDown();
scrollable->HandleDragStart(info);
scrollable->HandleDragUpdate(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -19.849327);
EXPECT_TRUE(pattern_->OutBoundaryCallback());
scrollable->HandleTouchUp();
scrollable->HandleDragEnd(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -38.809074);
MockAnimationManager::GetInstance().TickByVelocity(-100.0f);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -138.80908);
// swipe in the opposite direction
info.SetMainVelocity(1200.f);
info.SetMainDelta(100.f);
scrollable->HandleTouchDown();
scrollable->HandleDragStart(info);
scrollable->HandleDragUpdate(info);
FlushLayoutTask(frameNode_);
scrollable->HandleTouchUp();
scrollable->HandleDragEnd(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -91.843094);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 0.0f);
MockAnimationManager::GetInstance().TickByVelocity(1000.0f);
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 800);
MockAnimationManager::GetInstance().Tick();
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
EXPECT_TRUE(MockAnimationManager::GetInstance().AllFinished());
}
} // namespace OHOS::Ace::NG

View File

@ -13,8 +13,10 @@
* limitations under the License.
*/
#include "test/mock/core/animation/mock_animation_manager.h"
#include "water_flow_test_ng.h"
#include "core/components_ng/pattern/refresh/refresh_model_ng.h"
#include "core/components_ng/pattern/waterflow/layout/top_down/water_flow_layout_info.h"
#include "core/components_ng/pattern/waterflow/water_flow_item_model_ng.h"
@ -652,4 +654,69 @@ HWTEST_F(WaterFlowTestNg, Cache002, TestSize.Level1)
EXPECT_EQ(GetChildY(frameNode_, 22), -340.0f);
EXPECT_FALSE(GetChildFrameNode(frameNode_, 22)->IsActive());
}
/**
* @tc.name: Refresh002
* @tc.desc: Test WaterFlow nested in refresh. Currently have different friction from SW mode
* @tc.type: FUNC
*/
HWTEST_F(WaterFlowTestNg, Refresh002, TestSize.Level1)
{
MockAnimationManager::GetInstance().SetTicks(1);
MockAnimationManager::GetInstance().Reset();
RefreshModelNG refreshModel;
refreshModel.Create();
auto refreshNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->GetMainElementNode());
auto model = CreateWaterFlow();
model.SetColumnsTemplate("1fr 1fr");
model.SetEdgeEffect(EdgeEffect::SPRING, true);
CreateWaterFlowItems(3);
CreateDone();
GestureEvent info;
info.SetMainVelocity(-1200.f);
info.SetMainDelta(-100.f);
auto scrollable = pattern_->GetScrollableEvent()->GetScrollable();
scrollable->HandleTouchDown();
scrollable->HandleDragStart(info);
scrollable->HandleDragUpdate(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -31.505754);
EXPECT_TRUE(pattern_->OutBoundaryCallback());
scrollable->HandleTouchUp();
scrollable->HandleDragEnd(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -60.800022);
MockAnimationManager::GetInstance().TickByVelocity(-100.0f);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -160.80002);
// swipe in the opposite direction
info.SetMainVelocity(1200.f);
info.SetMainDelta(200.f);
scrollable->HandleTouchDown();
scrollable->HandleDragStart(info);
scrollable->HandleDragUpdate(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -129.28963);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 0.0f);
scrollable->HandleTouchUp();
scrollable->HandleDragEnd(info);
FlushLayoutTask(frameNode_);
EXPECT_FLOAT_EQ(GetChildY(frameNode_, 0), -97.779236);
MockAnimationManager::GetInstance().TickByVelocity(1000.0f);
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 800);
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
MockAnimationManager::GetInstance().Tick();
FlushLayoutTask(frameNode_);
EXPECT_EQ(GetChildY(frameNode_, 0), 0.0f);
EXPECT_EQ(frameNode_->GetRenderContext()->GetTransformTranslate()->y.Value(), 64);
EXPECT_TRUE(MockAnimationManager::GetInstance().AllFinished());
}
} // namespace OHOS::Ace::NG