• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "advanced_notification_service.h"
17 #include "ans_inner_errors.h"
18 
19 namespace {
20     bool g_mockGetDistributedEnableInApplicationInfoRet = true;
21     bool g_mockAppInfoEnableRet = true;
22 }
23 
MockGetDistributedEnableInApplicationInfo(bool mockRet,uint8_t mockCase=0)24 void MockGetDistributedEnableInApplicationInfo(bool mockRet, uint8_t mockCase = 0)
25 {
26     g_mockGetDistributedEnableInApplicationInfoRet = mockRet;
27     switch (mockCase) {
28         case 1: { // mock for appInfoEnable
29             g_mockAppInfoEnableRet = true;
30             break;
31         }
32         default:{
33             g_mockAppInfoEnableRet = false;
34             break;
35         }
36     }
37 }
38 
39 namespace OHOS {
40 namespace Notification {
41 #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED
GetDistributedEnableInApplicationInfo(const sptr<NotificationBundleOption> bundleOption,bool & enable)42 ErrCode AdvancedNotificationService::GetDistributedEnableInApplicationInfo(
43     const sptr<NotificationBundleOption> bundleOption, bool &enable)
44 {
45     enable = g_mockAppInfoEnableRet;
46     if (g_mockGetDistributedEnableInApplicationInfoRet == false) {
47         return ERR_ANS_INVALID_PARAM;
48     }
49     return ERR_OK;
50 }
51 #endif
52 }  // namespace Notification
53 }  // namespace OHOS
54