From f604041edf7e43dd4692512132cc9d98f61db5bf Mon Sep 17 00:00:00 2001 From: guxiang Date: Tue, 9 Sep 2025 22:23:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=BF=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=9B=B4=E6=96=B0=E4=BD=86=E8=B6=85=E8=BF=8710?= =?UTF-8?q?=E5=88=86=E9=92=9F=E4=BB=8D=E8=A2=AB=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: guxiang --- ...dvanced_notification_live_view_service.cpp | 12 +- ...ed_notification_live_view_service_test.cpp | 4 +- .../distributed_publish_service_v2.cpp | 6 +- services/distributed/test/unittest/BUILD.gn | 72 +--- ...stributed_publish_service_v2_unit_test.cpp | 61 ++++ .../test/unittest/mock/mock_request_box.cpp | 335 ++++++++++++++++++ .../test/unittest/mock/mock_request_box.h | 65 ++++ 7 files changed, 486 insertions(+), 69 deletions(-) create mode 100644 services/distributed/test/unittest/distributed_soft_bus_test/distributed_publish_service_v2_unit_test.cpp create mode 100644 services/distributed/test/unittest/mock/mock_request_box.cpp create mode 100644 services/distributed/test/unittest/mock/mock_request_box.h diff --git a/services/ans/src/advanced_notification_live_view_service.cpp b/services/ans/src/advanced_notification_live_view_service.cpp index b4e77d540..ec2958cc0 100644 --- a/services/ans/src/advanced_notification_live_view_service.cpp +++ b/services/ans/src/advanced_notification_live_view_service.cpp @@ -687,6 +687,8 @@ void AdvancedNotificationService::UpdateRecordByOwner( record->request->SetWantAgent(wantAgent); } uint64_t timerId = 0; + uint64_t process = NotificationConstant::DEFAULT_FINISH_STATUS; + CancelTimer(oldRecord->notification->GetFinishTimer()); if (isSystemApp) { record->request->SetContent(content); } else { @@ -694,16 +696,14 @@ void AdvancedNotificationService::UpdateRecordByOwner( auto data = downloadTemplate->GetTemplateData(); AAFwk::WantParamWrapper wrapper(*data); ANS_LOGD("Update the template data: %{public}s.", wrapper.ToString().c_str()); - CancelTimer(oldRecord->notification->GetFinishTimer()); - uint64_t process = 0; if (data->HasParam(PROGRESS_VALUE)) { process = data->GetIntParam(PROGRESS_VALUE, 0); } - StartFinishTimerForUpdate(record, process); - timerId = record->notification->GetFinishTimer(); - ANS_LOGI("TimerForUpdate,oldTimeId:%{public}d,newTimeId:%{public}d", - (int)(oldRecord->notification->GetFinishTimer()), (int)timerId); } + StartFinishTimerForUpdate(record, process); + timerId = record->notification->GetFinishTimer(); + ANS_LOGI("TimerForUpdate,oldTimeId: %{public}llu, newTimeId: %{public}llu", + oldRecord->notification->GetFinishTimer(), timerId); record->notification = new (std::nothrow) Notification(record->request); if (record->notification == nullptr) { ANS_LOGE("Failed to create notification."); diff --git a/services/ans/test/unittest/advanced_notification_live_view_service_test.cpp b/services/ans/test/unittest/advanced_notification_live_view_service_test.cpp index 4fad67980..47de5d978 100644 --- a/services/ans/test/unittest/advanced_notification_live_view_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_live_view_service_test.cpp @@ -654,7 +654,7 @@ HWTEST_F(AnsLiveViewServiceTest, UpdateRecordByOwner_100, Function | SmallTest | /** * @tc.name: UpdateRecordByOwner_200 - * @tc.desc: Test UpdateRecordByOwner when isSystem is true and timerId is 0 + * @tc.desc: Test UpdateRecordByOwner when isSystem is true and timerId is not 0 * @tc.type: FUNC */ HWTEST_F(AnsLiveViewServiceTest, UpdateRecordByOwner_200, Function | SmallTest | Level1) @@ -684,7 +684,7 @@ HWTEST_F(AnsLiveViewServiceTest, UpdateRecordByOwner_200, Function | SmallTest | advancedNotificationService_->UpdateRecordByOwner(record, isSystem); auto ret = record->notification->GetFinishTimer(); - ASSERT_EQ(ret, 0); + ASSERT_NE(ret, 0); } /** diff --git a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp index d27d4e2bc..6d669f6c2 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp @@ -585,7 +585,8 @@ void DistributedPublishService::SetNotificationButtons(const sptr buttonsTitle; size_t length = actionButtons.size(); @@ -857,7 +858,8 @@ void DistributedPublishService::MakeNotificationButtons(const NotificationReques NotificationConstant::SlotType slotType, sptr& request) { auto localDevice = DistributedDeviceService::GetInstance().GetLocalDevice(); - if ((localDevice.deviceType_ == DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD || + if ((localDevice.deviceType_ == DistributedHardware::DmDeviceType::DEVICE_TYPE_2IN1 || + localDevice.deviceType_ == DistributedHardware::DmDeviceType::DEVICE_TYPE_PAD || localDevice.deviceType_ == DistributedHardware::DmDeviceType::DEVICE_TYPE_PC)) { MakePadNotificationButtons(box, request); return; diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index 88541ce61..70336a1ba 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -1089,60 +1089,6 @@ ohos_unittest("distributed_helper_test") { part_name = "${component_name}" } -ohos_unittest("distributed_soft_bus_master_test") { - module_out_path = module_output_path - include_dirs = [ - "/${services_path}/distributed/include/soft_bus", - "/${services_path}/distributed/include/base", - "/${services_path}/distributed/include/helper", - "/${services_path}/distributed/include/tlv_box", - ] - - sources = [ - "/${services_path}/distributed/src/helper/analytics_util.cpp", - "/${services_path}/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp", - "/${services_path}/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp", - "/${services_path}/distributed/src/soft_bus/distributed_device_service.cpp", - "distributed_soft_bus_test/distributed_unlock_listener_oper_service_unit_test.cpp", ] - - deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] - - external_deps = [ - "ability_base:zuri", - "ability_runtime:ability_manager", - "ability_runtime:runtime", - "ability_runtime:uri_permission_mgr", - "access_token:libaccesstoken_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "c_utils:utils", - "device_manager:devicemanagersdk", - "dsoftbus:softbus_client", - "ffrt:libffrt", - "hilog:libhilog", - "kv_store:distributeddata_inner", - "os_account:os_account_innerkits", - "power_manager:powermgr_client", - "relational_store:native_rdb", - "samgr:samgr_proxy", - "time_service:time_client", - "zlib:libz", - ] - - defines = [] - if (screenlock_mgr_enable) { - external_deps += [ "screenlock_mgr:screenlock_client" ] - defines += [ "SCREENLOCK_MGR_ENABLE" ] - } - - if (distributed_notification_service_feature_phone_collaboration) { - defines += [ "DISTRIBUTED_FEATURE_MASTER" ] - } - - subsystem_name = "${subsystem_name}" - part_name = "${component_name}" -} - ohos_unittest("distributed_soft_bus_test") { module_out_path = module_output_path include_dirs = [ @@ -1152,22 +1098,23 @@ ohos_unittest("distributed_soft_bus_test") { "/${services_path}/distributed/include/helper", "/${services_path}/distributed/include/tlv_box", "/${services_path}/distributed/include/base", + "mock", ] sources = [ + "/${services_path}/distributed/src/helper/analytics_util.cpp", + "/${services_path}/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp", + "/${services_path}/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp", + "/${services_path}/distributed/src/soft_bus/distributed_device_service.cpp", "/${services_path}/distributed/src/tlv_box/box_base.cpp", "/${services_path}/distributed/src/soft_bus/distributed_operation_service.cpp", "/${services_path}/distributed/src/tlv_box/response_box.cpp", "/${services_path}/distributed/src/tlv_box/tlv_box.cpp", - "/${services_path}/distributed/src/soft_bus/distributed_device_service.cpp", - "/${services_path}/distributed/src/base/distributed_liveview_all_scenarios_extension_wrapper.cpp", "/${services_path}/distributed/src/base/distributed_client.cpp", "/${services_path}/distributed/src/base/distributed_server.cpp", - "/${services_path}/distributed/src/helper/analytics_util.cpp", "/${services_path}/distributed/src/base/distributed_socket.cpp", "/${services_path}/distributed/src/soft_bus/distributed_service.cpp", "/${services_path}/distributed/src/tlv_box/match_box.cpp", - "/${services_path}/distributed/src/base/distributed_send_adapter.cpp", "/${services_path}/distributed/src/soft_bus/distributed_observer_service.cpp", "/${services_path}/distributed/src/tlv_box/state_box.cpp", "/${services_path}/distributed/src/soft_bus/distributed_publish_service_v2.cpp", @@ -1182,7 +1129,10 @@ ohos_unittest("distributed_soft_bus_test") { "/${services_path}/distributed/src/soft_bus/distributed_subscriber.cpp", "/${services_path}/distributed/src/tlv_box/bundle_icon_box.cpp", "/${services_path}/distributed/src/base/distributed_local_config.cpp", + "mock/mock_request_box.cpp", "distributed_soft_bus_test/distributed_operation_service_unit_test.cpp", + "distributed_soft_bus_test/distributed_publish_service_v2_unit_test.cpp", + "distributed_soft_bus_test/distributed_unlock_listener_oper_service_unit_test.cpp", ] deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] @@ -1215,6 +1165,10 @@ ohos_unittest("distributed_soft_bus_test") { defines += [ "SCREENLOCK_MGR_ENABLE" ] } + if (distributed_notification_service_feature_phone_collaboration) { + defines += [ "DISTRIBUTED_FEATURE_MASTER" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" -} +} \ No newline at end of file diff --git a/services/distributed/test/unittest/distributed_soft_bus_test/distributed_publish_service_v2_unit_test.cpp b/services/distributed/test/unittest/distributed_soft_bus_test/distributed_publish_service_v2_unit_test.cpp new file mode 100644 index 000000000..b15c0605e --- /dev/null +++ b/services/distributed/test/unittest/distributed_soft_bus_test/distributed_publish_service_v2_unit_test.cpp @@ -0,0 +1,61 @@ +/* + * 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 + +#define private public +#define protected public +#include "distributed_publish_service.h" +#undef private +#undef protected +#include "mock_request_box.h" + +using namespace testing::ext; +namespace OHOS { +namespace Notification { +class DistributedPublishServiceV2Test : public testing::Test { +public: + static void SetUpTestCase() {} + static void TearDownTestCase() {} + void SetUp() {} + void TearDown() {} +}; + +/** + * @tc.name: SetNotificationButtons_0100 + * @tc.desc: Test SetNotificationButtons success. + * @tc.type: FUNC + */ +HWTEST_F(DistributedPublishServiceV2Test, SetNotificationButtons_0100, Function | SmallTest | Level1) +{ + sptr request = new (std::nothrow) NotificationRequest(); + std::shared_ptr actionButton1 = + NotificationActionButton::Create(nullptr, "title", nullptr); + request->AddActionButton(actionButton1); + std::shared_ptr actionButton2 = + NotificationActionButton::Create(nullptr, "title2", nullptr); + request->AddActionButton(actionButton2); + std::shared_ptr requestBox = std::make_shared(); + DistributedPublishService::GetInstance().SetNotificationButtons( + request, DistributedHardware::DmDeviceType::DEVICE_TYPE_2IN1, + NotificationConstant::SlotType::SOCIAL_COMMUNICATION, requestBox); + std::shared_ptr mockRequest = std::make_shared(); + mockRequest->box_ = requestBox->box_; + std::vector buttonsTitle; + mockRequest->GetActionButtonsTitle(buttonsTitle); + EXPECT_EQ(buttonsTitle.size(), 2); +} +} +} \ No newline at end of file diff --git a/services/distributed/test/unittest/mock/mock_request_box.cpp b/services/distributed/test/unittest/mock/mock_request_box.cpp new file mode 100644 index 000000000..9ab427680 --- /dev/null +++ b/services/distributed/test/unittest/mock/mock_request_box.cpp @@ -0,0 +1,335 @@ +/* + * 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 "mock_request_box.h" + +#include "ans_image_util.h" +#include "ans_log_wrapper.h" +#include "distributed_liveview_all_scenarios_extension_wrapper.h" +#include "distributed_local_config.h" +#include "notification_constant.h" + +namespace OHOS { +namespace Notification { +bool MockNotificationRequestBox::GetNotificationHashCode(std::string& hasdCode) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_HASHCODE, hasdCode); +} + +bool MockNotificationRequestBox::GetSlotType(int32_t& type) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(NOTIFICATION_SLOT_TYPE, type); +} + +bool MockNotificationRequestBox::GetContentType(int32_t& type) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(NOTIFICATION_CONTENT_TYPE, type); +} + +bool MockNotificationRequestBox::GetCreatorBundleName(std::string& bundleName) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(BUNDLE_NAME, bundleName); +} + +bool MockNotificationRequestBox::GetReminderFlag(int32_t& flag) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(NOTIFICATION_REMINDERFLAG, flag); +} + +bool MockNotificationRequestBox::GetNotificationTitle(std::string& title) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_TITLE, title); +} + +bool MockNotificationRequestBox::GetNotificationText(std::string& text) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_CONTENT, text); +} + +bool MockNotificationRequestBox::GetNotificationAdditionalText(std::string& text) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_ADDITIONAL_TEXT, text); +} + +bool MockNotificationRequestBox::GetNotificationBriefText(std::string& text) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_BRIEF_TEXT, text); +} + +bool MockNotificationRequestBox::GetNotificationExpandedTitle(std::string& text) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_EXPANDED_TITLE, text); +} + +bool MockNotificationRequestBox::GetNotificationLongText(std::string& text) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_LONG_TITLE, text); +} + +bool MockNotificationRequestBox::GetAllLineLength(int32_t& length) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(ALL_LINES_LENGTH, length); +} + +bool MockNotificationRequestBox::GetNotificationAllLines(std::vector& allLines) const +{ + int32_t length = 0; + if (!GetAllLineLength(length)) { + return false; + } + + if (length < 0 || length > MAX_LINES_NUM) { + ANS_LOGD("Invalid lines %{public}d.", length); + return false; + } + + for (int i = 0; i < length; i++) { + std::string line; + if (box_->GetStringValue(NOTIFICATION_ALL_LINES_START_INDEX + i, line)) { + allLines.push_back(line); + } + } + return true; +} + +bool MockNotificationRequestBox::GetNotificationBigPicture(std::shared_ptr& bigPicture) const +{ + return true; +} + +bool MockNotificationRequestBox::GetNotificationActionName(std::string& actionName) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(ACTION_BUTTON_NAME, actionName); +} + +bool MockNotificationRequestBox::GetNotificationUserInput(std::string& userInput) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(ACTION_USER_INPUT, userInput); +} + +bool MockNotificationRequestBox::GetSmallIcon(std::shared_ptr& smallIcon) const +{ + if (box_ == nullptr) { + return false; + } + std::vector buffer; + bool res = box_->GetBytes(BUNDLE_ICON, buffer); + ANS_LOGD("GetSmallIcon buffer size: %{public}d", static_cast(buffer.size())); + if (!res || buffer.size() <= 0) { + return false; + } + DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->UpdateLiveviewBinFile2PiexlMap(smallIcon, buffer); + if (smallIcon == nullptr) { + return false; + } + return true; +} + +bool MockNotificationRequestBox::GetBigIcon(std::shared_ptr& bigIcon, const int32_t deviceType) const +{ + if (box_ == nullptr) { + return false; + } + if (deviceType == DistributedHardware::DmDeviceType::DEVICE_TYPE_WATCH) { + std::string bigIconContent; + if (!box_->GetStringValue(NOTIFICATION_BIG_ICON, bigIconContent)) { + return false; + } + ANS_LOGD("GetBigIcon %{public}zu", bigIconContent.size()); + bigIcon = AnsImageUtil::UnPackImage(bigIconContent); + } else { + std::vector buffer; + bool res = box_->GetBytes(NOTIFICATION_BIG_ICON, buffer); + ANS_LOGD("GetBigIcon buffer size: %{public}d", static_cast(buffer.size())); + if (!res || buffer.size() <= 0) { + return false; + } + DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->UpdateLiveviewBinFile2PiexlMap(bigIcon, buffer); + } + if (bigIcon == nullptr) { + return false; + } + return true; +} + +bool MockNotificationRequestBox::GetOverlayIcon( + std::shared_ptr& overlayIcon, const int32_t deviceType) const +{ + if (box_ == nullptr) { + return false; + } + if (deviceType == DistributedHardware::DmDeviceType::DEVICE_TYPE_WATCH) { + std::string overlayContent; + if (!box_->GetStringValue(NOTIFICATION_OVERLAY_ICON, overlayContent)) { + return false; + } + ANS_LOGD("GetOverlayIcon %{public}zu", overlayContent.size()); + overlayIcon = AnsImageUtil::UnPackImage(overlayContent); + } else { + std::vector buffer; + bool res = box_->GetBytes(NOTIFICATION_OVERLAY_ICON, buffer); + ANS_LOGD("GetOverlayIcon buffer size: %{public}d", static_cast(buffer.size())); + if (!res || buffer.size() <= 0) { + return false; + } + DISTRIBUTED_LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->UpdateLiveviewBinFile2PiexlMap(overlayIcon, buffer); + } + if (overlayIcon == nullptr) { + return false; + } + return true; +} + +bool MockNotificationRequestBox::GetCommonLiveView(std::vector& byteSequence) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetBytes(NOTIFICATION_COMMON_LIVEVIEW, byteSequence); +} + +bool MockNotificationRequestBox::GetFinishTime(int64_t& time) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt64Value(FINISH_DEADLINE_TIME, time); +} + +bool MockNotificationRequestBox::GetAutoDeleteTime(int64_t& time) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt64Value(AUTO_DELETE_TIME, time); +} + +bool MockNotificationRequestBox::GetAppMessageId(std::string& appMessageId) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_APP_MESSAGE_ID, appMessageId); +} + +bool MockNotificationRequestBox::GetBoxExtendInfo(std::string& extendInfo) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(NOTIFICATION_EXTENDINFO, extendInfo); +} + +bool MockNotificationRequestBox::GetReceiverUserId(int32_t& userId) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(NOTIFICATION_RECEIVE_USERID, userId); +} + +bool MockNotificationRequestBox::GetDeviceUserId(int32_t& userId) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(LOCAL_DEVICE_USERID, userId); +} + +bool MockNotificationRequestBox::GetDeviceId(std::string& deviceId) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetStringValue(LOCAL_DEVICE_ID, deviceId); +} + +bool MockNotificationRequestBox::GetActionButtonsLength(int32_t& length) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(ACTION_BUTTONS_LENGTH, length); +} + +bool MockNotificationRequestBox::GetActionButtonsTitle(std::vector& buttonsTitle) const +{ + if (box_ == nullptr) { + return false; + } + int32_t length = 0; + if (!GetActionButtonsLength(length) || length > NotificationConstant::MAX_BTN_NUM) { + return false; + } + for (int i = 0; i < length; i++) { + std::string buttonTitle = ""; + box_->GetStringValue(ACTION_BUTTONS_TITILE_INDEX + i, buttonTitle); + buttonsTitle.push_back(buttonTitle); + } + return true; +} + +bool MockNotificationRequestBox::GetNotificationBasicInfo(std::string& basicInfo) const +{ + if (box_ == nullptr) { + return false; + } + + return box_->GetStringValue(NOTIFICATION_BASIC_INFO, basicInfo); +} +} +} \ No newline at end of file diff --git a/services/distributed/test/unittest/mock/mock_request_box.h b/services/distributed/test/unittest/mock/mock_request_box.h new file mode 100644 index 000000000..dba315085 --- /dev/null +++ b/services/distributed/test/unittest/mock/mock_request_box.h @@ -0,0 +1,65 @@ +/* + * 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. + */ + +#ifndef MOCK_REQUEST_BOX_H +#define MOCK_REQUEST_BOX_H + +#include +#include +#include +#include "pixel_map.h" +#include "tlv_box.h" +#include "box_base.h" + +namespace OHOS { +namespace Notification { +class MockNotificationRequestBox : public BoxBase { +public: + bool GetNotificationHashCode(std::string& hasdCode) const; + bool GetSlotType(int32_t& type) const; + bool GetContentType(int32_t& type) const; + bool GetReminderFlag(int32_t& flag) const; + bool GetCreatorBundleName(std::string& bundleName) const; + bool GetNotificationTitle(std::string& title) const; + bool GetNotificationText(std::string& text) const; + bool GetNotificationAdditionalText(std::string& text) const; + bool GetNotificationBriefText(std::string& text) const; + bool GetNotificationExpandedTitle(std::string& text) const; + bool GetNotificationLongText(std::string& text) const; + bool GetAllLineLength(int32_t& length) const; + bool GetNotificationAllLines(std::vector& allLines) const; + bool GetNotificationBigPicture(std::shared_ptr& bigPicture) const; + bool GetNotificationActionName(std::string& actionName) const; + bool GetNotificationUserInput(std::string& userInput) const; + bool GetSmallIcon(std::shared_ptr& smallIcon) const; + bool GetBigIcon(std::shared_ptr& bigIcon, const int32_t deviceType) const; + bool GetOverlayIcon(std::shared_ptr& overlayIcon, const int32_t deviceType) const; + bool GetCommonLiveView(std::vector& byteSequence) const; + bool GetFinishTime(int64_t& time) const; + bool GetAutoDeleteTime(int64_t& time) const; + bool GetAppMessageId(std::string& appMessageId) const; + bool GetReceiverUserId(int32_t& userId) const; + bool GetBoxExtendInfo(std::string& extendInfo) const; + bool GetDeviceUserId(int32_t& userId) const; + bool GetDeviceId(std::string& deviceId) const; + bool GetActionButtonsLength(int32_t& length) const; + bool GetActionButtonsTitle(std::vector& buttonsTitle) const; + bool GetNotificationBasicInfo(std::string& basicInfo) const; + + static int32_t MAX_LINES_NUM = 7; +}; +} // namespace Notification +} // namespace OHOS +#endif // MOCK_REQUEST_BOX_H \ No newline at end of file -- Gitee