• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "mock_reminder_data_manager.h"
17 
18 #include "reminder_data_manager.h"
19 
20 namespace OHOS::Notification {
21 namespace {
22 int32_t g_mockPublishReminderRet = 0;
23 int32_t g_mockCancelReminderRet = 0;
24 int32_t g_mockCancelAllRemindersRet = 0;
25 int32_t g_mockAddExcludeDateRet = 0;
26 int32_t g_mockDelExcludeDatesRet = 0;
27 int32_t g_mockGetExcludeDatesRet = 0;
28 int32_t g_mockQueryActiveReminderCountRet = 0;
29 }
30 
MockPublishReminder(const int32_t ret)31 void MockReminderDataManager::MockPublishReminder(const int32_t ret)
32 {
33     g_mockPublishReminderRet = ret;
34 }
35 
MockCancelReminder(const int32_t ret)36 void MockReminderDataManager::MockCancelReminder(const int32_t ret)
37 {
38     g_mockCancelReminderRet = ret;
39 }
40 
MockCancelAllReminders(const int32_t ret)41 void MockReminderDataManager::MockCancelAllReminders(const int32_t ret)
42 {
43     g_mockCancelAllRemindersRet = ret;
44 }
45 
MockAddExcludeDate(const int32_t ret)46 void MockReminderDataManager::MockAddExcludeDate(const int32_t ret)
47 {
48     g_mockAddExcludeDateRet = ret;
49 }
50 
MockDelExcludeDates(const int32_t ret)51 void MockReminderDataManager::MockDelExcludeDates(const int32_t ret)
52 {
53     g_mockDelExcludeDatesRet = ret;
54 }
55 
MockGetExcludeDates(const int32_t ret)56 void MockReminderDataManager::MockGetExcludeDates(const int32_t ret)
57 {
58     g_mockGetExcludeDatesRet = ret;
59 }
60 
MockQueryActiveReminderCount(const int32_t ret)61 void MockReminderDataManager::MockQueryActiveReminderCount(const int32_t ret)
62 {
63     g_mockQueryActiveReminderCountRet = ret;
64 }
65 
66 std::shared_ptr<ReminderDataManager> ReminderDataManager::REMINDER_DATA_MANAGER = nullptr;
ReminderDataManager()67 ReminderDataManager::ReminderDataManager()
68 {}
69 
~ReminderDataManager()70 ReminderDataManager::~ReminderDataManager()
71 {}
72 
GetInstance()73 std::shared_ptr<ReminderDataManager> ReminderDataManager::GetInstance()
74 {
75     return REMINDER_DATA_MANAGER;
76 }
77 
InitInstance()78 std::shared_ptr<ReminderDataManager> ReminderDataManager::InitInstance()
79 {
80     if (REMINDER_DATA_MANAGER == nullptr) {
81         REMINDER_DATA_MANAGER = std::make_shared<ReminderDataManager>();
82     }
83     return REMINDER_DATA_MANAGER;
84 }
85 
PublishReminder(const sptr<ReminderRequest> & reminder,const int32_t callingUid)86 ErrCode ReminderDataManager::PublishReminder(const sptr<ReminderRequest>& reminder,
87     const int32_t callingUid)
88 {
89     return g_mockPublishReminderRet;
90 }
91 
CancelReminder(const int32_t & reminderId,const int32_t callingUid)92 ErrCode ReminderDataManager::CancelReminder(const int32_t& reminderId, const int32_t callingUid)
93 {
94     return g_mockCancelReminderRet;
95 }
96 
CancelAllReminders(const std::string & packageName,const int32_t userId,const int32_t uid)97 ErrCode ReminderDataManager::CancelAllReminders(const std::string& packageName, const int32_t userId,
98     const int32_t uid)
99 {
100     return g_mockCancelAllRemindersRet;
101 }
102 
GetValidReminders(const int32_t callingUid,std::vector<ReminderRequestAdaptation> & reminders)103 void ReminderDataManager::GetValidReminders(const int32_t callingUid,
104     std::vector<ReminderRequestAdaptation>& reminders)
105 {}
106 
AddExcludeDate(const int32_t reminderId,const int64_t date,const int32_t callingUid)107 ErrCode ReminderDataManager::AddExcludeDate(const int32_t reminderId, const int64_t date,
108     const int32_t callingUid)
109 {
110     return g_mockAddExcludeDateRet;
111 }
112 
DelExcludeDates(const int32_t reminderId,const int32_t callingUid)113 ErrCode ReminderDataManager::DelExcludeDates(const int32_t reminderId, const int32_t callingUid)
114 {
115     return g_mockDelExcludeDatesRet;
116 }
117 
GetExcludeDates(const int32_t reminderId,const int32_t callingUid,std::vector<int64_t> & dates)118 ErrCode ReminderDataManager::GetExcludeDates(const int32_t reminderId, const int32_t callingUid,
119     std::vector<int64_t>& dates)
120 {
121     return g_mockGetExcludeDatesRet;
122 }
123 
QueryActiveReminderCount()124 int32_t ReminderDataManager::QueryActiveReminderCount()
125 {
126     return g_mockQueryActiveReminderCountRet;
127 }
128 } // namespace OHOS::Notification