diff --git a/frameworks/core/include/ans_subscriber_stub.h b/frameworks/core/include/ans_subscriber_stub.h index 0b10118a7adf814832d663388149f84c339515b0..af72735531c67d649ebd16e4aed071df3bd91934 100644 --- a/frameworks/core/include/ans_subscriber_stub.h +++ b/frameworks/core/include/ans_subscriber_stub.h @@ -38,63 +38,6 @@ public: virtual int32_t OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - /** - * @brief The callback function for the subscriber to establish a connection. - */ - void OnConnected() override; - - /** - * @brief The callback function for subscriber disconnected. - */ - void OnDisconnected() override; - - /** - * @brief The callback function on a notification published. - * - * @param notification Indicates the consumed notification. - * @param notificationMap Indicates the NotificationSortingMap object. - */ - void OnConsumed( - const sptr ¬ification, const sptr ¬ificationMap) override; - - /** - * @brief The callback function on a notification canceled. - * - * @param notification Indicates the canceled notification. - * @param notificationMap Indicates the NotificationSortingMap object. - * @param deleteReason Indicates the delete reason. - */ - void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, - int32_t deleteReason) override; - - /** - * @brief The callback function on the notifications updated. - * - * @param notificationMap Indicates the NotificationSortingMap object. - */ - void OnUpdated(const sptr ¬ificationMap) override; - - /** - * @brief The callback function on the do not disturb date changed. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - */ - void OnDoNotDisturbDateChange(const sptr &date) override; - - /** - * @brief The callback function on the notification enabled flag changed. - * - * @param callbackData Indicates the EnabledNotificationCallbackData object. - */ - void OnEnabledNotificationChanged(const sptr &callbackData) override; - - /** - * @brief The callback function on the badge number changed. - * - * @param badgeData Indicates the BadgeNumberCallbackData object. - */ - void OnBadgeChanged(const sptr &badgeData) override; - private: std::map> interfaces_; diff --git a/frameworks/core/src/ans_subscriber_stub.cpp b/frameworks/core/src/ans_subscriber_stub.cpp index 22f03532d72768503ed90f826ed3d60dd4890aa9..cf55aae8ad1b70386b076d70b6a7cacf81096851 100644 --- a/frameworks/core/src/ans_subscriber_stub.cpp +++ b/frameworks/core/src/ans_subscriber_stub.cpp @@ -191,31 +191,5 @@ ErrCode AnsSubscriberStub::HandleOnBadgeChanged(MessageParcel &data, MessageParc OnBadgeChanged(callbackData); return ERR_OK; } - -void AnsSubscriberStub::OnConnected() -{} - -void AnsSubscriberStub::OnDisconnected() -{} - -void AnsSubscriberStub::OnConsumed( - const sptr ¬ification, const sptr ¬ificationMap) -{} - -void AnsSubscriberStub::OnCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) -{} - -void AnsSubscriberStub::OnUpdated(const sptr ¬ificationMap) -{} - -void AnsSubscriberStub::OnDoNotDisturbDateChange(const sptr &date) -{} - -void AnsSubscriberStub::OnEnabledNotificationChanged(const sptr &callbackData) -{} - -void AnsSubscriberStub::OnBadgeChanged(const sptr &badgeData) -{} } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/test/unittest/BUILD.gn b/frameworks/core/test/unittest/BUILD.gn index c088cd31fbacb303aadd1147128c7ac528e69da2..3ae2e10babc30386b92ecb529f9e6b1e3cc578cc 100644 --- a/frameworks/core/test/unittest/BUILD.gn +++ b/frameworks/core/test/unittest/BUILD.gn @@ -23,6 +23,5 @@ group("unittest") { "ans_notification_annex_test:unittest", "ans_notification_test:unittest", "ans_subscriber_proxy_test:unittest", - "ans_subscriber_stub_test:unittest", ] } diff --git a/frameworks/core/test/unittest/ans_subscriber_stub_test/BUILD.gn b/frameworks/core/test/unittest/ans_subscriber_stub_test/BUILD.gn deleted file mode 100644 index a949040500505f56c58110d7d03c5243f2a56022..0000000000000000000000000000000000000000 --- a/frameworks/core/test/unittest/ans_subscriber_stub_test/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2022 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("//base/notification/distributed_notification_service/notification.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -module_output_path = "${component_name}/unittest" - -ohos_unittest("ans_subscriber_stub_test") { - module_out_path = module_output_path - include_dirs = [ - "${core_path}/include", - "//commonlibrary/c_utils/base/include", - ] - - sources = [ "ans_subscriber_stub_unit_test.cpp" ] - - deps = [ "${core_path}:ans_core" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "ability_runtime:wantagent_innerkits", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] - - subsystem_name = "${subsystem_name}" - part_name = "${component_name}" -} - -group("unittest") { - testonly = true - deps = [] - - deps += [ ":ans_subscriber_stub_test" ] -} diff --git a/frameworks/core/test/unittest/ans_subscriber_stub_test/ans_subscriber_stub_unit_test.cpp b/frameworks/core/test/unittest/ans_subscriber_stub_test/ans_subscriber_stub_unit_test.cpp deleted file mode 100644 index 8c2dc96f748be0f24b896729a724ec81d5738707..0000000000000000000000000000000000000000 --- a/frameworks/core/test/unittest/ans_subscriber_stub_test/ans_subscriber_stub_unit_test.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (c) 2021 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 - -#define private public -#define protected public -#include "ans_subscriber_stub.h" -#include "ans_inner_errors.h" -#include "ans_notification.h" -#undef private -#undef protected - -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" - -using namespace testing; -using namespace testing::ext; -namespace OHOS { -namespace Notification { -class AnsSubscriberStubUnitTest : public testing::Test { -public: - AnsSubscriberStubUnitTest() {} - - virtual ~AnsSubscriberStubUnitTest() {} - - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp() override; - - void TearDown() override; - - sptr stub_; -}; - -void AnsSubscriberStubUnitTest::SetUpTestCase() -{ -} - -void AnsSubscriberStubUnitTest::TearDownTestCase() -{ -} - -void AnsSubscriberStubUnitTest::SetUp() -{ - stub_ = new AnsSubscriberStub(); -} - -void AnsSubscriberStubUnitTest::TearDown() -{ -} - -/** -* @tc.name: OnRemoteRequest01 -* @tc.desc: test descriptor check failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, OnRemoteRequest01, Function | MediumTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool bRet = data.WriteInterfaceToken(u"error descriptor"); - EXPECT_TRUE(bRet) << "write token error"; - uint32_t code = static_cast(AnsSubscriberInterface::TransactId::ON_CONNECTED); - - ErrCode res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, OBJECT_NULL) << "descriptor error"; -} - -/** -* @tc.name: OnRemoteRequest02 -* @tc.desc: test code error -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, OnRemoteRequest02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - data.WriteInterfaceToken(AnsSubscriberStub::GetDescriptor()); - - - uint32_t code = static_cast(AnsSubscriberInterface::TransactId::ON_BADGE_CHANGED + 1); - - ErrCode res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_TRUE(res != NO_ERROR); -} - -/** -* @tc.name: OnRemoteRequest03 -* @tc.desc: test function error -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, OnRemoteRequest03, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - data.WriteInterfaceToken(AnsSubscriberStub::GetDescriptor()); - uint32_t code = static_cast(AnsSubscriberInterface::TransactId::ON_ENABLED_NOTIFICATION_CHANGED); - stub_->interfaces_[AnsSubscriberInterface::TransactId::ON_ENABLED_NOTIFICATION_CHANGED] = nullptr; - ErrCode res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_TRUE(res != NO_ERROR); -} - -/** -* @tc.name: OnRemoteRequest04 -* @tc.desc: test ON_CONNECTED success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, OnRemoteRequest04, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - data.WriteInterfaceToken(AnsSubscriberStub::GetDescriptor()); - uint32_t code = static_cast(AnsSubscriberInterface::TransactId::ON_CONNECTED); - ErrCode res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, NO_ERROR); -} - -/** -* @tc.name: HandleOnConnected -* @tc.desc: test HandleOnConnected success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnConnected, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnConnected(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnDisconnected -* @tc.desc: test HandleOnDisconnected success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnDisconnected, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnDisconnected(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnConsumedMap01 -* @tc.desc: test notification failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnConsumedMap01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnConsumedMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnConsumedMap02 -* @tc.desc: test read existMap failed -* @tc.type: Fun -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnConsumedMap02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - - ErrCode res = stub_->HandleOnConsumedMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnConsumedMap03 -* @tc.desc: test read NotificationSortingMap failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnConsumedMap03, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - bool existMap = true; - data.WriteBool(existMap); - - ErrCode res = stub_->HandleOnConsumedMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnConsumedMap04 -* @tc.desc: test HandleOnConsumedMap success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnConsumedMap04, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - bool existMap = true; - data.WriteBool(existMap); - sptr notificationSortingMap = new NotificationSortingMap(); - data.WriteParcelable(notificationSortingMap); - - ErrCode res = stub_->HandleOnConsumedMap(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnCanceledMap01 -* @tc.desc: test notification failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnCanceledMap01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnCanceledMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnCanceledMap02 -* @tc.desc: test read existMap failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnCanceledMap02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - - ErrCode res = stub_->HandleOnCanceledMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnCanceledMap03 -* @tc.desc: test read NotificationSortingMap failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnCanceledMap03, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - bool existMap = true; - data.WriteBool(existMap); - - ErrCode res = stub_->HandleOnCanceledMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnCanceledMap04 -* @tc.desc: test read reason failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnCanceledMap04, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - bool existMap = true; - data.WriteBool(existMap); - sptr notificationSortingMap = new NotificationSortingMap(); - data.WriteParcelable(notificationSortingMap); - - ErrCode res = stub_->HandleOnCanceledMap(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnCanceledMap05 -* @tc.desc: test HandleOnCanceledMap success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnCanceledMap05, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notification = new Notification(); - data.WriteParcelable(notification); - bool existMap = true; - data.WriteBool(existMap); - sptr notificationSortingMap = new NotificationSortingMap(); - data.WriteParcelable(notificationSortingMap); - int32_t reason = 0; - data.WriteInt32(reason); - - ErrCode res = stub_->HandleOnCanceledMap(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnUpdated01 -* @tc.desc: test notificationMap failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnUpdated01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnUpdated(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnUpdated02 -* @tc.desc: test HandleOnUpdated success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnUpdated02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notificationMap = new NotificationSortingMap(); - data.WriteParcelable(notificationMap); - - ErrCode res = stub_->HandleOnUpdated(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnDoNotDisturbDateChange01 -* @tc.desc: test callbackData failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnDoNotDisturbDateChange01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnDoNotDisturbDateChange(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnDoNotDisturbDateChange02 -* @tc.desc: test HandleOnDoNotDisturbDateChange success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnDoNotDisturbDateChange02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notifcallbackDataication = new EnabledNotificationCallbackData(); - data.WriteParcelable(notifcallbackDataication); - - ErrCode res = stub_->HandleOnDoNotDisturbDateChange(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** -* @tc.name: HandleOnEnabledNotificationChanged01 -* @tc.desc: test callbackData failed -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnEnabledNotificationChanged01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnEnabledNotificationChanged(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** -* @tc.name: HandleOnEnabledNotificationChanged02 -* @tc.desc: test HandleOnEnabledNotificationChanged success -* @tc.type: Fun -*/ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnEnabledNotificationChanged02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr notifcallbackDataication = new EnabledNotificationCallbackData(); - data.WriteParcelable(notifcallbackDataication); - - ErrCode res = stub_->HandleOnEnabledNotificationChanged(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.name: HandleOnBadgeChanged01 - * @tc.desc: test callbackData failed - * @tc.type: Fun - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnBadgeChanged01, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode res = stub_->HandleOnBadgeChanged(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleOnBadgeChanged02 - * @tc.desc: test HandleOnBadgeChanged success - * @tc.type: Fun - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsSubscriberStubUnitTest, HandleOnBadgeChanged02, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - - sptr badgeData = new BadgeNumberCallbackData(); - data.WriteParcelable(badgeData); - - ErrCode res = stub_->HandleOnBadgeChanged(data, reply); - EXPECT_EQ(res, ERR_OK); -} -} -} diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 4f5b2f36cff5893e5a4d87aa2175f27b68ff6b60..2984f5fc29fcc7c1eba6516cf3bb0ba47380ed35 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -23,7 +23,6 @@ group("fuzztest") { "ansmanagerstubannexthree_fuzzer:AnsManagerStubAnnexThreeFuzzTest", "ansmanagerstubannextwo_fuzzer:AnsManagerStubAnnexTwoFuzzTest", "anssubscriberproxy_fuzzer:AnsSubscriberProxyFuzzTest", - "anssubscriberstub_fuzzer:AnsSubscriberStubFuzzTest", "cancelasbundle_fuzzer:CancelAsBundleFuzzTest", "cancelgroup_fuzzer:CancelGroupFuzzTest", "cancelnotification_fuzzer:CancelNotificationFuzzTest", diff --git a/test/fuzztest/anssubscriberstub_fuzzer/BUILD.gn b/test/fuzztest/anssubscriberstub_fuzzer/BUILD.gn deleted file mode 100644 index 2d73d3f0534f63c7f84e38a25029fd58735bd3a2..0000000000000000000000000000000000000000 --- a/test/fuzztest/anssubscriberstub_fuzzer/BUILD.gn +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AnsSubscriberStubFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "${component_path}/test/fuzztest/anssubscriberstub_fuzzer" - - include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "anssubscriberstub_fuzzer.cpp" ] - - deps = [ - "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", - "${frameworks_module_ans_path}:ans_innerkits", - "//base\notification\distributed_notification_service\frameworks\core:ans_core", - ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AnsSubscriberStubFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp deleted file mode 100644 index 98a9aa993b42d17318b970f87a65b22040614493..0000000000000000000000000000000000000000 --- a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#define private public -#define protected public -#include "ans_subscriber_stub.h" -#undef private -#undef protected -#include "anssubscriberstub_fuzzer.h" -#include "notification_request.h" - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) - { - Notification::AnsSubscriberStub ansSubscriberStub; - uint32_t code = GetU32Data(data); - MessageParcel datas; - MessageParcel reply; - MessageOption flags; - // test OnRemoteRequest function - ansSubscriberStub.OnRemoteRequest(code, datas, reply, flags); - // test HandleOnConnected function - ansSubscriberStub.HandleOnConnected(datas, reply); - // test HandleOnDisconnected function - ansSubscriberStub.HandleOnDisconnected(datas, reply); - // test HandleOnConsumedMap function - ansSubscriberStub.HandleOnConsumedMap(datas, reply); - // test HandleOnCanceledMap function - ansSubscriberStub.HandleOnCanceledMap(datas, reply); - // test HandleOnUpdated function - ansSubscriberStub.HandleOnUpdated(datas, reply); - // test HandleOnDoNotDisturbDateChange function - ansSubscriberStub.HandleOnDoNotDisturbDateChange(datas, reply); - // test HandleOnEnabledNotificationChanged function - ansSubscriberStub.HandleOnEnabledNotificationChanged(datas, reply); - // test OnConnected function - ansSubscriberStub.OnConnected(); - // test OnDisconnected function - ansSubscriberStub.OnDisconnected(); - // test OnConsumed function - sptr notification = new Notification::Notification(); - sptr notificationMap = new Notification::NotificationSortingMap(); - ansSubscriberStub.OnConsumed(notification, notificationMap); - // test OnCanceled function - int32_t deleteReason = 1; - ansSubscriberStub.OnCanceled(notification, notificationMap, deleteReason); - // test OnUpdated function - ansSubscriberStub.OnUpdated(notificationMap); - // test OnDoNotDisturbDateChange function - sptr date = new Notification::NotificationDoNotDisturbDate(); - ansSubscriberStub.OnDoNotDisturbDateChange(date); - // test OnEnabledNotificationChanged function - sptr callbackData = new Notification::EnabledNotificationCallbackData(); - return true; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - char *ch = ParseData(data, size); - if (ch != nullptr && size >= GetU32Size()) { - OHOS::DoSomethingInterestingWithMyAPI(ch, size); - free(ch); - ch = nullptr; - } - return 0; -} diff --git a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.h b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.h deleted file mode 100644 index ec87efa9b8a624fe9aa563fb2b8521a5abc38af7..0000000000000000000000000000000000000000 --- a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef TEST_FUZZTEST_ANSSUBSCRIBERSTUB_FUZZER_ANSSUBSCRIBERSTUB_FUZZER_H -#define TEST_FUZZTEST_ANSSUBSCRIBERSTUB_FUZZER_ANSSUBSCRIBERSTUB_FUZZER_H - -#include "fuzz_common_base.h" - -#define FUZZ_PROJECT_NAME "anssubscriberstub_fuzzer" - -#endif // TEST_FUZZTEST_ANSSUBSCRIBERSTUB_FUZZER_ANSSUBSCRIBERSTUB_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/anssubscriberstub_fuzzer/corpus/init b/test/fuzztest/anssubscriberstub_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/anssubscriberstub_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 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. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/anssubscriberstub_fuzzer/project.xml b/test/fuzztest/anssubscriberstub_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/anssubscriberstub_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - -