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 "JsAppImpl.h"
17 #include "MockGlobalResult.h"
18
JsAppImpl()19 JsAppImpl::JsAppImpl() noexcept : ability(nullptr), isStop(false) {}
20
~JsAppImpl()21 JsAppImpl::~JsAppImpl() {}
22
GetInstance()23 JsAppImpl& JsAppImpl::GetInstance()
24 {
25 static JsAppImpl instance;
26 return instance;
27 }
28
ResolutionChanged(ResolutionParam & param,int32_t screenDensity,std::string reason)29 void JsAppImpl::ResolutionChanged(ResolutionParam& param, int32_t screenDensity, std::string reason)
30 {
31 this->width = param.orignalWidth;
32 this->height = param.orignalHeight;
33 }
34
GetOrientation() const35 std::string JsAppImpl::GetOrientation() const
36 {
37 g_getOrientation = true;
38 return orientation;
39 }
40
OrientationChanged(std::string commandOrientation)41 void JsAppImpl::OrientationChanged(std::string commandOrientation)
42 {
43 orientation = commandOrientation;
44 }
45
GetColorMode() const46 std::string JsAppImpl::GetColorMode() const
47 {
48 g_getColorMode = true;
49 return colorMode;
50 }
51
SetArgsColorMode(const std::string & value)52 void JsAppImpl::SetArgsColorMode(const std::string& value)
53 {
54 colorMode = value;
55 }
56
ColorModeChanged(const std::string commandColorMode)57 void JsAppImpl::ColorModeChanged(const std::string commandColorMode)
58 {
59 colorMode = commandColorMode;
60 }
61
MemoryRefresh(const std::string memoryRefreshArgs) const62 bool JsAppImpl::MemoryRefresh(const std::string memoryRefreshArgs) const
63 {
64 g_memoryRefresh = true;
65 return true;
66 }
67
LoadDocument(const std::string filePath,const std::string componentName,const Json2::Value & previewContext)68 void JsAppImpl::LoadDocument(const std::string filePath, const std::string componentName,
69 const Json2::Value& previewContext)
70 {
71 g_loadDocument = true;
72 }
73
ReloadRuntimePage(const std::string currentPage)74 void JsAppImpl::ReloadRuntimePage(const std::string currentPage)
75 {
76 g_reloadRuntimePage = true;
77 }
78
Restart()79 void JsAppImpl::Restart()
80 {
81 g_restart = true;
82 }
83
GetJSONTree()84 std::string JsAppImpl::GetJSONTree()
85 {
86 g_getJSONTree = true;
87 return "";
88 }
89
GetDefaultJSONTree()90 std::string JsAppImpl::GetDefaultJSONTree()
91 {
92 g_getDefaultJSONTree = true;
93 return "";
94 }
95
FoldStatusChanged(const std::string commandFoldStatus,int32_t currentWidth,int32_t currentHeight)96 void JsAppImpl::FoldStatusChanged(const std::string commandFoldStatus, int32_t currentWidth, int32_t currentHeight)
97 {
98 this->width = currentWidth;
99 this->height = currentHeight;
100 }
101
Start()102 void JsAppImpl::Start()
103 {
104 isFinished = true;
105 }
106
Interrupt()107 void JsAppImpl::Interrupt()
108 {
109 isStop = true;
110 }
SetArgsAceVersion(const std::string & value)111 void JsAppImpl::SetArgsAceVersion(const std::string& value)
112 {
113 aceVersion = value;
114 }
115
SetScreenDensity(const std::string value)116 void JsAppImpl::SetScreenDensity(const std::string value)
117 {
118 screenDensity = value;
119 }
120
SetConfigChanges(const std::string value)121 void JsAppImpl::SetConfigChanges(const std::string value)
122 {
123 configChanges = value;
124 }
125
DispatchBackPressedEvent() const126 void JsAppImpl::DispatchBackPressedEvent() const
127 {
128 g_dispatchBackPressedEvent = true;
129 }
130
DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent> & pointerEvent) const131 void JsAppImpl::DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) const
132 {
133 g_dispatchPointerEvent = true;
134 }
135
DispatchAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent> & axisEvent) const136 void JsAppImpl::DispatchAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) const
137 {
138 g_dispatchAxisEvent = true;
139 }
140
DispatchInputMethodEvent(const unsigned int codePoint) const141 void JsAppImpl::DispatchInputMethodEvent(const unsigned int codePoint) const
142 {
143 g_dispatchInputMethodEvent = true;
144 }
145
DispatchKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent> & keyEvent) const146 void JsAppImpl::DispatchKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) const
147 {
148 g_dispatchKeyEvent = true;
149 }
150
SetAvoidArea(const AvoidAreas & areas)151 void JsAppImpl::SetAvoidArea(const AvoidAreas& areas)
152 {
153 avoidInitialAreas = areas;
154 }
155
InitJsApp()156 void JsAppImpl::InitJsApp() {}