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