tdd接口覆盖

Signed-off-by: wangjin_123 <wangjin193@huawei.com>
This commit is contained in:
w00675913 2024-01-17 12:32:32 +08:00 committed by wangjin_123
parent 977301ac9b
commit d249da68a2
8 changed files with 800 additions and 0 deletions

View File

@ -143,6 +143,7 @@
"//foundation/barrierfree/accessibility/frameworks/acfwk/test:unittest",
"//foundation/barrierfree/accessibility/frameworks/asacfwk/test:unittest",
"//foundation/barrierfree/accessibility/frameworks/common/test:unittest",
"//foundation/barrierfree/accessibility/common/interface/test:unittest",
"//foundation/barrierfree/accessibility/interfaces/innerkits/test/fuzztest:fuzztest",
"//foundation/barrierfree/accessibility/interfaces/innerkits/test/benchmarktest:benchmarktest"
]

View File

@ -0,0 +1,87 @@
# 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.
import("//build/test.gni")
module_output_path = "accessibility/accessibility"
###############################################################################
config("module_parcel_private_config") {
visibility = [ ":*" ]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
include_dirs = [
"../include/parcel",
"../../../common/log/include",
"../../../interfaces/innerkits/common/include",
]
defines = [
"AAMS_LOG_TAG = \"accessibility_parcel\"",
"AAMS_LOG_DOMAIN = 0xD001D05",
]
}
accessibility_parcel_src = [
"../src/parcel/accessibility_ability_info_parcel.cpp",
"../src/parcel/accessibility_caption_parcel.cpp",
"../src/parcel/accessibility_element_info_parcel.cpp",
"../src/parcel/accessibility_event_info_parcel.cpp",
"../src/parcel/accessibility_window_info_parcel.cpp",
]
accessibility_parcel_test_src = [
"unittest/accessibility_ability_info_parcel_test.cpp",
"unittest/accessibility_caption_parcel_test.cpp",
"unittest/accessibility_element_info_parcel_test.cpp",
"unittest/accessibility_event_info_parcel_test.cpp",
"unittest/accessibility_window_info_parcel_test.cpp",
]
ohos_unittest("accessibility_parcel_test") {
module_out_path = module_output_path
sources = accessibility_parcel_src
sources += accessibility_parcel_test_src
configs = [
":module_parcel_private_config",
"../../../resources/config/build:coverage_flags",
]
deps = [
"../../../../../../third_party/googletest:gmock_main",
"../../../../../../third_party/googletest:gtest_main",
"../../../interfaces/innerkits/common:accessibility_common",
]
external_deps = [
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"c_utils:utils",
"hilog:libhilog",
"input:libmmi-client",
"ipc:ipc_single",
]
}
###############################################################################
group("unittest") {
testonly = true
deps = []
deps += [ ":accessibility_parcel_test" ]
}
###############################################################################

View File

@ -0,0 +1,103 @@
/*
* 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 <gtest/gtest.h>
#include "../../include/parcel/accessibility_ability_info_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Accessibility {
class AccessibilityAbilityInfoParcelTest : public ::testing::Test {
public:
AccessibilityAbilityInfoParcelTest()
{}
~AccessibilityAbilityInfoParcelTest()
{}
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest Start";
}
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest End";
}
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest SetUp() Start";
AccessibilityAbilityInitParams params;
params.bundleName = "bundleName";
params.moduleName = "moduleName";
params.name = "name";
params.description = "description";
params.rationale = "rationale";
params.settingsAbility = "settingsAbility";
params.staticCapabilities = 1;
params.abilityTypes = ACCESSIBILITY_ABILITY_TYPE_SPOKEN;
params.isImportant = true;
abilityInfo_ = std::make_shared<AccessibilityAbilityInfo>(params);
abilityInfoParcel_ = std::make_shared<AccessibilityAbilityInfoParcel>(*abilityInfo_);
GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest SetUp() End";
};
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest TearDown()";
abilityInfo_ = nullptr;
abilityInfoParcel_ = nullptr;
}
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo_ = nullptr;
std::shared_ptr<AccessibilityAbilityInfoParcel> abilityInfoParcel_ = nullptr;
};
/**
* @tc.number: Marshalling_001
* @tc.name: Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityAbilityInfoParcelTest, Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Marshalling_001 start";
if (!abilityInfoParcel_) {
GTEST_LOG_(INFO) << "abilityInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = abilityInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Marshalling_001 end";
}
/**
* @tc.number: Unmarshalling_001
* @tc.name: Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityAbilityInfoParcelTest, Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Unmarshalling_001 start";
if (!abilityInfoParcel_) {
GTEST_LOG_(INFO) << "abilityInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<AccessibilityAbilityInfoParcel> infoParcel = abilityInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, infoParcel == nullptr);
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -0,0 +1,92 @@
/*
* 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 <gtest/gtest.h>
#include "../../include/parcel/accessibility_caption_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Accessibility {
class AccessibilityCaptionParcelTest : public ::testing::Test {
public:
AccessibilityCaptionParcelTest()
{}
~AccessibilityCaptionParcelTest()
{}
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityCaptionParcelTest Start";
}
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityCaptionParcelTest End";
}
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityCaptionParcelTest SetUp() Start";
AccessibilityConfig::CaptionProperty captionProperty;
captionPropertyParcel_ = std::make_shared<CaptionPropertyParcel>(captionProperty);
GTEST_LOG_(INFO) << "AccessibilityCaptionParcelTest SetUp() End";
};
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityCaptionParcelTest TearDown()";
captionPropertyParcel_ = nullptr;
}
std::shared_ptr<CaptionPropertyParcel> captionPropertyParcel_ = nullptr;
};
/**
* @tc.number: Caption_Marshalling_001
* @tc.name: Caption_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityCaptionParcelTest, Caption_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Caption_Marshalling_001 start";
if (!captionPropertyParcel_) {
GTEST_LOG_(INFO) << "captionPropertyParcel_ is null";
return;
}
Parcel parcel;
bool ret = captionPropertyParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Caption_Marshalling_001 end";
}
/**
* @tc.number: Caption_Unmarshalling_001
* @tc.name: Caption_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityCaptionParcelTest, Caption_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Caption_Unmarshalling_001 start";
if (!captionPropertyParcel_) {
GTEST_LOG_(INFO) << "captionPropertyParcel_ is null";
return;
}
Parcel parcel;
sptr<CaptionPropertyParcel> captionParcel = captionPropertyParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, captionParcel == nullptr);
GTEST_LOG_(INFO) << "Caption_Unmarshalling_001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -0,0 +1,314 @@
/*
* 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 <gtest/gtest.h>
#include "../../include/parcel/accessibility_element_info_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Accessibility {
class AccessibilityElementInfoParcelTest : public ::testing::Test {
public:
AccessibilityElementInfoParcelTest()
{}
~AccessibilityElementInfoParcelTest()
{}
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest Start";
}
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest End";
}
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() Start";
elementInfo_ = std::make_shared<AccessibilityElementInfo>();
elementInfoParcel_ = std::make_shared<AccessibilityElementInfoParcel>(*elementInfo_);
action_ = std::make_shared<AccessibleAction>();
actionParcel_ = std::make_shared<AccessibleActionParcel>(*action_);
rangeInfo_ = std::make_shared<RangeInfo>();
rangeInfoParcel_ = std::make_shared<RangeInfoParcel>(*rangeInfo_);
gridInfo_ = std::make_shared<GridInfo>();
gridInfoParcel_ = std::make_shared<GridInfoParcel>(*gridInfo_);
gridItemInfo_ = std::make_shared<GridItemInfo>();
gridItemInfoParcel_ = std::make_shared<GridItemInfoParcel>(*gridItemInfo_);
rect_ = std::make_shared<Rect>();
rectParcel_ = std::make_shared<RectParcel>(*rect_);
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() End";
};
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest TearDown()";
elementInfo_ = nullptr;
elementInfoParcel_ = nullptr;
action_ = nullptr;
actionParcel_ = nullptr;
rangeInfo_ = nullptr;
rangeInfoParcel_ = nullptr;
gridInfo_ = nullptr;
gridInfoParcel_ = nullptr;
gridItemInfo_ = nullptr;
gridItemInfoParcel_ = nullptr;
rect_ = nullptr;
rectParcel_ = nullptr;
}
std::shared_ptr<AccessibleAction> action_ = nullptr;
std::shared_ptr<AccessibleActionParcel> actionParcel_ = nullptr;
std::shared_ptr<RangeInfo> rangeInfo_ = nullptr;
std::shared_ptr<RangeInfoParcel> rangeInfoParcel_ = nullptr;
std::shared_ptr<GridInfo> gridInfo_ = nullptr;
std::shared_ptr<GridInfoParcel> gridInfoParcel_ = nullptr;
std::shared_ptr<GridItemInfo> gridItemInfo_ = nullptr;
std::shared_ptr<GridItemInfoParcel> gridItemInfoParcel_ = nullptr;
std::shared_ptr<Rect> rect_ = nullptr;
std::shared_ptr<RectParcel> rectParcel_ = nullptr;
std::shared_ptr<AccessibilityElementInfo> elementInfo_ = nullptr;
std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr;
};
/**
* @tc.number: Element_Info__Marshalling_001
* @tc.name: Element_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 start";
if (!elementInfoParcel_) {
GTEST_LOG_(INFO) << "elementInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = elementInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 end";
}
/**
* @tc.number: Element_Info_Unmarshalling_001
* @tc.name: Element_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start";
if (!elementInfoParcel_) {
GTEST_LOG_(INFO) << "elementInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, elementInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end";
}
/**
* @tc.number: Rect_Marshalling_001
* @tc.name: Rect_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Rect_Marshalling_001 start";
if (!rectParcel_) {
GTEST_LOG_(INFO) << "rectParcel_ is null";
return;
}
Parcel parcel;
bool ret = rectParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Rect_Marshalling_001 end";
}
/**
* @tc.number: Rect_Unmarshalling_001
* @tc.name: Rect__Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 start";
if (!rectParcel_) {
GTEST_LOG_(INFO) << "rectParcel_ is null";
return;
}
Parcel parcel;
sptr<RectParcel> rectParcel = rectParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, rectParcel == nullptr);
GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 end";
}
/**
* @tc.number: Grid_Item_Info_Marshalling_001
* @tc.name: Grid_Item_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 start";
if (!gridItemInfoParcel_) {
GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = gridItemInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 end";
}
/**
* @tc.number: Grid_Item_Info_Unmarshalling_001
* @tc.name: Grid_Item_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 start";
if (!gridItemInfoParcel_) {
GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<GridItemInfoParcel> gridItemInfoParcel = gridItemInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, gridItemInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 end";
}
/**
* @tc.number: Action_Marshalling_001
* @tc.name: Action_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Action_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Action_Marshalling_001 start";
if (!actionParcel_) {
GTEST_LOG_(INFO) << "actionParcel_ is null";
return;
}
Parcel parcel;
bool ret = actionParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Action_Marshalling_001 end";
}
/**
* @tc.number: Action_Unmarshalling_001
* @tc.name: Action_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Action_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Action_Unmarshalling_001 start";
if (!actionParcel_) {
GTEST_LOG_(INFO) << "actionParcel_ is null";
return;
}
Parcel parcel;
sptr<AccessibleActionParcel> actionParcel = actionParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, actionParcel == nullptr);
GTEST_LOG_(INFO) << "Action_Unmarshalling_001 end";
}
/**
* @tc.number: Range_Info_Marshalling_001
* @tc.name: Range_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 start";
if (!rangeInfoParcel_) {
GTEST_LOG_(INFO) << "rangeInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = rangeInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 end";
}
/**
* @tc.number: Range_Info_Unmarshalling_001
* @tc.name: Range_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 start";
if (!rangeInfoParcel_) {
GTEST_LOG_(INFO) << "rangeInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<RangeInfoParcel> rangeInfoParcel = rangeInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, rangeInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 end";
}
/**
* @tc.number: Grid_Info_Marshalling_001
* @tc.name: Grid_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 start";
if (!gridInfoParcel_) {
GTEST_LOG_(INFO) << "gridInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = gridInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 end";
}
/**
* @tc.number: Grid_Info_Unmarshalling_001
* @tc.name: Grid_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 start";
if (!gridInfoParcel_) {
GTEST_LOG_(INFO) << "gridInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<GridInfoParcel> gridInfoParcel = gridInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, gridInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -0,0 +1,92 @@
/*
* 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 <gtest/gtest.h>
#include "../../include/parcel/accessibility_event_info_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Accessibility {
class AccessibilityEventInfoParcelTest : public ::testing::Test {
public:
AccessibilityEventInfoParcelTest()
{}
~AccessibilityEventInfoParcelTest()
{}
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest Start";
}
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest End";
}
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest SetUp() Start";
AccessibilityEventInfo eventInfo;
eventInfoParcel_ = std::make_shared<AccessibilityEventInfoParcel>(eventInfo);
GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest SetUp() End";
};
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest TearDown()";
eventInfoParcel_ = nullptr;
}
std::shared_ptr<AccessibilityEventInfoParcel> eventInfoParcel_ = nullptr;
};
/**
* @tc.number: Event_Info_Marshalling_001
* @tc.name: Event_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityEventInfoParcelTest, Event_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Event_Info_Marshalling_001 start";
if (!eventInfoParcel_) {
GTEST_LOG_(INFO) << "eventInfoParcel_ is null";
return;
}
Parcel parcel;
bool ret = eventInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Event_Info_Marshalling_001 end";
}
/**
* @tc.number: Event_Info_Unmarshalling_001
* @tc.name: Event_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityEventInfoParcelTest, Event_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 start";
if (!eventInfoParcel_) {
GTEST_LOG_(INFO) << "eventInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<AccessibilityEventInfoParcel> eventInfoParcel = eventInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, eventInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -0,0 +1,92 @@
/*
* 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 <gtest/gtest.h>
#include "../../include/parcel/accessibility_window_info_parcel.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Accessibility {
class AccessibilityWindowInfoParcelTest : public ::testing::Test {
public:
AccessibilityWindowInfoParcelTest()
{}
~AccessibilityWindowInfoParcelTest()
{}
static void SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest Start";
}
static void TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest End";
}
void SetUp()
{
GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest SetUp() Start";
AccessibilityWindowInfo windowInfo;
windowInfoParcel_ = std::make_shared<AccessibilityWindowInfoParcel>(windowInfo);
GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest SetUp() End";
};
void TearDown()
{
GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest TearDown()";
windowInfoParcel_ = nullptr;
}
std::shared_ptr<AccessibilityWindowInfoParcel> windowInfoParcel_ = nullptr;
};
/**
* @tc.number: Window_Info_Marshalling_001
* @tc.name: Window_Info_Marshalling
* @tc.desc: Test function Marshalling
*/
HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Marshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Window_Info_Marshalling_001 start";
if (!windowInfoParcel_) {
GTEST_LOG_(INFO) << "captionPropertyParcel_ is null";
return;
}
Parcel parcel;
bool ret = windowInfoParcel_->Marshalling(parcel);
EXPECT_EQ(ret, true);
GTEST_LOG_(INFO) << "Window_Info_Marshalling_001 end";
}
/**
* @tc.number: Window_Info_Unmarshalling_001
* @tc.name: Window_Info_Unmarshalling
* @tc.desc: Test function Unmarshalling
*/
HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Unmarshalling_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 start";
if (!windowInfoParcel_) {
GTEST_LOG_(INFO) << "windowInfoParcel_ is null";
return;
}
Parcel parcel;
sptr<AccessibilityWindowInfoParcel> windowInfoParcel = windowInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, windowInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -201,6 +201,25 @@ HWTEST_F(AccessibilityConfigImplTest, SetShortkeyTarget_002, TestSize.Level1)
GTEST_LOG_(INFO) << "SetShortkeyTarget_002 end";
}
/**
* @tc.number: SetShortkeyMultiTarget_002
* @tc.name: SetShortkeyMultiTarget_002
* @tc.desc: Test function SetShortkeyMultiTarget GetShortkeyMultiTarget
* @tc.require: issueI5NTXH
*/
HWTEST_F(AccessibilityConfigImplTest, SetShortkeyMultiTarget_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetShortkeyMultiTarget_002 start";
std::vector<std::string> name = {"test"};
std::vector<std::string> value = {};
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
instance.SetShortkeyMultiTarget(name);
instance.GetShortkeyMultiTarget(value);
EXPECT_EQ(value.size(), 0);
GTEST_LOG_(INFO) << "SetShortkeyMultiTarget_002 end";
}
/**
* @tc.number: SetDaltonizationState_002
* @tc.name: SetDaltonizationState_002