From 53242fcfb9e83e5314bb24d5c779c912b6461d07 Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Fri, 27 Jun 2025 16:19:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Etdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangchongtao --- test/unittest/core/base/BUILD.gn | 1 + .../unittest/core/base/frame_node_test_ng.cpp | 49 -- .../core/base/frame_node_test_ng_coverage.cpp | 23 - .../core/base/frame_node_test_ng_dump.cpp | 435 ++++++++++++++++++ .../core/base/frame_node_test_ng_new.cpp | 112 ----- 5 files changed, 436 insertions(+), 184 deletions(-) create mode 100644 test/unittest/core/base/frame_node_test_ng_dump.cpp diff --git a/test/unittest/core/base/BUILD.gn b/test/unittest/core/base/BUILD.gn index 1455f8429e0..f2f34118797 100644 --- a/test/unittest/core/base/BUILD.gn +++ b/test/unittest/core/base/BUILD.gn @@ -36,6 +36,7 @@ ace_unittest("frame_node_test_ng") { "frame_node_test_ng_coverage_new.cpp", "frame_node_test_ng_new.cpp", "frame_node_test_ng_v3.cpp", + "frame_node_test_ng_dump.cpp", ] } diff --git a/test/unittest/core/base/frame_node_test_ng.cpp b/test/unittest/core/base/frame_node_test_ng.cpp index 47f690f30a5..bff72768e11 100644 --- a/test/unittest/core/base/frame_node_test_ng.cpp +++ b/test/unittest/core/base/frame_node_test_ng.cpp @@ -1510,55 +1510,6 @@ HWTEST_F(FrameNodeTestNg, SwapDirtyLayoutWrapperOnMainThread040, TestSize.Level1 EXPECT_TRUE(frameNode->GetOrCreateEventHub()->GetOrCreateFocusHub()->IsCurrentFocus()); } -/** - * @tc.name: FrameNodeTouchTest047 - * @tc.desc: Test method GeometryNodeToJsonValue - * @tc.type: FUNC - */ -HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest047, TestSize.Level1) -{ - /** - * @tc.steps: step1. construct parameters. - */ - std::unique_ptr value = JsonUtil::Create(true); - - /** - * @tc.steps: step2. construct parameters. - * @tc.expected: expect cover branch layoutProperty_ is nullptr. - */ - FRAME_NODE2->GeometryNodeToJsonValue(value, filter); - EXPECT_EQ(FRAME_NODE2->layoutProperty_, nullptr); - - /** - * @tc.steps: step3. set layoutProperty_ and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch layoutProperty_ is not nullptr. - */ - auto layoutProperty = AceType::MakeRefPtr(); - FRAME_NODE2->layoutProperty_ = layoutProperty; - FRAME_NODE2->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(FRAME_NODE2->layoutProperty_, nullptr); - - /** - * @tc.steps: step4. set calcLayoutConstraint_ and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch calcLayoutConstraint_ is not nullptr. - */ - FRAME_NODE2->layoutProperty_->calcLayoutConstraint_ = std::make_unique(); - - FRAME_NODE2->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(FRAME_NODE2->layoutProperty_->calcLayoutConstraint_, nullptr); - - /** - * @tc.steps: step5. set selfIdealSize and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch selfIdealSize has value. - */ - std::optional len = CalcLength("auto"); - FRAME_NODE2->layoutProperty_->calcLayoutConstraint_->selfIdealSize = CalcSize(len, len); - FRAME_NODE2->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(FRAME_NODE2->renderContext_, nullptr); - - FRAME_NODE2->layoutProperty_ = nullptr; -} - /** * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback048 * @tc.desc: Test frame node method diff --git a/test/unittest/core/base/frame_node_test_ng_coverage.cpp b/test/unittest/core/base/frame_node_test_ng_coverage.cpp index 0d25efc0dca..97f146a9bb5 100755 --- a/test/unittest/core/base/frame_node_test_ng_coverage.cpp +++ b/test/unittest/core/base/frame_node_test_ng_coverage.cpp @@ -561,29 +561,6 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue02, TestSize.Level1) EXPECT_FALSE(jsonValue->GetBool("enabled", false)); } -/** - * @tc.name: FrameNodeGeometryNodeToJsonValue01 - * @tc.desc: Test the function GeometryNodeToJsonValue - * @tc.type: FUNC - */ -HWTEST_F(FrameNodeTestNg, FrameNodeGeometryNodeToJsonValue01, TestSize.Level1) -{ - /** - * @tc.steps: step1. create frameNode. - */ - auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr(), true); - EXPECT_NE(frameNode->pattern_, nullptr); - - /** - * @tc.steps: step2. call the function GeometryNodeToJsonValue. - */ - InspectorFilter testFilter; - auto jsonValue = std::make_unique(); - testFilter.AddFilterAttr("focusable"); - frameNode->GeometryNodeToJsonValue(jsonValue, testFilter); - EXPECT_FALSE(jsonValue->GetBool("enabled", false)); -} - /** * @tc.name: FrameNodeToTreeJson01 * @tc.desc: Test the function ToTreeJson diff --git a/test/unittest/core/base/frame_node_test_ng_dump.cpp b/test/unittest/core/base/frame_node_test_ng_dump.cpp new file mode 100644 index 00000000000..b949dbf92e3 --- /dev/null +++ b/test/unittest/core/base/frame_node_test_ng_dump.cpp @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "test/unittest/core/base/frame_node_test_ng.h" + +#include "base/memory/ace_type.h" +#include "base/memory/referenced.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Ace::NG { + +/** + * @tc.name: FrameNodeTestNgDumpPadding001 + * @tc.desc: Test DumpPadding. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeTestNgDumpPadding001, TestSize.Level1) +{ + /** + * @tc.steps: step1. initialization frameNode. + */ + auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr(), true); + std::unique_ptr json = JsonUtil::Create(true); + auto testPadding = std::make_unique(); + + /** + * @tc.steps: step2. Generate JSON using default PaddingProperty + * @tc.expected: step2. get the JsonValue is "". + */ + + frameNode->DumpPadding(testPadding, "padding", json); + EXPECT_EQ(json->GetString("padding"), ""); +} + +/** + * @tc.name: FrameNodeTestNgDumpPadding002 + * @tc.desc: Test DumpPadding. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeTestNgDumpPadding002, TestSize.Level1) +{ + /** + * @tc.steps: step1. initialization frameNode. + */ + auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr(), true); + std::unique_ptr json = JsonUtil::Create(true); + auto testPadding = std::make_unique(); + + /** + * @tc.steps: step2. Give PaddingProperty bottom a new value. + */ + testPadding->bottom = CalcLength(10.0f); + + /** + * @tc.steps: step3. Execute DumpPadding. + * @tc.expected: step3. get the JsonValue is "[NA,NA,NA,10.00px]". + */ + + frameNode->DumpPadding(testPadding, "padding1", json); + EXPECT_EQ(json->GetString("padding1"), "[NA,NA,NA,10.00px]"); + + /** + * @tc.steps: step4. Give PaddingProperty top a new value. + */ + testPadding->top = CalcLength(10.0f); + + /** + * @tc.steps: step5. Execute DumpPadding. + * @tc.expected: step5. get the JsonValue is "[NA,NA,20.00px,10.00px]". + */ + + frameNode->DumpPadding(testPadding, "padding2", json); + EXPECT_EQ(json->GetString("padding2"), "[NA,NA,10.00px,10.00px]"); + + /** + * @tc.steps: step6. Give PaddingProperty right a new value. + */ + testPadding->right = CalcLength(10.0f); + + /** + * @tc.steps: step7. Execute DumpPadding. + * @tc.expected: step7. get the JsonValue is "[NA,10.00px,10.00px,10.00px]". + */ + + frameNode->DumpPadding(testPadding, "padding3", json); + EXPECT_EQ(json->GetString("padding3"), "[NA,10.00px,10.00px,10.00px]"); + + /** + * @tc.steps: step8. Give PaddingProperty left a new value. + */ + testPadding->left = CalcLength(10.0f); + + /** + * @tc.steps: step9. Execute DumpPadding. + * @tc.expected: step9. get the JsonValue is "[10.00px,10.00px,10.00px,10.00px]". + */ + + frameNode->DumpPadding(testPadding, "padding4", json); + EXPECT_EQ(json->GetString("padding4"), "[10.00px,10.00px,10.00px,10.00px]"); +} + +/** + * @tc.name: FrameNodeTestNgDumpBorder001 + * @tc.desc: Test DumpBorder. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeTestNgDumpBorder001, TestSize.Level1) +{ + /** + * @tc.steps: step1. initialization frameNode. + */ + auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr(), true); + std::unique_ptr json = JsonUtil::Create(true); + auto testBorder = std::make_unique(); + + /** + * @tc.steps: step2. Generate JSON using default BorderWidthProperty + * @tc.expected: step2. get the JsonValue is "". + */ + + frameNode->DumpBorder(testBorder, "border", json); + EXPECT_EQ(json->GetString("border"), ""); +} + +/** + * @tc.name: FrameNodeTestNgDumpBorder002 + * @tc.desc: Test DumpBorder. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeTestNgDumpBorder002, TestSize.Level1) +{ + /** + * @tc.steps: step1. initialization frameNode. + */ + auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr(), true); + std::unique_ptr json = JsonUtil::Create(true); + auto testBorder = std::make_unique(); + + /** + * @tc.steps: step2. Give BorderWidthProperty a new value. + */ + testBorder->bottomDimen = Dimension(10.0f); + + /** + * @tc.steps: step3. Execute DumpPadding. + * @tc.expected: step3. get the JsonValue is "[NA,NA,NA,10.00px]". + */ + + frameNode->DumpBorder(testBorder, "border1", json); + EXPECT_EQ(json->GetString("border1"), "[NA,NA,NA,10.00px]"); + + /** + * @tc.steps: step4. Give PaddingProperty a new value. + */ + testBorder->topDimen = Dimension(10.0f); + + /** + * @tc.steps: step5. Execute DumpPadding. + * @tc.expected: step5. get the JsonValue is "[NA,NA,20.00px,10.00px]". + */ + + frameNode->DumpBorder(testBorder, "border2", json); + EXPECT_EQ(json->GetString("border2"), "[NA,NA,10.00px,10.00px]"); + + /** + * @tc.steps: step6. Give PaddingProperty a new value. + */ + testBorder->rightDimen = Dimension(10.0f); + + /** + * @tc.steps: step7. Execute DumpPadding. + * @tc.expected: step7. get the JsonValue is "[NA,10.00px,10.00px,10.00px]". + */ + + frameNode->DumpBorder(testBorder, "border3", json); + EXPECT_EQ(json->GetString("border3"), "[NA,10.00px,10.00px,10.00px]"); + + /** + * @tc.steps: step8. Give PaddingProperty a new value. + */ + testBorder->leftDimen = Dimension(10.0f); + + /** + * @tc.steps: step9. Execute DumpPadding. + * @tc.expected: step9. get the JsonValue is "[10.00px,10.00px,10.00px,10.00px]". + */ + + frameNode->DumpBorder(testBorder, "border4", json); + EXPECT_EQ(json->GetString("border4"), "[10.00px,10.00px,10.00px,10.00px]"); +} + +/** + * @tc.name: FrameNodeDumpSimplifySafeAreaInfo001 + * @tc.desc: Test DumpSimplifySafeAreaInfo. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifySafeAreaInfo001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode. + * @tc.expected: expect is nullptr. + */ + auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); + ASSERT_NE(frameNode, nullptr); + + /** + * @tc.steps: step2. create json, create SafeAreaExpandOpts. + * @tc.expected: expect is nullptr. + */ + std::unique_ptr json = JsonUtil::Create(true); + ASSERT_NE(json, nullptr); + SafeAreaExpandOpts opts; + frameNode->GetLayoutProperty()->UpdateSafeAreaExpandOpts(opts); + + /** + * @tc.steps: step3.Opts have no value, test DumpSimplifySafeAreaInfo. + * @tc.expected: json is null. + */ + frameNode->DumpSimplifySafeAreaInfo(json); + const auto& valueExpandOpts = json->GetValue("SafeAreaExpandOpts"); + EXPECT_TRUE(valueExpandOpts->IsNull()); + const auto& valueInsets = json->GetValue("SafeAreaInsets"); + EXPECT_TRUE(valueInsets->IsNull()); + const auto& valueSelfAdjust = json->GetValue("SelfAdjust"); + EXPECT_TRUE(valueSelfAdjust->IsNull()); + const auto& valueParentSelfAdjust = json->GetValue("ParentSelfAdjust"); + EXPECT_TRUE(valueParentSelfAdjust->IsNull()); + + /** + * @tc.steps: step4.Opts have value, test DumpSimplifySafeAreaInfo. + * @tc.expected: JSON data has values and their values are predictable. + */ + opts.edges = SAFE_AREA_EDGE_TOP; + std::string optsString = "SafeAreaExpandOpts: type:SAFE_AREA_TYPE_NONE, edges: SAFE_AREA_EDGE_TOP"; + frameNode->GetLayoutProperty()->UpdateSafeAreaExpandOpts(opts); + frameNode->DumpSimplifySafeAreaInfo(json); + EXPECT_EQ(json->GetString("SafeAreaExpandOpts"), optsString); + + json->Delete("SafeAreaExpandOpts"); + opts.type = SAFE_AREA_TYPE_SYSTEM; + optsString = "SafeAreaExpandOpts: type:SAFE_AREA_TYPE_SYSTEM, edges: SAFE_AREA_EDGE_TOP"; + frameNode->GetLayoutProperty()->UpdateSafeAreaExpandOpts(opts); + frameNode->DumpSimplifySafeAreaInfo(json); + EXPECT_EQ(json->GetString("SafeAreaExpandOpts"), optsString); + + SafeAreaInsets safeArea; + optsString = "SafeAreaInsets left_"; + frameNode->GetLayoutProperty()->UpdateSafeAreaInsets(safeArea); + frameNode->DumpSimplifySafeAreaInfo(json); + EXPECT_EQ(json->GetString("SafeAreaInsets").find("left_"), optsString.find("left_")); +} + +/** + * @tc.name: FrameNodeDumpSimplifySafeAreaInfo002 + * @tc.desc: Test DumpSimplifySafeAreaInfo. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifySafeAreaInfo002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode. + * @tc.expected: expect is nullptr. + */ + auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); + ASSERT_NE(frameNode, nullptr); + + /** + * @tc.steps: step2. create json, create SafeAreaExpandOpts. + * @tc.expected: expect is nullptr. + */ + std::unique_ptr json = JsonUtil::Create(true); + ASSERT_NE(json, nullptr); + SafeAreaExpandOpts opts; + opts.edges = SAFE_AREA_EDGE_TOP; + opts.type = SAFE_AREA_TYPE_SYSTEM; + frameNode->GetLayoutProperty()->UpdateSafeAreaExpandOpts(opts); + frameNode->DumpSimplifySafeAreaInfo(json); + const auto& valueSelfAdjust = json->GetValue("SelfAdjust"); + EXPECT_TRUE(valueSelfAdjust->IsNull()); + const auto& valueParentSelfAdjust = json->GetValue("ParentSelfAdjust"); + EXPECT_TRUE(valueParentSelfAdjust->IsNull()); + + /** + * @tc.steps: step3.SetGeometryNode, test DumpSimplifySafeAreaInfo. + * @tc.expected: JSON data has values and their values are predictable. + */ + RefPtr geometryNode = AceType::MakeRefPtr(); + geometryNode->SetSelfAdjust(RectF(10.0f, 10.0f, 10.0f, 10.0f)); + geometryNode->SetParentAdjust(RectF(20.0f, 20.0f, 20.0f, 20.0f)); + frameNode->SetGeometryNode(geometryNode); + frameNode->DumpSimplifySafeAreaInfo(json); + std::string str = "RectT (10.00, 10.00) - [10.00 x 10.00]"; + EXPECT_EQ(json->GetString("SelfAdjust"), str); + str = "RectT (20.00, 20.00) - [20.00 x 20.00]"; + EXPECT_EQ(json->GetString("ParentSelfAdjust"), str); +} + +/** + * @tc.name: FrameNodeDumpSimplifySafeAreaInfo003 + * @tc.desc: Test DumpSimplifySafeAreaInfo. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifySafeAreaInfo003, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode. + * @tc.expected: expect is nullptr. + */ + auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr(), true); + ASSERT_NE(frameNode, nullptr); + + /** + * @tc.steps: step2. create json, create SafeAreaExpandOpts. + * @tc.expected: expect is nullptr. + */ + std::unique_ptr json = JsonUtil::Create(true); + ASSERT_NE(json, nullptr); + frameNode->DumpSimplifySafeAreaInfo(json); + const auto& valueKeyboardInset = json->GetValue("KeyboardInset: "); + EXPECT_TRUE(valueKeyboardInset->IsNull()); + /** + * @tc.steps: step3.SetGeometryNode, test DumpSimplifySafeAreaInfo. + * @tc.expected: JSON data has values and their values are predictable. + */ + auto manager = MockPipelineContext::GetCurrent()->GetSafeAreaManager(); + ASSERT_NE(manager, nullptr); + SafeAreaInsets::Inset keyboardInset; + manager->keyboardInset_ = keyboardInset; + manager->keyboardSafeAreaEnabled_ = true; + frameNode->DumpSimplifySafeAreaInfo(json); + EXPECT_EQ(json->GetBool("IgnoreSafeArea"), false); + EXPECT_EQ(json->GetBool("IsNeedAvoidWindow"), false); + EXPECT_EQ(json->GetBool("IsFullScreen"), false); + EXPECT_EQ(json->GetInt("IsKeyboardAvoidMode"), 0); + EXPECT_EQ(json->GetBool("IsKeyboardAvoidMode"), false); + std::string str = "[start: 0, end: 0]"; + EXPECT_EQ(json->GetString("KeyboardInset: "), str); +} + +/** + * @tc.name: FrameNodeDumpSimplifyOverlayInfo001 + * @tc.desc: Test DumpSimplifyOverlayInfo. + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifyOverlayInfo001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode. + * @tc.expected: expect is nullptr. + */ + auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); + ASSERT_NE(frameNode, nullptr); + + /** + * @tc.steps: step2. create json, create SafeAreaExpandOpts. + * @tc.expected: expect is nullptr. + */ + std::unique_ptr json = JsonUtil::Create(true); + ASSERT_NE(json, nullptr); + frameNode->DumpSimplifyOverlayInfo(json); + const auto& valueIsOverlayNode = json->GetValue("IsOverlayNode"); + EXPECT_TRUE(valueIsOverlayNode->IsNull()); + + /** + * @tc.steps: step3.IsOverlayNode == true, test DumpSimplifyOverlayInfo. + * @tc.expected: JSON data has values and their values are predictable. + */ + frameNode->GetLayoutProperty()->SetIsOverlayNode(true); + frameNode->DumpSimplifyOverlayInfo(json); + EXPECT_EQ(json->GetBool("IsOverlayNode"), true); + EXPECT_EQ(json->GetString("OverlayOffset"), "0.00px,0.00px"); +} + +/** + * @tc.name: FrameNodeGeometryNodeToJsonValue + * @tc.desc: Test method GeometryNodeToJsonValue + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, FrameNodeGeometryNodeToJsonValue, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode. + * @tc.expected: expect is nullptr. + */ + auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); + ASSERT_NE(frameNode, nullptr); + + /** + * @tc.steps: step2. create json, create InspectorFilter. + * @tc.expected: width is 0.00vp, height is 0.00vp. + */ + std::unique_ptr json = JsonUtil::Create(true); + ASSERT_NE(json, nullptr); + InspectorFilter filter; + frameNode->GeometryNodeToJsonValue(json, filter); + EXPECT_EQ(json->GetString("width"), "0.00vp"); + EXPECT_EQ(json->GetString("height"), "0.00vp"); + + /** + * @tc.steps: step3. has CalcLayoutProperty. + * @tc.expected: width is 0.00vp, height is 0.00vp. + */ + MeasureProperty calc; + frameNode->GetLayoutProperty()->UpdateCalcLayoutProperty(calc); + json->Delete("width"); + json->Delete("height"); + frameNode->GeometryNodeToJsonValue(json, filter); + EXPECT_EQ(json->GetString("width"), "0.00vp"); + EXPECT_EQ(json->GetString("height"), "0.00vp"); + + /** + * @tc.steps: step3. GeometryNode has value. + * @tc.expected: width is 10.00vp, height is 10.00vp. + */ + frameNode->GetGeometryNode()->SetFrameSize(SizeF(10.0, 10.0)); + json->Delete("width"); + json->Delete("height"); + frameNode->GeometryNodeToJsonValue(json, filter); + EXPECT_EQ(json->GetString("width"), "10.00vp"); + EXPECT_EQ(json->GetString("height"), "10.00vp"); +} +} // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/test/unittest/core/base/frame_node_test_ng_new.cpp b/test/unittest/core/base/frame_node_test_ng_new.cpp index ef2ec3453b0..68a05f56536 100644 --- a/test/unittest/core/base/frame_node_test_ng_new.cpp +++ b/test/unittest/core/base/frame_node_test_ng_new.cpp @@ -2790,55 +2790,6 @@ HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirty003, TestSize.Level1) EXPECT_TRUE(frameNode->GetOrCreateEventHub()->GetOrCreateFocusHub()->IsCurrentFocus()); } -/** - * @tc.name: FrameNodeGeometryNodeToJsonValue - * @tc.desc: Test method GeometryNodeToJsonValue - * @tc.type: FUNC - */ -HWTEST_F(FrameNodeTestNg, FrameNodeGeometryNodeToJsonValue, TestSize.Level1) -{ - /** - * @tc.steps: step1. create value. - */ - auto value = JsonUtil::Create(true); - - /** - * @tc.steps: step2. construct parameters. - * @tc.expected: expect cover branch layoutProperty_ is nullptr. - */ - auto frameNode = FrameNode::CreateFrameNode("frameNode", 2, AceType::MakeRefPtr()); - InspectorFilter filter; - frameNode->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(frameNode->layoutProperty_, nullptr); - - /** - * @tc.steps: step3. set layoutProperty_ and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch layoutProperty_ is not nullptr. - */ - auto layoutProperty = AceType::MakeRefPtr(); - frameNode->layoutProperty_ = layoutProperty; - frameNode->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(frameNode->layoutProperty_, nullptr); - - /** - * @tc.steps: step4. set calcLayoutConstraint_ and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch calcLayoutConstraint_ is not nullptr. - */ - frameNode->layoutProperty_->calcLayoutConstraint_ = std::make_unique(); - - frameNode->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(frameNode->layoutProperty_->calcLayoutConstraint_, nullptr); - - /** - * @tc.steps: step5. set selfIdealSize and call GeometryNodeToJsonValue. - * @tc.expected: expect cover branch selfIdealSize has value. - */ - std::optional len = CalcLength("auto"); - frameNode->layoutProperty_->calcLayoutConstraint_->selfIdealSize = CalcSize(len, len); - frameNode->GeometryNodeToJsonValue(value, filter); - EXPECT_NE(frameNode->renderContext_, nullptr); -} - /** * @tc.name: FrameNodeDumpSimplifyCommonInfo * @tc.desc: Test DumpSimplifyCommonInfo. @@ -2902,69 +2853,6 @@ HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifyCommonInfo, TestSize.Level1) EXPECT_FALSE(hasKeyParentLayout); } -/** - * @tc.name: FrameNodeDumpSimplifySafeAreaInfo - * @tc.desc: Test DumpSimplifySafeAreaInfo. - * @tc.type: FUNC - */ -HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifySafeAreaInfo, TestSize.Level1) -{ - /** - * @tc.steps: step1. create frameNode. - * @tc.expected: expect is nullptr. - */ - auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); - EXPECT_NE(frameNode, nullptr); - - /** - * @tc.steps: step2. create json. - * @tc.expected: expect is nullptr. - */ - std::unique_ptr json = JsonUtil::Create(true); - EXPECT_NE(json, nullptr); - - /** - * @tc.steps: step3. test DumpSimplifySafeAreaInfo. - * @tc.expected: expect is FALSE. - */ - frameNode->DumpSimplifySafeAreaInfo(json); - const auto& valueExpandOpts = json->GetValue("SafeAreaExpandOpts"); - bool hasvalueExpandOpts = !(valueExpandOpts->IsNull()); - EXPECT_FALSE(hasvalueExpandOpts); - - const auto& valueInsets = json->GetValue("SafeAreaInsets"); - bool hasKeyInsets = !(valueInsets->IsNull()); - EXPECT_FALSE(hasKeyInsets); - - const auto& valueSelfAdjust = json->GetValue("SelfAdjust"); - bool hasKeySelfAdjust = !(valueSelfAdjust->IsNull()); - EXPECT_FALSE(hasKeySelfAdjust); - - const auto& valueParentSelfAdjust = json->GetValue("ParentSelfAdjust"); - bool hasKeyParentSelfAdjust = !(valueParentSelfAdjust->IsNull()); - EXPECT_FALSE(hasKeyParentSelfAdjust); - - const auto& valueIgnore = json->GetValue("IgnoreSafeArea"); - bool hasKeyIgnore = !(valueIgnore->IsNull()); - EXPECT_FALSE(hasKeyIgnore); - - const auto& valueAvoidWindow = json->GetValue("IsNeedAvoidWindow"); - bool hasKeyAvoidWindow = !(valueAvoidWindow->IsNull()); - EXPECT_FALSE(hasKeyAvoidWindow); - - const auto& valueIsFullScreen = json->GetValue("IsFullScreen"); - bool hasKeyIsFullScreen = !(valueIsFullScreen->IsNull()); - EXPECT_FALSE(hasKeyIsFullScreen); - - const auto& valueIsKeyboard = json->GetValue("IsKeyboardAvoidMode"); - bool hasKeyIsKeyboard = !(valueIsKeyboard->IsNull()); - EXPECT_FALSE(hasKeyIsKeyboard); - - const auto& valueIsUseCutout = json->GetValue("IsUseCutout"); - bool hasKeyIsUseCutout = !(valueIsUseCutout->IsNull()); - EXPECT_FALSE(hasKeyIsUseCutout); -} - /** * @tc.name: FrameNodeDumpCommonInfo * @tc.desc: Test DumpCommonInfo. -- Gitee