• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     int32_t GetSystemDatabaseDir(const std::string &groupId, bool checkExist, std::string &databaseDir) override;
48 
49     int32_t GetSystemPreferencesDir(const std::string &groupId, bool checkExist, std::string &preferencesDir) override;
50 
51     std::string GetDistributedFilesDir() override;
52 
53     std::shared_ptr<Context> CreateModuleContext(const std::string &moduleName) override;
54 
55     std::shared_ptr<Context> CreateModuleContext(const std::string &bundleName, const std::string &moduleName) override;
56 
57     int GetArea() override;
58 
59     std::shared_ptr<Context> CreateBundleContext(const std::string &bundleName) override;
60 
61     sptr<AppExecFwk::IBundleMgr> GetBundleManager() const;
62 
63     void SetApplicationInfo(const std::shared_ptr<AppExecFwk::ApplicationInfo> &info);
64 
65 
66     void SetParentContext(const std::shared_ptr<Context> &context);
67 
68     std::string GetBundleCodePath() const override;
69 
70     void InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo);
71 
72     std::string GetBaseDir() const override;
73 
74     Global::Resource::DeviceType GetDeviceType() const override;
75 
76     std::shared_ptr<AppExecFwk::ApplicationInfo> GetApplicationInfo() const override;
77 
78     std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override;
79 
80     std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override;
81 
82     std::string GetGroupDir(std::string groupId) override;
83 };
84 }  // namespace AbilityRuntime
85 }  // namespace OHOS
86 #endif  // OHOS_ABILITY_RUNTIME_MOCK_CONTEXT_IMPL_H
87