1 /* 2 * Copyright (c) 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 OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_IMPL_H 17 #define OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_IMPL_H 18 19 #include "bundle_mgr_interface.h" 20 #include "context_impl.h" 21 22 namespace OHOS { 23 namespace AbilityRuntime { 24 class MockContextImpl : public ContextImpl { 25 public: 26 MockContextImpl() = default; 27 virtual ~MockContextImpl() = default; 28 29 std::string GetBundleName() const override; 30 31 std::string GetBundleCodeDir() override; 32 33 std::string GetCacheDir() override; 34 35 bool IsUpdatingConfigurations() override; 36 37 bool PrintDrawnCompleted() override; 38 39 std::string GetTempDir() override; 40 41 std::string GetFilesDir() override; 42 43 std::string GetDatabaseDir() override; 44 45 std::string GetPreferencesDir() override; 46 47 std::string GetDistributedFilesDir() override; 48 49 std::shared_ptr<Context> CreateModuleContext(const std::string &moduleName) override; 50 51 std::shared_ptr<Context> CreateModuleContext(const std::string &bundleName, const std::string &moduleName) override; 52 53 int GetArea() override; 54 55 std::shared_ptr<Context> CreateBundleContext(const std::string &bundleName) override; 56 57 sptr<AppExecFwk::IBundleMgr> GetBundleManager() const; 58 59 void SetApplicationInfo(const std::shared_ptr<AppExecFwk::ApplicationInfo> &info); 60 61 62 void SetParentContext(const std::shared_ptr<Context> &context); 63 64 std::string GetBundleCodePath() const override; 65 66 void InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo); 67 68 std::string GetBaseDir() const override; 69 70 Global::Resource::DeviceType GetDeviceType() const override; 71 72 std::shared_ptr<AppExecFwk::ApplicationInfo> GetApplicationInfo() const override; 73 74 std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override; 75 76 std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override; 77 }; 78 } // namespace AbilityRuntime 79 } // namespace OHOS 80 #endif // OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_IMPL_H