• 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_mockUpdateReminderRet = 0;
24 int32_t g_mockCancelReminderRet = 0;
25 int32_t g_mockCancelAllRemindersRet = 0;
26 int32_t g_mockAddExcludeDateRet = 0;
27 int32_t g_mockDelExcludeDatesRet = 0;
28 int32_t g_mockGetExcludeDatesRet = 0;
29 int32_t g_mockQueryActiveReminderCountRet = 0;
30 }
31 
MockPublishReminder(const int32_t ret)32 void MockReminderDataManager::MockPublishReminder(const int32_t ret)
33 {
34     g_mockPublishReminderRet = ret;
35 }
36 
MockUpdateReminder(const int32_t ret)37 void MockReminderDataManager::MockUpdateReminder(const int32_t ret)
38 {
39     g_mockUpdateReminderRet = ret;
40 }
41 
MockCancelReminder(const int32_t ret)42 void MockReminderDataManager::MockCancelReminder(const int32_t ret)
43 {
44     g_mockCancelReminderRet = ret;
45 }
46 
MockCancelAllReminders(const int32_t ret)47 void MockReminderDataManager::MockCancelAllReminders(const int32_t ret)
48 {
49     g_mockCancelAllRemindersRet = ret;
50 }
51 
MockAddExcludeDate(const int32_t ret)52 void MockReminderDataManager::MockAddExcludeDate(const int32_t ret)
53 {
54     g_mockAddExcludeDateRet = ret;
55 }
56 
MockDelExcludeDates(const int32_t ret)57 void MockReminderDataManager::MockDelExcludeDates(const int32_t ret)
58 {
59     g_mockDelExcludeDatesRet = ret;
60 }
61 
MockGetExcludeDates(const int32_t ret)62 void MockReminderDataManager::MockGetExcludeDates(const int32_t ret)
63 {
64     g_mockGetExcludeDatesRet = ret;
65 }
66 
MockQueryActiveReminderCount(const int32_t ret)67 void MockReminderDataManager::MockQueryActiveReminderCount(const int32_t ret)
68 {
69     g_mockQueryActiveReminderCountRet = ret;
70 }
71 
72 std::shared_ptr<ReminderDataManager> ReminderDataManager::REMINDER_DATA_MANAGER = nullptr;
ReminderDataManager()73 ReminderDataManager::ReminderDataManager()
74 {}
75 
~ReminderDataManager()76 ReminderDataManager::~ReminderDataManager()
77 {}
78 
GetInstance()79 std::shared_ptr<ReminderDataManager> ReminderDataManager::GetInstance()
80 {
81     return REMINDER_DATA_MANAGER;
82 }
83 
InitInstance()84 std::shared_ptr<ReminderDataManager> ReminderDataManager::InitInstance()
85 {
86     if (REMINDER_DATA_MANAGER == nullptr) {
87         REMINDER_DATA_MANAGER = std::make_shared<ReminderDataManager>();
88     }
89     return REMINDER_DATA_MANAGER;
90 }
91 
PublishReminder(const sptr<ReminderRequest> & reminder,const int32_t callingUid)92 ErrCode ReminderDataManager::PublishReminder(const sptr<ReminderRequest>& reminder,
93     const int32_t callingUid)
94 {
95     return g_mockPublishReminderRet;
96 }
97 
UpdateReminder(const sptr<ReminderRequest> & reminder,const int32_t callingUid)98 ErrCode ReminderDataManager::UpdateReminder(const sptr<ReminderRequest>& reminder,
99     const int32_t callingUid)
100 {
101     return g_mockUpdateReminderRet;
102 }
103 
CancelReminder(const int32_t & reminderId,const int32_t callingUid)104 ErrCode ReminderDataManager::CancelReminder(const int32_t& reminderId, const int32_t callingUid)
105 {
106     return g_mockCancelReminderRet;
107 }
108 
CancelAllReminders(const std::string & packageName,const int32_t userId,const int32_t uid)109 ErrCode ReminderDataManager::CancelAllReminders(const std::string& packageName, const int32_t userId,
110     const int32_t uid)
111 {
112     return g_mockCancelAllRemindersRet;
113 }
114 
GetValidReminders(const int32_t callingUid,std::vector<ReminderRequestAdaptation> & reminders)115 void ReminderDataManager::GetValidReminders(const int32_t callingUid,
116     std::vector<ReminderRequestAdaptation>& reminders)
117 {}
118 
AddExcludeDate(const int32_t reminderId,const int64_t date,const int32_t callingUid)119 ErrCode ReminderDataManager::AddExcludeDate(const int32_t reminderId, const int64_t date,
120     const int32_t callingUid)
121 {
122     return g_mockAddExcludeDateRet;
123 }
124 
DelExcludeDates(const int32_t reminderId,const int32_t callingUid)125 ErrCode ReminderDataManager::DelExcludeDates(const int32_t reminderId, const int32_t callingUid)
126 {
127     return g_mockDelExcludeDatesRet;
128 }
129 
GetExcludeDates(const int32_t reminderId,const int32_t callingUid,std::vector<int64_t> & dates)130 ErrCode ReminderDataManager::GetExcludeDates(const int32_t reminderId, const int32_t callingUid,
131     std::vector<int64_t>& dates)
132 {
133     return g_mockGetExcludeDatesRet;
134 }
135 
QueryActiveReminderCount()136 int32_t ReminderDataManager::QueryActiveReminderCount()
137 {
138     return g_mockQueryActiveReminderCountRet;
139 }
140 } // namespace OHOS::Notification