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 GetResourceDir() override; 42 43 std::string GetFilesDir() override; 44 45 std::string GetDatabaseDir() override; 46 47 std::string GetPreferencesDir() override; 48 49 int32_t GetSystemDatabaseDir(const std::string &groupId, bool checkExist, std::string &databaseDir) override; 50 51 int32_t GetSystemPreferencesDir(const std::string &groupId, bool checkExist, std::string &preferencesDir) override; 52 53 std::string GetDistributedFilesDir() override; 54 55 std::string GetCloudFileDir() override; 56 57 std::shared_ptr<Context> CreateModuleContext(const std::string &moduleName) override; 58 59 std::shared_ptr<Context> CreateModuleContext(const std::string &bundleName, const std::string &moduleName) override; 60 61 int32_t CreateSystemHspModuleResourceManager(const std::string &bundleName, 62 const std::string &moduleName, std::shared_ptr<Global::Resource::ResourceManager> &resourceManager) override; 63 64 int GetArea() override; 65 66 std::shared_ptr<Context> CreateBundleContext(const std::string &bundleName) override; 67 68 std::shared_ptr<Global::Resource::ResourceManager> CreateModuleResourceManager( 69 const std::string &bundleName, const std::string &moduleName) override; 70 71 sptr<AppExecFwk::IBundleMgr> GetBundleManager() const; 72 73 void SetApplicationInfo(const std::shared_ptr<AppExecFwk::ApplicationInfo> &info); 74 75 void SetParentContext(const std::shared_ptr<Context> &context); 76 77 std::string GetBundleCodePath() const override; 78 79 void InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo); 80 81 std::string GetBaseDir() const override; 82 83 Global::Resource::DeviceType GetDeviceType() const override; 84 85 std::shared_ptr<AppExecFwk::ApplicationInfo> GetApplicationInfo() const override; 86 87 std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override; 88 89 std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override; 90 91 std::string GetGroupDir(std::string groupId) override; 92 }; 93 } // namespace AbilityRuntime 94 } // namespace OHOS 95 #endif // OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_IMPL_H 96