无障碍补充DT用例

Signed-off-by: qianchuang <qianchuang1@huawei.com>
This commit is contained in:
qianchuang 2024-11-03 14:42:51 +08:00
parent f7d3ce90b7
commit 65f0bca5bd
3 changed files with 151 additions and 0 deletions

View File

@ -40,6 +40,8 @@ public:
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() Start";
elementInfo_ = std::make_shared<AccessibilityElementInfo>();
elementInfoParcel_ = std::make_shared<AccessibilityElementInfoParcel>(*elementInfo_);
spanInfo_ = std::make_shared<SpanInfo>();
spanInfoParcel_ = std::make_shared<SpanInfoParcel>(*spanInfo_);
action_ = std::make_shared<AccessibleAction>();
actionParcel_ = std::make_shared<AccessibleActionParcel>(*action_);
rangeInfo_ = std::make_shared<RangeInfo>();
@ -59,6 +61,8 @@ public:
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest TearDown()";
elementInfo_ = nullptr;
elementInfoParcel_ = nullptr;
spanInfo_ = nullptr;
spanInfoParcel_ = nullptr;
action_ = nullptr;
actionParcel_ = nullptr;
rangeInfo_ = nullptr;
@ -85,6 +89,8 @@ public:
std::shared_ptr<RectParcel> rectParcel_ = nullptr;
std::shared_ptr<AccessibilityElementInfo> elementInfo_ = nullptr;
std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr;
std::shared_ptr<SpanInfo> spanInfo_ = nullptr;
std::shared_ptr<SpanInfoParcel> spanInfoParcel_ = nullptr;
std::shared_ptr<ExtraElementInfo> extraElementInfo_ = nullptr;
std::shared_ptr<ExtraElementInfoParcel> extraElementInfoParcel_ = nullptr;
};
@ -353,5 +359,61 @@ HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__002, Tes
EXPECT_EQ(true, extraElementInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 end";
}
/**
* @tc.number: Span_Info_Parcel__001
* @tc.name: Span_Info_Parcel
* @tc.desc: Test function ReadFromParcel
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Parcel__001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Span_Info_Parcel__001 start";
if (!spanInfoParcel_) {
GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
return;
}
Parcel parcel;
EXPECT_EQ(false, spanInfoParcel_->ReadFromParcel(parcel));
GTEST_LOG_(INFO) << "Span_Info_Parcel__001 end";
}
/**
* @tc.number: Span_Info_Marshalling_001
* @tc.name: Span_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 start";
if (!spanInfoParcel_) {
GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = spanInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 end";
}
/**
* @tc.number: Span_Info_Unmarshalling__001
* @tc.name: Span_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Unmarshalling__001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 start";
if (!spanInfoParcel_) {
GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<SpanInfoParcel> spanInfoParcel = spanInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, spanInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -88,5 +88,23 @@ HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Unmarshalling_001, TestS
EXPECT_EQ(true, windowInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 end";
}
/**
* @tc.number: Window_Info_Parcel__001
* @tc.name: Window_Info_Parcel
* @tc.desc: Test function ReadFromParcel
*/
HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Parcel__001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Window_Info_Parcel__001 start";
if (!windowInfoParcel_) {
GTEST_LOG_(INFO) << "windowInfoParcel_ is null";
return;
}
Parcel parcel;
EXPECT_EQ(false, windowInfoParcel_->ReadFromParcel(parcel));
GTEST_LOG_(INFO) << "Window_Info_Parcel__001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -1479,5 +1479,76 @@ HWTEST_F(AccessibilityElementInfoTest, SetNavDestinationId_001, TestSize.Level1)
EXPECT_TRUE(elementInfo_->GetNavDestinationId() == 1);
GTEST_LOG_(INFO) << "SetNavDestinationId_001 end";
}
/**
* @tc.number: SetSpanList_001
* @tc.name: SetSpanList
* @tc.desc: Test function AddSpan, SetSpanList
*/
HWTEST_F(AccessibilityElementInfoTest, SetSpanList_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetSpanList_001 start";
SpanInfo span;
span.SetSpanId(1);
EXPECT_TRUE(span.GetSpanId() == 1);
span.SetSpanText("spanText");
EXPECT_TRUE(span.GetSpanText() == "spanText");
span.SetAccessibilityText("accessibilityText");
EXPECT_TRUE(span.GetAccessibilityText() == "accessibilityText");
span.SetAccessibilityDescription("accessibilityDescription");
EXPECT_TRUE(span.GetAccessibilityDescription() == "accessibilityDescription");
span.SetAccessibilityLevel("accessibilityLevel");
EXPECT_TRUE(span.GetAccessibilityLevel() == "accessibilityLevel");
elementInfo_->AddSpan(span);
EXPECT_TRUE(elementInfo_->GetSpanList().size() == 1);
std::vector<SpanInfo> spanList;
spanList.push_back(span);
spanList.push_back(span);
elementInfo_->SetSpanList(spanList);
EXPECT_TRUE(elementInfo_->GetSpanList().size() == 2);
GTEST_LOG_(INFO) << "SetSpanList_001 end";
}
/**
* @tc.number: SetIsActive_001
* @tc.name: SetIsActive
* @tc.desc: Test function SetIsActive, GetIsActive
*/
HWTEST_F(AccessibilityElementInfoTest, SetIsActive_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetIsActive_001 start";
elementInfo_->SetIsActive(true);
EXPECT_TRUE(elementInfo_->GetIsActive());
GTEST_LOG_(INFO) << "SetIsActive_001 end";
}
/**
* @tc.number: SetAccessibilityVisible_001
* @tc.name: SetAccessibilityVisible
* @tc.desc: Test function SetAccessibilityVisible, GetAccessibilityVisible
*/
HWTEST_F(AccessibilityElementInfoTest, SetAccessibilityVisible_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetAccessibilityVisible_001 start";
elementInfo_->SetAccessibilityVisible(true);
EXPECT_TRUE(elementInfo_->GetAccessibilityVisible());
GTEST_LOG_(INFO) << "SetAccessibilityVisible_001 end";
}
/**
* @tc.number: SetClip_001
* @tc.name: SetClip
* @tc.desc: Test function SetClip, GetClip
*/
HWTEST_F(AccessibilityElementInfoTest, SetClip_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetClip_001 start";
elementInfo_->SetClip(true);
EXPECT_TRUE(elementInfo_->GetClip());
GTEST_LOG_(INFO) << "SetClip_001 end";
}
} // namespace Accessibility
} // namespace OHOS