1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#ifndef MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_H 17eace7efcSopenharmony_ci#define MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_H 18eace7efcSopenharmony_ci 19eace7efcSopenharmony_ci#include "context.h" 20eace7efcSopenharmony_ci#include "gmock/gmock.h" 21eace7efcSopenharmony_ci 22eace7efcSopenharmony_ciclass MockContext { 23eace7efcSopenharmony_cipublic: 24eace7efcSopenharmony_ci MockContext() = default; 25eace7efcSopenharmony_ci virtual ~MockContext() = default; 26eace7efcSopenharmony_ci MOCK_METHOD0(GetProcessInfo, std::shared_ptr<ProcessInfo>()); 27eace7efcSopenharmony_ci MOCK_METHOD0(GetApplicationInfo, std::shared_ptr<ApplicationInfo>()); 28eace7efcSopenharmony_ci MOCK_METHOD0(GetApplicationContext, std::shared_ptr<Context>()); 29eace7efcSopenharmony_ci MOCK_METHOD0(GetBundleCodePath, std::string()); 30eace7efcSopenharmony_ci MOCK_METHOD0(GetAbilityInfo, std::shared_ptr<AbilityInfo>()); 31eace7efcSopenharmony_ci MOCK_METHOD0(GetContext, std::shared_ptr<Context>()); 32eace7efcSopenharmony_ci MOCK_METHOD0(GetBundleManager, sptr<IBundleMgr>()); 33eace7efcSopenharmony_ci MOCK_METHOD0(GetResourceManager, std::shared_ptr<Global::Resource::ResourceManager>()); 34eace7efcSopenharmony_ci MOCK_METHOD1(DeleteFile, bool(const std::string& fileName)); 35eace7efcSopenharmony_ci MOCK_METHOD1(StopAbility, bool(const AAFwk::Want& want)); 36eace7efcSopenharmony_ci MOCK_METHOD0(GetCacheDir, std::string()); 37eace7efcSopenharmony_ci 38eace7efcSopenharmony_ci virtual std::string GetDatabaseDir() = 0; 39eace7efcSopenharmony_ci virtual std::string GetDataDir() = 0; 40eace7efcSopenharmony_ci virtual std::string GetDir(const std::string& name, int mode) = 0; 41eace7efcSopenharmony_ci virtual std::string GetExternalCacheDir() = 0; 42eace7efcSopenharmony_ci virtual std::string GetExternalFilesDir(std::string& type) = 0; 43eace7efcSopenharmony_ci virtual std::string GetFilesDir() = 0; 44eace7efcSopenharmony_ci virtual std::string GetNoBackupFilesDir() = 0; 45eace7efcSopenharmony_ci virtual int VerifyCallingPermission(const std::string& permission) = 0; 46eace7efcSopenharmony_ci virtual int VerifySelfPermission(const std::string& permission) = 0; 47eace7efcSopenharmony_ci virtual std::string GetBundleName() = 0; 48eace7efcSopenharmony_ci virtual std::string GetBundleResourcePath() = 0; 49eace7efcSopenharmony_ci virtual void StartAbility(const AAFwk::Want& want, int requestCode) = 0; 50eace7efcSopenharmony_ci virtual void UnauthUriPermission(const std::string& permission, const Uri& uri, int uid) = 0; 51eace7efcSopenharmony_ci virtual sptr<AAFwk::IAbilityManager> GetAbilityManager() = 0; 52eace7efcSopenharmony_ci virtual std::string GetAppType() = 0; 53eace7efcSopenharmony_ci virtual void TerminateAbility() = 0; 54eace7efcSopenharmony_ci virtual bool CanRequestPermission(const std::string& permission) = 0; 55eace7efcSopenharmony_ci virtual int VerifyCallingOrSelfPermission(const std::string& permission) = 0; 56eace7efcSopenharmony_ci virtual int VerifyPermission(const std::string& permission, int pid, int uid) = 0; 57eace7efcSopenharmony_ci virtual void SetPattern(int patternId) = 0; 58eace7efcSopenharmony_ci virtual std::shared_ptr<Context> GetAbilityPackageContext() = 0; 59eace7efcSopenharmony_ci virtual std::shared_ptr<HapModuleInfo> GetHapModuleInfo() = 0; 60eace7efcSopenharmony_ci virtual std::string GetProcessName() = 0; 61eace7efcSopenharmony_ci virtual std::string GetCallingBundle() = 0; 62eace7efcSopenharmony_ci virtual void RequestPermissionsFromUser(std::vector<std::string>& permissions, std::vector<int>& permissionsState, 63eace7efcSopenharmony_ci int requestCode) = 0; 64eace7efcSopenharmony_ci virtual void StartAbility(const Want& want, int requestCode, const AbilityStartSetting& abilityStartSetting) = 0; 65eace7efcSopenharmony_ci virtual bool ConnectAbility(const Want& want, const sptr<AAFwk::IAbilityConnection>& conn) = 0; 66eace7efcSopenharmony_ci virtual void DisconnectAbility(const sptr<AAFwk::IAbilityConnection>& conn) = 0; 67eace7efcSopenharmony_ci virtual Uri GetCaller() = 0; 68eace7efcSopenharmony_ci virtual std::string GetString(int resId) = 0; 69eace7efcSopenharmony_ci virtual std::vector<std::string> GetStringArray(int resId) = 0; 70eace7efcSopenharmony_ci virtual std::vector<int> GetIntArray(int resId) = 0; 71eace7efcSopenharmony_ci virtual std::map<std::string, std::string> GetTheme() = 0; 72eace7efcSopenharmony_ci virtual void SetTheme(int themeId) = 0; 73eace7efcSopenharmony_ci virtual std::map<std::string, std::string> GetPattern() = 0; 74eace7efcSopenharmony_ci virtual int GetColor(int resId) = 0; 75eace7efcSopenharmony_ci virtual int GetThemeId() = 0; 76eace7efcSopenharmony_ci virtual int GetDisplayOrientation() = 0; 77eace7efcSopenharmony_ci virtual std::string GetPreferencesDir() = 0; 78eace7efcSopenharmony_ci virtual void SetColorMode(int mode) = 0; 79eace7efcSopenharmony_ci virtual int GetColorMode() = 0; 80eace7efcSopenharmony_ci virtual int GetMissionId() = 0; 81eace7efcSopenharmony_ci virtual void StartAbilities(const std::vector<AAFwk::Want>& wants) = 0; 82eace7efcSopenharmony_ci friend DataAbilityHelper; 83eace7efcSopenharmony_ci friend DataShareHelper; 84eace7efcSopenharmony_ci friend ContinuationConnector; 85eace7efcSopenharmony_ciprotected: 86eace7efcSopenharmony_ci virtual sptr<IRemoteObject> GetToken() = 0; 87eace7efcSopenharmony_ci}; 88eace7efcSopenharmony_ci} // namespace AppExecFwk 89eace7efcSopenharmony_ci} // namespace OHOS 90eace7efcSopenharmony_ci#endif // MODULETEST_OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_H 91