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