• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "window.h"
17 #include "MockGlobalResult.h"
18 #define private public
19 #include "ace_ability.h"
20 
21 namespace OHOS::Ace::Platform {
AceAbility(const AceRunArgs & runArgs)22 AceAbility::AceAbility(const AceRunArgs& runArgs) : runArgs_(runArgs) {}
23 
~AceAbility()24 AceAbility::~AceAbility() {}
25 
SetMockModuleList(const std::map<std::string,std::string> & mockJsonInfo)26 void AceAbility::SetMockModuleList(const std::map<std::string, std::string>& mockJsonInfo)
27 {
28     g_setMockModuleList = true;
29 }
30 
InitEnv()31 void AceAbility::InitEnv()
32 {
33     g_initEnv = true;
34 }
35 
OnBackPressed() const36 void AceAbility::OnBackPressed() const
37 {
38     g_onBackPressed = true;
39 }
40 
OnInputEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent) const41 bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const
42 {
43     g_onInputEvent = true;
44     return true;
45 }
OnInputEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent) const46 bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const
47 {
48     g_onInputEvent = true;
49     return true;
50 }
OnInputEvent(const std::shared_ptr<MMI::AxisEvent> & axisEvent) const51 bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const
52 {
53     g_onInputEvent = true;
54     return true;
55 }
OnInputMethodEvent(const unsigned int codePoint) const56 bool AceAbility::OnInputMethodEvent(const unsigned int codePoint) const
57 {
58     g_onInputMethodEvent = true;
59     return true;
60 }
61 
OnConfigurationChanged(const DeviceConfig & newConfig)62 void AceAbility::OnConfigurationChanged(const DeviceConfig& newConfig)
63 {
64     g_onConfigurationChanged = true;
65 }
66 
SurfaceChanged(const DeviceOrientation & orientation,const double & resolution,int32_t & width,int32_t & height,WindowSizeChangeReason type)67 void AceAbility::SurfaceChanged(
68     const DeviceOrientation& orientation, const double& resolution, int32_t& width, int32_t& height,
69     WindowSizeChangeReason type)
70 {
71     g_surfaceChanged = true;
72 }
73 
ReplacePage(const std::string & url,const std::string & params)74 void AceAbility::ReplacePage(const std::string& url, const std::string& params)
75 {
76     g_replacePage = true;
77 }
LoadDocument(const std::string & url,const std::string & componentName,SystemParams & systemParams)78 void AceAbility::LoadDocument(const std::string& url, const std::string& componentName, SystemParams& systemParams)
79 {
80     g_loadAceDocument = true;
81 }
82 
GetJSONTree()83 std::string AceAbility::GetJSONTree()
84 {
85     return "jsontree";
86 }
87 
GetDefaultJSONTree()88 std::string AceAbility::GetDefaultJSONTree()
89 {
90     return "defaultjsontree";
91 }
92 
OperateComponent(const std::string & attrsJson)93 bool AceAbility::OperateComponent(const std::string& attrsJson)
94 {
95     g_operateComponent = true;
96     return true;
97 }
98 
SetWindow(sptr<OHOS::Rosen::Window> rsWindow)99 void AceAbility::SetWindow(sptr<OHOS::Rosen::Window> rsWindow)
100 {
101     rsWindow_ = rsWindow;
102     g_setWindow = true;
103 }
104 
CreateInstance(AceRunArgs & runArgs)105 std::unique_ptr<AceAbility> AceAbility::CreateInstance(AceRunArgs& runArgs)
106 {
107     auto aceAbility = std::make_unique<AceAbility>(runArgs);
108     return aceAbility;
109 }
110 
GetWindow()111 sptr<OHOS::Rosen::Window> AceAbility::GetWindow()
112 {
113     return rsWindow_;
114 }
115 }