1 /*
2 * Copyright (c) 2021 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_bundle_manager.h"
17
18 #include <functional>
19 #include <gtest/gtest.h>
20 #include "ans_ut_constant.h"
21
22 namespace OHOS {
23 namespace Notification {
24 namespace {
25 bool g_isNonBundleName = false;
26 }
27
MockIsNonBundleName(bool isNonBundleName)28 void MockIsNonBundleName(bool isNonBundleName)
29 {
30 g_isNonBundleName = isNonBundleName;
31 }
32 }
33 }
34
35 namespace OHOS {
36 namespace AppExecFwk {
GetNameForUid(const int uid,std::string & name)37 ErrCode BundleMgrProxy::GetNameForUid(const int uid, std::string &name)
38 {
39 GTEST_LOG_(INFO) << "mock GetNameForUid.";
40 name = Notification::g_isNonBundleName ? "": "bundleName";
41 return ERR_OK;
42 }
43
GetBundleInfo(const std::string & bundleName,const BundleFlag flag,BundleInfo & bundleInfo,int32_t userId)44 bool BundleMgrProxy::GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo,
45 int32_t userId)
46 {
47 return true;
48 }
49
GetUidByBundleName(const std::string & bundleName,const int userId)50 int BundleMgrProxy::GetUidByBundleName(const std::string &bundleName, const int userId)
51 {
52 if (userId == 0) {
53 return -1;
54 } else {
55 return Notification::NON_SYSTEM_APP_UID;
56 }
57 }
58
GetApplicationInfo(const std::string & appName,const ApplicationFlag flag,const int userId,ApplicationInfo & appInfo)59 bool BundleMgrProxy::GetApplicationInfo(
60 const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
61 {
62 appInfo.distributedNotificationEnabled = true;
63 return true;
64 }
65
66 } // namespace AppExecFwk
67 } // namespace OHOS