From 609101a19dc52476d1690b5dd50243cada079ddb Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 19 Jun 2024 16:11:00 +0800 Subject: [PATCH] =?UTF-8?q?TDD=E8=A1=A5=E5=85=85inspector=5Ftest=5Fng?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E3=80=90=20ace=5Fengine=20inspector=5Ftest?= =?UTF-8?q?=5Fng=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- test/unittest/core/base/inspector_test_ng.cpp | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/test/unittest/core/base/inspector_test_ng.cpp b/test/unittest/core/base/inspector_test_ng.cpp index 3052a7bf240..95558851988 100755 --- a/test/unittest/core/base/inspector_test_ng.cpp +++ b/test/unittest/core/base/inspector_test_ng.cpp @@ -376,4 +376,77 @@ HWTEST_F(InspectorTestNg, InspectorTestNg008, TestSize.Level1) EXPECT_EQ(rect.scale.z, zResult); context->rootNode_ = nullptr; } + +/** + * @tc.name: InspectorTestNg009 + * @tc.desc: Test the GetFrameNodeByKey + * @tc.type: FUNC + */ +HWTEST_F(InspectorTestNg, InspectorTestNg009, TestSize.Level1) +{ + auto id = ElementRegister::GetInstance()->MakeUniqueId(); + RefPtr ONE = FrameNode::CreateFrameNode("one", id, AceType::MakeRefPtr(), true); + auto id2 = ElementRegister::GetInstance()->MakeUniqueId(); + const RefPtr TWO = FrameNode::CreateFrameNode("two", id2, AceType::MakeRefPtr()); + auto context = PipelineContext::GetCurrentContext(); + ASSERT_NE(context, nullptr); + auto nodePtr = Inspector::GetFrameNodeByKey(key); + EXPECT_EQ(nodePtr, nullptr); +} + +/** + * @tc.name: InspectorTestNg010 + * @tc.desc: Test the GetRectangleById + * @tc.type: FUNC + */ +HWTEST_F(InspectorTestNg, InspectorTestNg010, TestSize.Level1) +{ + auto id = ElementRegister::GetInstance()->MakeUniqueId(); + RefPtr ONE = FrameNode::CreateFrameNode("one", id, AceType::MakeRefPtr(), true); + auto context = NG::PipelineContext::GetCurrentContext(); + ASSERT_NE(context, nullptr); + context->rootNode_ = ONE; + context->rootNode_->SetGeometryNode(AceType::MakeRefPtr()); + std::string key = "key"; + OHOS::Ace::NG::Rectangle rect; + Inspector::GetRectangleById(key, rect); + context->rootNode_ = nullptr; +} + +/** + * @tc.name: InspectorTestNg011 + * @tc.desc: Test the operation of GetSubWindowInspector + * @tc.type: FUNC + */ +HWTEST_F(InspectorTestNg, InspectorTestNg011, TestSize.Level1) +{ + auto id = ElementRegister::GetInstance()->MakeUniqueId(); + RefPtr ONE = FrameNode::CreateFrameNode("one", id, AceType::MakeRefPtr(), true); + auto context = PipelineContext::GetCurrentContext(); + ASSERT_NE(context, nullptr); + context->stageManager_ = AceType::MakeRefPtr(ONE); + auto pageRootNode = context->GetStageManager()->GetLastPage(); + auto test = Inspector::GetSubWindowInspector(false); + auto str = ""; + EXPECT_NE(test, str); + context->stageManager_ = nullptr; +} + +/** + * @tc.name: InspectorTestNg012 + * @tc.desc: Test the operation of GetSubWindowInspector + * @tc.type: FUNC + */ +HWTEST_F(InspectorTestNg, InspectorTestNg012, TestSize.Level1) +{ + auto id = ElementRegister::GetInstance()->MakeUniqueId(); + RefPtr ONE = FrameNode::CreateFrameNode("one", id, AceType::MakeRefPtr(), true); + auto context = PipelineContext::GetCurrentContext(); + ASSERT_NE(context, nullptr); + context->stageManager_ = AceType::MakeRefPtr(ONE); + int32_t containerId = 1; + std::string result = Inspector::GetSimplifiedInspector(containerId); + EXPECT_NE(result, ""); + context->stageManager_ = nullptr; +} } // namespace OHOS::Ace::NG