1 /* 2 * Copyright (c) 2022-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 #ifndef MOCK_BUNDLE_MANAGER_H 17 #define MOCK_BUNDLE_MANAGER_H 18 19 #include <gmock/gmock.h> 20 #include <vector> 21 22 #include "ability_info.h" 23 #include "application_info.h" 24 #include "bundlemgr/bundle_mgr_interface.h" 25 #include "iremote_proxy.h" 26 #include "iremote_stub.h" 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 class BundleMgrProxy : public IRemoteProxy<IBundleMgr> { 31 public: BundleMgrProxy(const sptr<IRemoteObject> & impl)32 explicit BundleMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IBundleMgr>(impl) {} ~BundleMgrProxy()33 virtual ~BundleMgrProxy() {} 34 35 bool GetBundleInfo(const std::string &bundleName, 36 const BundleFlag flag, 37 BundleInfo &bundleInfo, 38 int32_t userId) override; 39 }; 40 41 class BundleMgrStub : public IRemoteStub<IBundleMgr> { 42 public: BundleMgrStub()43 BundleMgrStub() {}; ~BundleMgrStub()44 virtual ~BundleMgrStub() {} 45 virtual int OnRemoteRequest(uint32_t code, 46 MessageParcel &data, 47 MessageParcel &reply, 48 MessageOption &option) override; 49 50 virtual bool GetBundleInfo(const std::string &bundleName, 51 const BundleFlag flag, 52 BundleInfo &bundleInfo, 53 int32_t userId = Constants::UNSPECIFIED_USERID) override; 54 55 virtual bool GetBundleInfo(const std::string &bundleName, 56 int32_t flags, 57 BundleInfo &bundleInfo, 58 int32_t userId = Constants::UNSPECIFIED_USERID) override; 59 60 virtual bool GetApplicationInfos(const ApplicationFlag flag, 61 int userId, 62 std::vector<ApplicationInfo> &appInfos) override; 63 }; 64 } // namespace AppExecFwk 65 } // namespace OHOS 66 #endif // MOCK_BUNDLE_MANAGER_H