• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 #ifndef FRAMEWORKS_CORE_COMMON_TEST_UNITTEST_ENVIRONMENT_MOCK_ENVIRONMENT_H
16 #define FRAMEWORKS_CORE_COMMON_TEST_UNITTEST_ENVIRONMENT_MOCK_ENVIRONMENT_H
17 
18 #include "core/common/environment/environment.h"
19 #include "core/common/environment/environment_interface.h"
20 #include "core/common/environment/environment_proxy.h"
21 
22 namespace OHOS::Ace {
23 const std::string RET_TEST = "true";
24 
25 class MockEnvironmentImpl : public Environment {
26 public:
27     explicit MockEnvironmentImpl(const RefPtr<TaskExecutor>& taskExecutor);
28     ~MockEnvironmentImpl() override = default;
29 
30     std::string GetAccessibilityEnabled() override;
31 };
32 
MockEnvironmentImpl(const RefPtr<TaskExecutor> & taskExecutor)33 MockEnvironmentImpl::MockEnvironmentImpl(const RefPtr<TaskExecutor>& taskExecutor) : Environment(taskExecutor) {}
34 
GetAccessibilityEnabled()35 std::string MockEnvironmentImpl::GetAccessibilityEnabled()
36 {
37     return  RET_TEST;
38 }
39 
40 class MockEnvironmentProxyImpl final : public EnvironmentInterface {
41 public:
42     MockEnvironmentProxyImpl() = default;
43     ~MockEnvironmentProxyImpl() override = default;
44 
45     RefPtr<Environment> GetEnvironment(const RefPtr<TaskExecutor>& taskExecutor) const override;
46 
47     ACE_DISALLOW_COPY_AND_MOVE(MockEnvironmentProxyImpl);
48 };
49 
GetEnvironment(const RefPtr<TaskExecutor> & taskExecutor)50 RefPtr<Environment> MockEnvironmentProxyImpl::GetEnvironment(const RefPtr<TaskExecutor>& taskExecutor) const
51 {
52     return AceType::MakeRefPtr<MockEnvironmentImpl>(taskExecutor);
53 }
54 } // namespace OHOS::Ace
55 #endif