diff --git a/frameworks/bridge/declarative_frontend/ark_node/src/frame_node.ts b/frameworks/bridge/declarative_frontend/ark_node/src/frame_node.ts index 7f1d0ade5b3dad34c95a03028a23edeb4ee7c9b3..2d7c68aad289c461147dd154db43743dd9dd232b 100644 --- a/frameworks/bridge/declarative_frontend/ark_node/src/frame_node.ts +++ b/frameworks/bridge/declarative_frontend/ark_node/src/frame_node.ts @@ -289,10 +289,30 @@ class FrameNode { return { x: position[0], y: position[1] }; } + getPositionToScreen(): Position { + const position = getUINativeModule().frameNode.getPositionToScreen(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } + getPositionToWindow(): Position { const position = getUINativeModule().frameNode.getPositionToWindow(this.getNodePtr()); return { x: position[0], y: position[1] }; } + + getPositionToParentWithTransform(): Position { + const position = getUINativeModule().frameNode.getPositionToParentWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } + + getPositionToScreenWithTransform(): Position { + const position = getUINativeModule().frameNode.getPositionToScreenWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } + + getPositionToWindowWithTransform(): Position { + const position = getUINativeModule().frameNode.getPositionToWindowWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } getMeasuredSize(): Size { const size = getUINativeModule().frameNode.getMeasuredSize(this.getNodePtr()); diff --git a/frameworks/bridge/declarative_frontend/engine/jsXNode.js b/frameworks/bridge/declarative_frontend/engine/jsXNode.js index 933795b02ec445006466c3c1302068fc2d9dd4bf..be71ae70af67244fdcdbf706fd760d2f295a34c4 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsXNode.js +++ b/frameworks/bridge/declarative_frontend/engine/jsXNode.js @@ -671,10 +671,26 @@ class FrameNode { const position = getUINativeModule().frameNode.getPositionToParent(this.getNodePtr()); return { x: position[0], y: position[1] }; } + getPositionToScreen() { + const position = getUINativeModule().frameNode.getPositionToScreen(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } getPositionToWindow() { const position = getUINativeModule().frameNode.getPositionToWindow(this.getNodePtr()); return { x: position[0], y: position[1] }; } + getPositionToParentWithTransform() { + const position = getUINativeModule().frameNode.getPositionToParentWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } + getPositionToScreenWithTransform() { + const position = getUINativeModule().frameNode.getPositionToScreenWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } + getPositionToWindowWithTransform() { + const position = getUINativeModule().frameNode.getPositionToWindowWithTransform(this.getNodePtr()); + return { x: position[0], y: position[1] }; + } getMeasuredSize() { const size = getUINativeModule().frameNode.getMeasuredSize(this.getNodePtr()); return { width: size[0], height: size[1] }; diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_api_impl_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_api_impl_bridge.cpp index 012b33c5870a04852d380d229b830cb41d8d6f88..23a817a37d9873c3013a2bea7cd6a50398d7341c 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_api_impl_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_api_impl_bridge.cpp @@ -2628,8 +2628,16 @@ void ArkUINativeModule::RegisterFrameNodeAttributes(Local obje panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetIdByNodePtr)); frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToParent"), panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToParent)); + frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToScreen"), + panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToScreen)); frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToWindow"), panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToWindow)); + frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToParentWithTransform"), + panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToParentWithTransform)); + frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToScreenWithTransform"), + panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToScreenWithTransform)); + frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getPositionToWindowWithTransform"), + panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetPositionToWindowWithTransform)); frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getMeasuredSize"), panda::FunctionRef::New(const_cast(vm), FrameNodeBridge::GetMeasuredSize)); frameNode->Set(vm, panda::StringRef::NewFromUtf8(vm, "getLayoutPosition"), diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp index 347ea526f65d3ccd058ff1061371dec10c9a5222..4d4e326159681d79f20b351281f4e4ec17196e0c 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp @@ -345,6 +345,21 @@ ArkUINativeModuleValue FrameNodeBridge::GetPositionToParent(ArkUIRuntimeCallInfo Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, parentOffset[1])); return valueArray; } +ArkUINativeModuleValue FrameNodeBridge::GetPositionToScreen(ArkUIRuntimeCallInfo* runtimeCallInfo) +{ + EcmaVM* vm = runtimeCallInfo->GetVM(); + CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm)); + Local firstArg = runtimeCallInfo->GetCallArgRef(0); + CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm)); + auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); + Local valueArray = Framework::ArrayRef::New(vm, 2); + ArkUI_Float32 screenPosition[2]; + GetArkUINodeModifiers()->getFrameNodeModifier()->getPositionToScreen(nativeNode, screenPosition); + CHECK_NULL_RETURN(screenPosition, panda::JSValueRef::Undefined(vm)); + Framework::ArrayRef::SetValueAt(vm, valueArray, 0, panda::NumberRef::New(vm, screenPosition[0])); + Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, screenPosition[1])); + return valueArray; +} ArkUINativeModuleValue FrameNodeBridge::GetPositionToWindow(ArkUIRuntimeCallInfo* runtimeCallInfo) { EcmaVM* vm = runtimeCallInfo->GetVM(); @@ -360,6 +375,51 @@ ArkUINativeModuleValue FrameNodeBridge::GetPositionToWindow(ArkUIRuntimeCallInfo Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, windowOffset[1])); return valueArray; } +ArkUINativeModuleValue FrameNodeBridge::GetPositionToParentWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo) +{ + EcmaVM* vm = runtimeCallInfo->GetVM(); + CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm)); + Local firstArg = runtimeCallInfo->GetCallArgRef(0); + CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm)); + auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); + Local valueArray = Framework::ArrayRef::New(vm, 2); + ArkUI_Float32 parentPosition[2]; + GetArkUINodeModifiers()->getFrameNodeModifier()->getPositionToParentWithTransform(nativeNode, parentPosition); + CHECK_NULL_RETURN(parentPosition, panda::JSValueRef::Undefined(vm)); + Framework::ArrayRef::SetValueAt(vm, valueArray, 0, panda::NumberRef::New(vm, parentPosition[0])); + Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, parentPosition[1])); + return valueArray; +} +ArkUINativeModuleValue FrameNodeBridge::GetPositionToScreenWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo) +{ + EcmaVM* vm = runtimeCallInfo->GetVM(); + CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm)); + Local firstArg = runtimeCallInfo->GetCallArgRef(0); + CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm)); + auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); + Local valueArray = Framework::ArrayRef::New(vm, 2); + ArkUI_Float32 screenPosition[2]; + GetArkUINodeModifiers()->getFrameNodeModifier()->getPositionToScreenWithTransform(nativeNode, screenPosition); + CHECK_NULL_RETURN(screenPosition, panda::JSValueRef::Undefined(vm)); + Framework::ArrayRef::SetValueAt(vm, valueArray, 0, panda::NumberRef::New(vm, screenPosition[0])); + Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, screenPosition[1])); + return valueArray; +} +ArkUINativeModuleValue FrameNodeBridge::GetPositionToWindowWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo) +{ + EcmaVM* vm = runtimeCallInfo->GetVM(); + CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm)); + Local firstArg = runtimeCallInfo->GetCallArgRef(0); + CHECK_NULL_RETURN(!firstArg.IsNull(), panda::JSValueRef::Undefined(vm)); + auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); + Local valueArray = Framework::ArrayRef::New(vm, 2); + ArkUI_Float32 windowPosition[2]; + GetArkUINodeModifiers()->getFrameNodeModifier()->getPositionToWindowWithTransform(nativeNode, windowPosition); + CHECK_NULL_RETURN(windowPosition, panda::JSValueRef::Undefined(vm)); + Framework::ArrayRef::SetValueAt(vm, valueArray, 0, panda::NumberRef::New(vm, windowPosition[0])); + Framework::ArrayRef::SetValueAt(vm, valueArray, 1, panda::NumberRef::New(vm, windowPosition[1])); + return valueArray; +} ArkUINativeModuleValue FrameNodeBridge::GetMeasuredSize(ArkUIRuntimeCallInfo* runtimeCallInfo) { EcmaVM* vm = runtimeCallInfo->GetVM(); diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h index 0002a9a94ab69663c77b3e72ed8582fe092a0e2c..63edff3d55f1295fae486727907702f9be5c55f3 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.h @@ -47,7 +47,11 @@ public: static ArkUINativeModuleValue GetParent(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetIdByNodePtr(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetPositionToParent(ArkUIRuntimeCallInfo* runtimeCallInfo); + static ArkUINativeModuleValue GetPositionToScreen(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetPositionToWindow(ArkUIRuntimeCallInfo* runtimeCallInfo); + static ArkUINativeModuleValue GetPositionToParentWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo); + static ArkUINativeModuleValue GetPositionToScreenWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo); + static ArkUINativeModuleValue GetPositionToWindowWithTransform(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetMeasuredSize(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetLayoutPosition(ArkUIRuntimeCallInfo* runtimeCallInfo); static ArkUINativeModuleValue GetConfigBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo); diff --git a/frameworks/core/components_ng/base/frame_node.cpp b/frameworks/core/components_ng/base/frame_node.cpp index e1feef1364ba5e38ae96c99982d6c05ce3d3c833..37063ce477120141172df92f3f0ca03075eb0673 100644 --- a/frameworks/core/components_ng/base/frame_node.cpp +++ b/frameworks/core/components_ng/base/frame_node.cpp @@ -2340,6 +2340,60 @@ OffsetF FrameNode::GetOffsetRelativeToWindow() const return offset; } +OffsetF FrameNode::GetPositionToScreen() +{ + auto offsetCurrent = GetOffsetRelativeToWindow(); + auto pipelineContext = GetContext(); + CHECK_NULL_RETURN(pipelineContext, OffsetF()); + auto windowOffset = pipelineContext->GetCurrentWindowRect().GetOffset(); + OffsetF offset(windowOffset.GetX() + offsetCurrent.GetX(), windowOffset.GetY() + offsetCurrent.GetY()); + return offset; +} + +OffsetF FrameNode::GetPositionToParentWithTransform() +{ + auto context = GetRenderContext(); + CHECK_NULL_RETURN(context, OffsetF()); + auto offset = context->GetPaintRectWithoutTransform().GetOffset(); + PointF pointTmp(offset.GetX(), offset.GetY()); + context->GetPointTransform(pointTmp); + offset.SetX(pointTmp.GetX()); + offset.SetY(pointTmp.GetY()); + return offset; +} + +OffsetF FrameNode::GetPositionToScreenWithTransform() +{ + auto pipelineContext = GetContext(); + CHECK_NULL_RETURN(pipelineContext, OffsetF()); + auto windowOffset = pipelineContext->GetCurrentWindowRect().GetOffset(); + OffsetF nodeOffset = GetPositionToWindowWithTransform(); + OffsetF offset(windowOffset.GetX() + nodeOffset.GetX(), windowOffset.GetY() + nodeOffset.GetY()); + return offset; +} + +OffsetF FrameNode::GetPositionToWindowWithTransform() +{ + auto context = GetRenderContext(); + CHECK_NULL_RETURN(context, OffsetF()); + auto offset = context->GetPaintRectWithoutTransform().GetOffset(); + PointF pointNode(offset.GetX(), offset.GetY()); + context->GetPointTransform(pointNode); + auto parent = GetAncestorNodeOfFrame(true); + while (parent) { + auto parentRenderContext = parent->GetRenderContext(); + offset = parentRenderContext->GetPaintRectWithoutTransform().GetOffset(); + PointF pointTmp(offset.GetX(), offset.GetY()); + parentRenderContext->GetPointTransform(pointTmp); + pointNode.SetX(pointTmp.GetX() + pointNode.GetX()); + pointNode.SetY(pointTmp.GetY() + pointNode.GetY()); + parent = parent->GetAncestorNodeOfFrame(true); + } + offset.SetX(pointNode.GetX()); + offset.SetY(pointNode.GetY()); + return offset; +} + RectF FrameNode::GetTransformRectRelativeToWindow() const { auto context = GetRenderContext(); diff --git a/frameworks/core/components_ng/base/frame_node.h b/frameworks/core/components_ng/base/frame_node.h index 90615ddbd88f7cb5babeb7a0c1d1c34ca0730753..ea42cbed72dc0f6cd6e5094e26880eda5d498032 100644 --- a/frameworks/core/components_ng/base/frame_node.h +++ b/frameworks/core/components_ng/base/frame_node.h @@ -383,6 +383,14 @@ public: OffsetF GetOffsetRelativeToWindow() const; + OffsetF GetPositionToScreen(); + + OffsetF GetPositionToParentWithTransform(); + + OffsetF GetPositionToScreenWithTransform(); + + OffsetF GetPositionToWindowWithTransform(); + OffsetF GetTransformRelativeOffset() const; RectF GetTransformRectRelativeToWindow() const; diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 16fa1f04da7362bbb124534c2d76618ea43ab286..ec9b82a3e29d9416f95fcab74ae446a94ad29018 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -3331,7 +3331,11 @@ struct ArkUIFrameNodeModifier { ArkUINodeHandle (*getParent)(ArkUINodeHandle node); ArkUI_Int32 (*getIdByNodePtr)(ArkUINodeHandle node); void (*getPositionToParent)(ArkUINodeHandle node, ArkUI_Float32* parentOffset); + void (*getPositionToScreen)(ArkUINodeHandle node, ArkUI_Float32* screenPosition); void (*getPositionToWindow)(ArkUINodeHandle node, ArkUI_Float32* windowOffset); + void (*getPositionToParentWithTransform)(ArkUINodeHandle node, ArkUI_Float32* parentPosition); + void (*getPositionToScreenWithTransform)(ArkUINodeHandle node, ArkUI_Float32* screenPosition); + void (*getPositionToWindowWithTransform)(ArkUINodeHandle node, ArkUI_Float32* windowPosition); ArkUI_Float32* (*getMeasuredSize)(ArkUINodeHandle node); ArkUI_Float32* (*getLayoutPosition)(ArkUINodeHandle node); ArkUI_CharPtr (*getInspectorId)(ArkUINodeHandle node); diff --git a/frameworks/core/interfaces/native/node/frame_node_modifier.cpp b/frameworks/core/interfaces/native/node/frame_node_modifier.cpp index c92233423a6f97baceeb4a144fbf33ee23e04568..e64eb5c8a85bd919ab71cb15c8c5f1e9d4d58a67 100644 --- a/frameworks/core/interfaces/native/node/frame_node_modifier.cpp +++ b/frameworks/core/interfaces/native/node/frame_node_modifier.cpp @@ -195,6 +195,15 @@ void GetPositionToParent(ArkUINodeHandle node, ArkUI_Float32* parentOffset) parentOffset[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); } +void GetPositionToScreen(ArkUINodeHandle node, ArkUI_Float32* screenPosition) +{ + auto* currentNode = reinterpret_cast(node); + CHECK_NULL_VOID(currentNode); + auto offset = currentNode->GetPositionToScreen(); + screenPosition[0] = PipelineBase::Px2VpWithCurrentDensity(offset.GetX()); + screenPosition[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); +} + void GetPositionToWindow(ArkUINodeHandle node, ArkUI_Float32* windowOffset) { auto* currentNode = reinterpret_cast(node); @@ -204,6 +213,33 @@ void GetPositionToWindow(ArkUINodeHandle node, ArkUI_Float32* windowOffset) windowOffset[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); } +void GetPositionToParentWithTransform(ArkUINodeHandle node, ArkUI_Float32* parentPosition) +{ + auto* currentNode = reinterpret_cast(node); + CHECK_NULL_VOID(currentNode); + auto offset = currentNode->GetPositionToParentWithTransform(); + parentPosition[0] = PipelineBase::Px2VpWithCurrentDensity(offset.GetX()); + parentPosition[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); +} + +void GetPositionToScreenWithTransform(ArkUINodeHandle node, ArkUI_Float32* screenPosition) +{ + auto* currentNode = reinterpret_cast(node); + CHECK_NULL_VOID(currentNode); + auto offset = currentNode->GetPositionToScreenWithTransform(); + screenPosition[0] = PipelineBase::Px2VpWithCurrentDensity(offset.GetX()); + screenPosition[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); +} + +void GetPositionToWindowWithTransform(ArkUINodeHandle node, ArkUI_Float32* windowPosition) +{ + auto* currentNode = reinterpret_cast(node); + CHECK_NULL_VOID(currentNode); + auto offset = currentNode->GetPositionToWindowWithTransform(); + windowPosition[0] = PipelineBase::Px2VpWithCurrentDensity(offset.GetX()); + windowPosition[1] = PipelineBase::Px2VpWithCurrentDensity(offset.GetY()); +} + ArkUI_Float32* GetMeasuredSize(ArkUINodeHandle node) { auto* currentNode = reinterpret_cast(node); @@ -335,9 +371,10 @@ const ArkUIFrameNodeModifier* GetFrameNodeModifier() static const ArkUIFrameNodeModifier modifier = { IsModifiable, CreateFrameNode, InvalidateInFrameNode, AppendChildInFrameNode, InsertChildAfterInFrameNode, RemoveChildInFrameNode, ClearChildrenInFrameNode, GetChildrenCount, GetChild, GetFirst, GetNextSibling, GetPreviousSibling, GetParent, GetIdByNodePtr, - GetPositionToParent, GetPositionToWindow, GetMeasuredSize, GetLayoutPosition, GetInspectorId, GetNodeType, - IsVisible, IsAttached, GetInspectorInfo, GetFrameNodeById, GetFrameNodeByUniqueId, GetFrameNodeByKey, - PropertyUpdate, GetLast }; + GetPositionToParent, GetPositionToScreen, GetPositionToWindow, GetPositionToParentWithTransform, + GetPositionToScreenWithTransform, GetPositionToWindowWithTransform, GetMeasuredSize, GetLayoutPosition, + GetInspectorId, GetNodeType, IsVisible, IsAttached, GetInspectorInfo, GetFrameNodeById, GetFrameNodeByUniqueId, + GetFrameNodeByKey, PropertyUpdate, GetLast }; return &modifier; } } // namespace NodeModifier diff --git a/test/unittest/core/base/frame_node_test_ng.cpp b/test/unittest/core/base/frame_node_test_ng.cpp index 5b43c8ea3d25dee776bcccc1abec16cf7003078b..ee32a14d40377c602ee46a82c5beac214c7617a5 100644 --- a/test/unittest/core/base/frame_node_test_ng.cpp +++ b/test/unittest/core/base/frame_node_test_ng.cpp @@ -2706,4 +2706,56 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTestNg0040, TestSize.Level1) std::set allowDrop = frameNode->GetAllowDrop(); EXPECT_TRUE(allowDrop.empty()); } + +/** + * @tc.name: FrameNodeTestNg_GetPositionToScreen001 + * @tc.desc: Test frame node method GetPositionToScreen + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, GetPositionToScreen001, TestSize.Level1) +{ + OffsetF Offset = { 0, 0 }; + FRAME_NODE2->SetParent(FRAME_NODE3); + auto screenOffset = FRAME_NODE2->GetPositionToScreen(); + EXPECT_EQ(screenOffset, Offset); +} + +/** + * @tc.name: FrameNodeTestNg_GetPositionToParentWithTransform001 + * @tc.desc: Test frame node method GetPositionToParentWithTransform + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, GetPositionToParentWithTransform001, TestSize.Level1) +{ + OffsetF Offset = { 0, 0 }; + FRAME_NODE2->SetParent(FRAME_NODE3); + auto parentOffsetWithTransform = FRAME_NODE2->GetPositionToParentWithTransform(); + EXPECT_EQ(parentOffsetWithTransform, Offset); +} + +/** + * @tc.name: FrameNodeTestNg_GetPositionToParentWithTransform001 + * @tc.desc: Test frame node method GetPositionToParentWithTransform + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, GetPositionToScreenWithTransform001, TestSize.Level1) +{ + OffsetF Offset = { 0, 0 }; + FRAME_NODE2->SetParent(FRAME_NODE3); + auto screenOffsetWithTransform = FRAME_NODE2->GetPositionToScreenWithTransform(); + EXPECT_EQ(screenOffsetWithTransform, Offset); +} + +/** + * @tc.name: FrameNodeTestNg_GetPositionToWindowWithTransform001 + * @tc.desc: Test frame node method GetPositionToWindowWithTransform + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, GetPositionToWindowWithTransform001, TestSize.Level1) +{ + OffsetF Offset = { 0, 0 }; + FRAME_NODE2->SetParent(FRAME_NODE3); + auto windowOffsetWithTransform = FRAME_NODE2->GetPositionToWindowWithTransform(); + EXPECT_EQ(windowOffsetWithTransform, Offset); +} } // namespace OHOS::Ace::NG