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 #include "frameworks/bridge/declarative_frontend/jsview/js_previewer_mock.h"
17
18 #include "base/log/ace_trace.h"
19 #include "frameworks/bridge/common/utils/utils.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/models/preview_mock_model_impl.h"
21 #include "frameworks/core/components_ng/pattern/preview_mock/preview_mock_model.h"
22 #include "frameworks/core/components_ng/pattern/preview_mock/preview_mock_model_ng.h"
23
24 namespace OHOS::Ace {
25
26 std::unique_ptr<PreviewMockModel> PreviewMockModel::instance_ = nullptr;
27 std::mutex PreviewMockModel::mutex_;
28
GetInstance()29 PreviewMockModel* PreviewMockModel::GetInstance()
30 {
31 if (!instance_) {
32 std::lock_guard<std::mutex> lock(mutex_);
33 if (!instance_) {
34 if (Container::IsCurrentUseNewPipeline()) {
35 instance_.reset(new NG::PreviewMockModelNG());
36 } else {
37 instance_.reset(new Framework::PreviewMockModelImpl());
38 }
39 }
40 }
41 return instance_.get();
42 }
43
44 } // namespace OHOS::Ace
45
46 namespace OHOS::Ace::Framework {
47
CreateMockComponent(const std::string & inspectorTag)48 void CreateMockComponent(const std::string& inspectorTag)
49 {
50 OHOS::Ace::PreviewMockModel::GetInstance()->Create(inspectorTag);
51 }
52
Create(const JSCallbackInfo & info)53 void JSForm::Create(const JSCallbackInfo& info)
54 {
55 if (info.Length() == 0 || !info[0]->IsObject()) {
56 return;
57 }
58
59 CreateMockComponent("FormComponent");
60 }
61
Mock(const JSCallbackInfo & info)62 void JSForm::Mock(const JSCallbackInfo& info) {}
63
JSBind(BindingTarget globalObj)64 void JSForm::JSBind(BindingTarget globalObj)
65 {
66 JSClass<JSForm>::Declare("FormComponent");
67 MethodOptions opt = MethodOptions::NONE;
68 JSClass<JSForm>::StaticMethod("create", &JSForm::Create, opt);
69 JSClass<JSForm>::StaticMethod("size", &JSForm::Mock, opt);
70 JSClass<JSForm>::StaticMethod("dimension", &JSForm::Mock, opt);
71 JSClass<JSForm>::StaticMethod("allowUpdate", &JSForm::Mock, opt);
72 JSClass<JSForm>::StaticMethod("visibility", &JSForm::Mock, opt);
73 JSClass<JSForm>::StaticMethod("clip", &JSForm::Mock, opt);
74
75 JSClass<JSForm>::StaticMethod("onAcquired", &JSForm::Mock);
76 JSClass<JSForm>::StaticMethod("onError", &JSForm::Mock);
77 JSClass<JSForm>::StaticMethod("onUninstall", &JSForm::Mock);
78 JSClass<JSForm>::StaticMethod("onRouter", &JSForm::Mock);
79 JSClass<JSForm>::StaticMethod("onAppear", &JSForm::Mock);
80 JSClass<JSForm>::StaticMethod("onDisAppear", &JSForm::Mock);
81 JSClass<JSForm>::StaticMethod("onAttach", &JSForm::Mock);
82 JSClass<JSForm>::StaticMethod("onDetach", &JSForm::Mock);
83 JSClass<JSForm>::StaticMethod("onTouch", &JSForm::Mock);
84 JSClass<JSForm>::StaticMethod("onKeyEvent", &JSForm::Mock);
85 JSClass<JSForm>::StaticMethod("onDeleteEvent", &JSForm::Mock);
86 JSClass<JSForm>::StaticMethod("onClick", &JSForm::Mock);
87
88 JSClass<JSForm>::InheritAndBind<JSViewAbstract>(globalObj);
89 }
90
Create(const JSCallbackInfo & info)91 void JSRichText::Create(const JSCallbackInfo& info)
92 {
93 if (info.Length() < 1) {
94 return;
95 }
96 CreateMockComponent("RichText");
97 }
98
Mock(const JSCallbackInfo & info)99 void JSRichText::Mock(const JSCallbackInfo& info) {}
100
JSBind(BindingTarget globalObj)101 void JSRichText::JSBind(BindingTarget globalObj)
102 {
103 JSClass<JSRichText>::Declare("RichText");
104 JSClass<JSRichText>::StaticMethod("create", &JSRichText::Create);
105 JSClass<JSRichText>::StaticMethod("onStart", &JSRichText::Mock);
106 JSClass<JSRichText>::StaticMethod("onComplete", &JSRichText::Mock);
107 JSClass<JSRichText>::InheritAndBind<JSViewAbstract>(globalObj);
108 }
109
110 class JSWebDialog : public Referenced {
111 public:
JSBind(BindingTarget globalObj)112 static void JSBind(BindingTarget globalObj)
113 {
114 JSClass<JSWebDialog>::Declare("WebDialog");
115 JSClass<JSWebDialog>::StaticMethod("handleConfirm", &JSWeb::Mock);
116 JSClass<JSWebDialog>::StaticMethod("handleCancel", &JSWeb::Mock);
117 JSClass<JSWebDialog>::StaticMethod("handlePromptConfirm", &JSWeb::Mock);
118 JSClass<JSWebDialog>::Bind(globalObj);
119 }
120 };
121
122 class JSWebHttpAuth : public Referenced {
123 public:
JSBind(BindingTarget globalObj)124 static void JSBind(BindingTarget globalObj)
125 {
126 JSClass<JSWebHttpAuth>::Declare("WebHttpAuthResult");
127 JSClass<JSWebHttpAuth>::StaticMethod("confirm", &JSWeb::Mock);
128 JSClass<JSWebHttpAuth>::StaticMethod("cancel", &JSWeb::Mock);
129 JSClass<JSWebHttpAuth>::StaticMethod("isHttpAuthInfoSaved", &JSWeb::Mock);
130 JSClass<JSWebHttpAuth>::Bind(globalObj);
131 }
132 };
133
134 class JSWebSslError : public Referenced {
135 public:
JSBind(BindingTarget globalObj)136 static void JSBind(BindingTarget globalObj)
137 {
138 JSClass<JSWebSslError>::Declare("WebSslErrorResult");
139 JSClass<JSWebSslError>::StaticMethod("handleConfirm", &JSWeb::Mock);
140 JSClass<JSWebSslError>::StaticMethod("handleCancel", &JSWeb::Mock);
141 JSClass<JSWebSslError>::Bind(globalObj);
142 }
143 };
144
145 class JSWebSslSelectCert : public Referenced {
146 public:
JSBind(BindingTarget globalObj)147 static void JSBind(BindingTarget globalObj)
148 {
149 JSClass<JSWebSslSelectCert>::Declare("WebSelectCertResult");
150 JSClass<JSWebSslSelectCert>::StaticMethod("confirm", &JSWeb::Mock);
151 JSClass<JSWebSslSelectCert>::StaticMethod("cancel", &JSWeb::Mock);
152 JSClass<JSWebSslSelectCert>::StaticMethod("ignore", &JSWeb::Mock);
153 JSClass<JSWebSslSelectCert>::Bind(globalObj);
154 }
155 };
156
157 class JSWebConsoleLog : public Referenced {
158 public:
JSBind(BindingTarget globalObj)159 static void JSBind(BindingTarget globalObj)
160 {
161 JSClass<JSWebConsoleLog>::Declare("ConsoleMessage");
162 JSClass<JSWebConsoleLog>::StaticMethod("getLineNumber", &JSWeb::Mock);
163 JSClass<JSWebConsoleLog>::StaticMethod("getMessage", &JSWeb::Mock);
164 JSClass<JSWebConsoleLog>::StaticMethod("getMessageLevel", &JSWeb::Mock);
165 JSClass<JSWebConsoleLog>::StaticMethod("getSourceId", &JSWeb::Mock);
166 JSClass<JSWebConsoleLog>::Bind(globalObj);
167 }
168 };
169
170 class JSWebGeolocation : public Referenced {
171 public:
JSBind(BindingTarget globalObj)172 static void JSBind(BindingTarget globalObj)
173 {
174 JSClass<JSWebGeolocation>::Declare("WebGeolocation");
175 JSClass<JSWebGeolocation>::StaticMethod("invoke", &JSWeb::Mock);
176 JSClass<JSWebGeolocation>::Bind(globalObj);
177 }
178 };
179
180 class JSWebResourceError : public Referenced {
181 public:
JSBind(BindingTarget globalObj)182 static void JSBind(BindingTarget globalObj)
183 {
184 JSClass<JSWebResourceError>::Declare("WebResourceError");
185 JSClass<JSWebResourceError>::StaticMethod("getErrorCode", &JSWeb::Mock);
186 JSClass<JSWebResourceError>::StaticMethod("getErrorInfo", &JSWeb::Mock);
187 JSClass<JSWebResourceError>::Bind(globalObj);
188 }
189 };
190
191 class JSWebResourceResponse : public Referenced {
192 public:
JSBind(BindingTarget globalObj)193 static void JSBind(BindingTarget globalObj)
194 {
195 JSClass<JSWebResourceResponse>::Declare("WebResourceResponse");
196 JSClass<JSWebResourceResponse>::StaticMethod("getResponseData", &JSWeb::Mock);
197 JSClass<JSWebResourceResponse>::StaticMethod("getResponseEncoding", &JSWeb::Mock);
198 JSClass<JSWebResourceResponse>::StaticMethod("getResponseMimeType", &JSWeb::Mock);
199 JSClass<JSWebResourceResponse>::StaticMethod("getReasonMessage", &JSWeb::Mock);
200 JSClass<JSWebResourceResponse>::StaticMethod("getResponseCode", &JSWeb::Mock);
201 JSClass<JSWebResourceResponse>::StaticMethod("getResponseHeader", &JSWeb::Mock);
202 JSClass<JSWebResourceResponse>::Bind(globalObj);
203 }
204 };
205
206 class JSWebResourceRequest : public Referenced {
207 public:
JSBind(BindingTarget globalObj)208 static void JSBind(BindingTarget globalObj)
209 {
210 JSClass<JSWebResourceRequest>::Declare("WebResourceRequest");
211 JSClass<JSWebResourceRequest>::StaticMethod("getRequestUrl", &JSWeb::Mock);
212 JSClass<JSWebResourceRequest>::StaticMethod("getRequestHeader", &JSWeb::Mock);
213 JSClass<JSWebResourceRequest>::StaticMethod("isRequestGesture", &JSWeb::Mock);
214 JSClass<JSWebResourceRequest>::StaticMethod("isMainFrame", &JSWeb::Mock);
215 JSClass<JSWebResourceRequest>::StaticMethod("isRedirect", &JSWeb::Mock);
216 JSClass<JSWebResourceRequest>::Bind(globalObj);
217 }
218 };
219
220 class JSFileSelectorParam : public Referenced {
221 public:
JSBind(BindingTarget globalObj)222 static void JSBind(BindingTarget globalObj)
223 {
224 JSClass<JSFileSelectorParam>::Declare("FileSelectorParam");
225 JSClass<JSFileSelectorParam>::StaticMethod("getTitle", &JSWeb::Mock);
226 JSClass<JSFileSelectorParam>::StaticMethod("getMode", &JSWeb::Mock);
227 JSClass<JSFileSelectorParam>::StaticMethod("getAcceptType", &JSWeb::Mock);
228 JSClass<JSFileSelectorParam>::StaticMethod("isCapture", &JSWeb::Mock);
229 JSClass<JSFileSelectorParam>::Bind(globalObj);
230 }
231 };
232
233 class JSFileSelectorResult : public Referenced {
234 public:
JSBind(BindingTarget globalObj)235 static void JSBind(BindingTarget globalObj)
236 {
237 JSClass<JSFileSelectorResult>::Declare("FileSelectorResult");
238 JSClass<JSFileSelectorResult>::StaticMethod("handleFileList", &JSWeb::Mock);
239 JSClass<JSFileSelectorResult>::Bind(globalObj);
240 }
241 };
242
Create(const JSCallbackInfo & info)243 void JSWeb::Create(const JSCallbackInfo& info)
244 {
245 if (info.Length() < 1 || !info[0]->IsObject()) {
246 return;
247 }
248
249 CreateMockComponent("Web");
250 }
251
Mock(const JSCallbackInfo & info)252 void JSWeb::Mock(const JSCallbackInfo& info) {}
253
JSBind(BindingTarget globalObj)254 void JSWeb::JSBind(BindingTarget globalObj)
255 {
256 JSClass<JSWeb>::Declare("Web");
257 JSClass<JSWeb>::StaticMethod("create", &JSWeb::Create);
258 JSClass<JSWeb>::StaticMethod("onAlert", &JSWeb::Mock);
259 JSClass<JSWeb>::StaticMethod("onBeforeUnload", &JSWeb::Mock);
260 JSClass<JSWeb>::StaticMethod("onConfirm", &JSWeb::Mock);
261 JSClass<JSWeb>::StaticMethod("onPrompt", &JSWeb::Mock);
262 JSClass<JSWeb>::StaticMethod("onConsole", &JSWeb::Mock);
263 JSClass<JSWeb>::StaticMethod("onPageBegin", &JSWeb::Mock);
264 JSClass<JSWeb>::StaticMethod("onPageEnd", &JSWeb::Mock);
265 JSClass<JSWeb>::StaticMethod("onProgressChange", &JSWeb::Mock);
266 JSClass<JSWeb>::StaticMethod("onTitleReceive", &JSWeb::Mock);
267 JSClass<JSWeb>::StaticMethod("onGeolocationHide", &JSWeb::Mock);
268 JSClass<JSWeb>::StaticMethod("onGeolocationShow", &JSWeb::Mock);
269 JSClass<JSWeb>::StaticMethod("onRequestSelected", &JSWeb::Mock);
270 JSClass<JSWeb>::StaticMethod("onShowFileSelector", &JSWeb::Mock);
271 JSClass<JSWeb>::StaticMethod("javaScriptAccess", &JSWeb::Mock);
272 JSClass<JSWeb>::StaticMethod("fileExtendAccess", &JSWeb::Mock);
273 JSClass<JSWeb>::StaticMethod("fileAccess", &JSWeb::Mock);
274 JSClass<JSWeb>::StaticMethod("onDownloadStart", &JSWeb::Mock);
275 JSClass<JSWeb>::StaticMethod("onErrorReceive", &JSWeb::Mock);
276 JSClass<JSWeb>::StaticMethod("onHttpErrorReceive", &JSWeb::Mock);
277 JSClass<JSWeb>::StaticMethod("onUrlLoadIntercept", &JSWeb::Mock);
278 JSClass<JSWeb>::StaticMethod("onlineImageAccess", &JSWeb::Mock);
279 JSClass<JSWeb>::StaticMethod("domStorageAccess", &JSWeb::Mock);
280 JSClass<JSWeb>::StaticMethod("imageAccess", &JSWeb::Mock);
281 JSClass<JSWeb>::StaticMethod("mixedMode", &JSWeb::Mock);
282 JSClass<JSWeb>::StaticMethod("zoomAccess", &JSWeb::Mock);
283 JSClass<JSWeb>::StaticMethod("geolocationAccess", &JSWeb::Mock);
284 JSClass<JSWeb>::StaticMethod("javaScriptProxy", &JSWeb::Mock);
285 JSClass<JSWeb>::StaticMethod("userAgent", &JSWeb::Mock);
286 JSClass<JSWeb>::StaticMethod("onRenderExited", &JSWeb::Mock);
287 JSClass<JSWeb>::StaticMethod("onRefreshAccessedHistory", &JSWeb::Mock);
288 JSClass<JSWeb>::StaticMethod("cacheMode", &JSWeb::Mock);
289 JSClass<JSWeb>::StaticMethod("overviewModeAccess", &JSWeb::Mock);
290 JSClass<JSWeb>::StaticMethod("fileFromUrlAccess", &JSWeb::Mock);
291 JSClass<JSWeb>::StaticMethod("databaseAccess", &JSWeb::Mock);
292 JSClass<JSWeb>::StaticMethod("textZoomAtio", &JSWeb::Mock);
293 JSClass<JSWeb>::StaticMethod("textZoomRatio", &JSWeb::Mock);
294 JSClass<JSWeb>::StaticMethod("webDebuggingAccess", &JSWeb::Mock);
295 JSClass<JSWeb>::StaticMethod("initialScale", &JSWeb::Mock);
296 JSClass<JSWeb>::StaticMethod("backgroundColor", &JSWeb::Mock);
297 JSClass<JSWeb>::StaticMethod("onKeyEvent", &JSWeb::Mock);
298 JSClass<JSWeb>::StaticMethod("onTouch", &JSWeb::Mock);
299 JSClass<JSWeb>::StaticMethod("onMouse", &JSWeb::Mock);
300 JSClass<JSWeb>::StaticMethod("onResourceLoad", &JSWeb::Mock);
301 JSClass<JSWeb>::StaticMethod("onScaleChange", &JSWeb::Mock);
302 JSClass<JSWeb>::StaticMethod("password", &JSWeb::Mock);
303 JSClass<JSWeb>::StaticMethod("tableData", &JSWeb::Mock);
304 JSClass<JSWeb>::StaticMethod("onFileSelectorShow", &JSWeb::Mock);
305 JSClass<JSWeb>::StaticMethod("onHttpAuthRequest", &JSWeb::Mock);
306 JSClass<JSWeb>::StaticMethod("onSslErrorEventReceive", &JSWeb::Mock);
307 JSClass<JSWeb>::StaticMethod("onClientAuthenticationRequest", &JSWeb::Mock);
308 JSClass<JSWeb>::StaticMethod("onRenderProcessNotResponding", &JSWeb::Mock);
309 JSClass<JSWeb>::StaticMethod("onRenderProcessResponding", &JSWeb::Mock);
310 JSClass<JSWeb>::StaticMethod("onViewportFitChanged", &JSWeb::Mock);
311 JSClass<JSWeb>::StaticMethod("onAdsBlocked", &JSWeb::Mock);
312
313 JSClass<JSWeb>::InheritAndBind<JSViewAbstract>(globalObj);
314
315 JSWebDialog::JSBind(globalObj);
316 JSWebGeolocation::JSBind(globalObj);
317 JSWebResourceRequest::JSBind(globalObj);
318 JSWebResourceError::JSBind(globalObj);
319 JSWebResourceResponse::JSBind(globalObj);
320 JSWebConsoleLog::JSBind(globalObj);
321 JSFileSelectorParam::JSBind(globalObj);
322 JSFileSelectorResult::JSBind(globalObj);
323 JSWebHttpAuth::JSBind(globalObj);
324 JSWebSslError::JSBind(globalObj);
325 JSWebSslSelectCert::JSBind(globalObj);
326 }
327
328 class JSWebCookie : public Referenced {
329 public:
JSBind(BindingTarget globalObj)330 static void JSBind(BindingTarget globalObj)
331 {
332 JSClass<JSWebCookie>::Declare("WebCookie");
333 JSClass<JSWebCookie>::StaticMethod("setCookie", &JSWeb::Mock);
334 JSClass<JSWebCookie>::StaticMethod("getCookie", &JSWeb::Mock);
335 JSClass<JSWebCookie>::StaticMethod("deleteEntireCookie", &JSWeb::Mock);
336 JSClass<JSWebCookie>::StaticMethod("saveCookieSync", &JSWeb::Mock);
337 JSClass<JSWebCookie>::Bind(globalObj);
338 }
339 };
340
341 class JSHitTestValue : public Referenced {
342 public:
JSBind(BindingTarget globalObj)343 static void JSBind(BindingTarget globalObj)
344 {
345 JSClass<JSHitTestValue>::Declare("HitTestValue");
346 JSClass<JSHitTestValue>::StaticMethod("getType", &JSWeb::Mock);
347 JSClass<JSHitTestValue>::StaticMethod("getExtra", &JSWeb::Mock);
348 JSClass<JSHitTestValue>::Bind(globalObj);
349 }
350 };
351
JSBind(BindingTarget globalObj)352 void JSWebController::JSBind(BindingTarget globalObj)
353 {
354 JSClass<JSWebController>::Declare("WebController");
355 JSClass<JSWebController>::StaticMethod("loadUrl", &JSWeb::Mock);
356 JSClass<JSWebController>::StaticMethod("runJavaScript", &JSWeb::Mock);
357 JSClass<JSWebController>::StaticMethod("refresh", &JSWeb::Mock);
358 JSClass<JSWebController>::StaticMethod("stop", &JSWeb::Mock);
359 JSClass<JSWebController>::StaticMethod("getHitTest", &JSWeb::Mock);
360 JSClass<JSWebController>::StaticMethod("registerJavaScriptProxy", &JSWeb::Mock);
361 JSClass<JSWebController>::StaticMethod("deleteJavaScriptRegister", &JSWeb::Mock);
362 JSClass<JSWebController>::StaticMethod("onInactive", &JSWeb::Mock);
363 JSClass<JSWebController>::StaticMethod("onActive", &JSWeb::Mock);
364 JSClass<JSWebController>::StaticMethod("zoom", &JSWeb::Mock);
365 JSClass<JSWebController>::StaticMethod("requestFocus", &JSWeb::Mock);
366 JSClass<JSWebController>::StaticMethod("loadData", &JSWeb::Mock);
367 JSClass<JSWebController>::StaticMethod("backward", &JSWeb::Mock);
368 JSClass<JSWebController>::StaticMethod("forward", &JSWeb::Mock);
369 JSClass<JSWebController>::StaticMethod("accessStep", &JSWeb::Mock);
370 JSClass<JSWebController>::StaticMethod("accessForward", &JSWeb::Mock);
371 JSClass<JSWebController>::StaticMethod("accessBackward", &JSWeb::Mock);
372 JSClass<JSWebController>::StaticMethod("clearHistory", &JSWeb::Mock);
373 JSClass<JSWebController>::StaticMethod("clearSslCache", &JSWeb::Mock);
374 JSClass<JSWebController>::StaticMethod("clearClientAuthenticationCache", &JSWeb::Mock);
375 JSClass<JSWebController>::StaticMethod("getCookieManager", &JSWeb::Mock);
376 JSClass<JSWebController>::StaticMethod("getHitTestValue", &JSWeb::Mock);
377 JSClass<JSWebController>::StaticMethod("backOrForward", &JSWeb::Mock);
378 JSClass<JSWebController>::StaticMethod("zoomIn", &JSWeb::Mock);
379 JSClass<JSWebController>::StaticMethod("zoomOut", &JSWeb::Mock);
380 JSClass<JSWebController>::StaticMethod("getPageHeight", &JSWeb::Mock);
381 JSClass<JSWebController>::StaticMethod("getTitle", &JSWeb::Mock);
382 JSClass<JSWebController>::StaticMethod("getWebId", &JSWeb::Mock);
383 JSClass<JSWebController>::StaticMethod("getDefaultUserAgent", &JSWeb::Mock);
384 JSClass<JSWebController>::StaticMethod("getProgress", &JSWeb::Mock);
385 JSClass<JSWebController>::Bind(globalObj);
386 JSWebCookie::JSBind(globalObj);
387 JSHitTestValue::JSBind(globalObj);
388 }
389
Create(const JSCallbackInfo & info)390 void JSXComponent::Create(const JSCallbackInfo& info)
391 {
392 if (info.Length() < 1 || !info[0]->IsObject()) {
393 return;
394 }
395 CreateMockComponent("XComponent");
396 }
397
Mock(const JSCallbackInfo & info)398 void JSXComponent::Mock(const JSCallbackInfo& info) {}
399
JSBind(BindingTarget globalObj)400 void JSXComponent::JSBind(BindingTarget globalObj)
401 {
402 JSClass<JSXComponent>::Declare("XComponent");
403 JSClass<JSXComponent>::StaticMethod("create", &JSXComponent::Create);
404 JSClass<JSXComponent>::StaticMethod("onLoad", &JSXComponent::Mock);
405 JSClass<JSXComponent>::StaticMethod("onDestroy", &JSXComponent::Mock);
406 JSClass<JSXComponent>::InheritAndBind<JSViewAbstract>(globalObj);
407 }
408
JSBind(BindingTarget globalObj)409 void JSXComponentController::JSBind(BindingTarget globalObj)
410 {
411 JSClass<JSXComponentController>::Declare("XComponentController");
412 JSClass<JSXComponentController>::StaticMethod("getXComponentSurfaceId", &JSXComponentController::Mock);
413 JSClass<JSXComponentController>::StaticMethod("getXComponentContext", &JSXComponentController::Mock);
414 JSClass<JSXComponentController>::StaticMethod("setXComponentSurfaceSize", &JSXComponentController::Mock);
415 JSClass<JSXComponentController>::Bind(globalObj);
416 }
417
Mock(const JSCallbackInfo & info)418 void JSXComponentController::Mock(const JSCallbackInfo& info) {}
419
Create(const JSCallbackInfo & info)420 void JSVideo::Create(const JSCallbackInfo& info)
421 {
422 if (info.Length() <= 0 || !info[0]->IsObject()) {
423 return;
424 }
425 CreateMockComponent("Video");
426 }
427
Mock(const JSCallbackInfo & info)428 void JSVideo::Mock(const JSCallbackInfo& info) {}
429
JSBind(BindingTarget globalObj)430 void JSVideo::JSBind(BindingTarget globalObj)
431 {
432 JSClass<JSVideo>::Declare("Video");
433 MethodOptions opt = MethodOptions::NONE;
434 JSClass<JSVideo>::StaticMethod("create", &JSVideo::Create, opt);
435 JSClass<JSVideo>::StaticMethod("muted", &JSVideo::Mock, opt);
436 JSClass<JSVideo>::StaticMethod("autoPlay", &JSVideo::Mock, opt);
437 JSClass<JSVideo>::StaticMethod("controls", &JSVideo::Mock, opt);
438 JSClass<JSVideo>::StaticMethod("loop", &JSVideo::Mock, opt);
439 JSClass<JSVideo>::StaticMethod("objectFit", &JSVideo::Mock, opt);
440
441 JSClass<JSVideo>::StaticMethod("onStart", &JSVideo::Mock);
442 JSClass<JSVideo>::StaticMethod("onPause", &JSVideo::Mock);
443 JSClass<JSVideo>::StaticMethod("onFinish", &JSVideo::Mock);
444 JSClass<JSVideo>::StaticMethod("onFullscreenChange", &JSVideo::Mock);
445 JSClass<JSVideo>::StaticMethod("onPrepared", &JSVideo::Mock);
446 JSClass<JSVideo>::StaticMethod("onSeeking", &JSVideo::Mock);
447 JSClass<JSVideo>::StaticMethod("onSeeked", &JSVideo::Mock);
448 JSClass<JSVideo>::StaticMethod("onUpdate", &JSVideo::Mock);
449 JSClass<JSVideo>::StaticMethod("onError", &JSVideo::Mock);
450
451 JSClass<JSVideo>::StaticMethod("onTouch", &JSVideo::Mock);
452 JSClass<JSVideo>::StaticMethod("onHover", &JSVideo::Mock);
453 JSClass<JSVideo>::StaticMethod("onKeyEvent", &JSVideo::Mock);
454 JSClass<JSVideo>::StaticMethod("onDeleteEvent", &JSVideo::Mock);
455 JSClass<JSVideo>::StaticMethod("onClick", &JSVideo::Mock);
456 JSClass<JSVideo>::StaticMethod("onAppear", &JSVideo::Mock);
457 JSClass<JSVideo>::StaticMethod("onDisAppear", &JSVideo::Mock);
458 JSClass<JSVideo>::StaticMethod("onAttach", &JSVideo::Mock);
459 JSClass<JSVideo>::StaticMethod("onDetach", &JSVideo::Mock);
460 JSClass<JSVideo>::StaticMethod("remoteMessage", &JSVideo::Mock);
461 JSClass<JSVideo>::InheritAndBind<JSViewAbstract>(globalObj);
462 }
463
JSBind(BindingTarget globalObj)464 void JSVideoController::JSBind(BindingTarget globalObj)
465 {
466 JSClass<JSVideoController>::Declare("VideoController");
467 JSClass<JSVideoController>::StaticMethod("start", &JSVideoController::Mock);
468 JSClass<JSVideoController>::StaticMethod("pause", &JSVideoController::Mock);
469 JSClass<JSVideoController>::StaticMethod("stop", &JSVideoController::Mock);
470 JSClass<JSVideoController>::StaticMethod("setCurrentTime", &JSVideoController::Mock);
471 JSClass<JSVideoController>::StaticMethod("requestFullscreen", &JSVideoController::Mock);
472 JSClass<JSVideoController>::StaticMethod("exitFullscreen", &JSVideoController::Mock);
473 JSClass<JSVideoController>::Bind(globalObj);
474 }
475
Mock(const JSCallbackInfo & info)476 void JSVideoController::Mock(const JSCallbackInfo& info) {}
477
Create(const JSCallbackInfo & info)478 void JSPlugin::Create(const JSCallbackInfo& info)
479 {
480 if (info.Length() <= 0 || !info[0]->IsObject()) {
481 return;
482 }
483 CreateMockComponent("PluginComponent");
484 }
485
Mock(const JSCallbackInfo & info)486 void JSPlugin::Mock(const JSCallbackInfo& info) {}
487
JSBind(BindingTarget globalObj)488 void JSPlugin::JSBind(BindingTarget globalObj)
489 {
490 JSClass<JSPlugin>::Declare("PluginComponent");
491 MethodOptions opt = MethodOptions::NONE;
492 JSClass<JSPlugin>::StaticMethod("create", &JSPlugin::Create, opt);
493 JSClass<JSPlugin>::StaticMethod("size", &JSPlugin::Mock, opt);
494 JSClass<JSPlugin>::StaticMethod("width", &JSPlugin::Mock);
495 JSClass<JSPlugin>::StaticMethod("height", &JSPlugin::Mock);
496 JSClass<JSPlugin>::StaticMethod("onComplete", &JSPlugin::Mock);
497 JSClass<JSPlugin>::StaticMethod("onError", &JSPlugin::Mock);
498 JSClass<JSPlugin>::StaticMethod("onAppear", &JSPlugin::Mock);
499 JSClass<JSPlugin>::StaticMethod("onDisAppear", &JSPlugin::Mock);
500 JSClass<JSPlugin>::StaticMethod("onAttach", &JSPlugin::Mock);
501 JSClass<JSPlugin>::StaticMethod("onDetach", &JSPlugin::Mock);
502 JSClass<JSPlugin>::StaticMethod("onTouch", &JSPlugin::Mock);
503 JSClass<JSPlugin>::StaticMethod("onKeyEvent", &JSPlugin::Mock);
504 JSClass<JSPlugin>::StaticMethod("onDeleteEvent", &JSPlugin::Mock);
505 JSClass<JSPlugin>::StaticMethod("onClick", &JSPlugin::Mock);
506
507 JSClass<JSPlugin>::InheritAndBind<JSViewAbstract>(globalObj);
508 }
509
JSBind(BindingTarget globalObj)510 void JSUIExtension::JSBind(BindingTarget globalObj)
511 {
512 JSClass<JSUIExtension>::Declare("UIExtensionComponent");
513 MethodOptions opt = MethodOptions::NONE;
514 JSClass<JSUIExtension>::StaticMethod("create", &JSUIExtension::Create, opt);
515 JSClass<JSUIExtension>::StaticMethod("onRemoteReady", &JSUIExtension::Mock);
516 JSClass<JSUIExtension>::StaticMethod("onReceive", &JSUIExtension::Mock);
517 JSClass<JSUIExtension>::StaticMethod("onResult", &JSUIExtension::Mock);
518 JSClass<JSUIExtension>::StaticMethod("onRelease", &JSUIExtension::Mock);
519 JSClass<JSUIExtension>::StaticMethod("onError", &JSUIExtension::Mock);
520 JSClass<JSUIExtension>::InheritAndBind<JSViewAbstract>(globalObj);
521 }
522
Create(const JSCallbackInfo & info)523 void JSUIExtension::Create(const JSCallbackInfo& info)
524 {
525 if (!info[0]->IsObject()) {
526 return;
527 }
528 CreateMockComponent("UIExtensionComponent");
529 }
530
Mock(const JSCallbackInfo & info)531 void JSUIExtension::Mock(const JSCallbackInfo& info) {}
532
JSBind(BindingTarget globalObj)533 void JSPreviewUIExtension::JSBind(BindingTarget globalObj)
534 {
535 JSClass<JSPreviewUIExtension>::Declare("PreviewUIExtensionComponent");
536 MethodOptions opt = MethodOptions::NONE;
537 JSClass<JSPreviewUIExtension>::StaticMethod("create", &JSPreviewUIExtension::Create, opt);
538 JSClass<JSPreviewUIExtension>::StaticMethod("onError", &JSPreviewUIExtension::Mock);
539 JSClass<JSPreviewUIExtension>::StaticMethod("width", &JSPreviewUIExtension::Mock);
540 JSClass<JSPreviewUIExtension>::StaticMethod("height", &JSPreviewUIExtension::Mock);
541 JSClass<JSPreviewUIExtension>::InheritAndBind<JSViewAbstract>(globalObj);
542 }
543
Create(const JSCallbackInfo & info)544 void JSPreviewUIExtension::Create(const JSCallbackInfo& info)
545 {
546 if (!info[0]->IsObject()) {
547 return;
548 }
549 CreateMockComponent("PreviewUIExtensionComponent");
550 }
551
Mock(const JSCallbackInfo & info)552 void JSPreviewUIExtension::Mock(const JSCallbackInfo& info) {}
553
JSBind(BindingTarget globalObj)554 void JSSecurityUIExtension::JSBind(BindingTarget globalObj)
555 {
556 JSClass<JSSecurityUIExtension>::Declare("SecurityUIExtensionComponent");
557 MethodOptions opt = MethodOptions::NONE;
558 JSClass<JSSecurityUIExtension>::StaticMethod("create", &JSSecurityUIExtension::Create, opt);
559 JSClass<JSSecurityUIExtension>::StaticMethod("onRemoteReady", &JSSecurityUIExtension::Mock);
560 JSClass<JSSecurityUIExtension>::StaticMethod("onReceive", &JSSecurityUIExtension::Mock);
561 JSClass<JSSecurityUIExtension>::StaticMethod("onError", &JSSecurityUIExtension::Mock);
562 JSClass<JSSecurityUIExtension>::StaticMethod("onTerminated", &JSSecurityUIExtension::Mock);
563 JSClass<JSSecurityUIExtension>::InheritAndBind<JSViewAbstract>(globalObj);
564 }
565
Create(const JSCallbackInfo & info)566 void JSSecurityUIExtension::Create(const JSCallbackInfo& info)
567 {
568 if (!info[0]->IsObject()) {
569 return;
570 }
571 CreateMockComponent("SecurityUIExtensionComponent");
572 }
573
Mock(const JSCallbackInfo & info)574 void JSSecurityUIExtension::Mock(const JSCallbackInfo& info) {}
575
JSBind(BindingTarget globalObj)576 void JSAbilityComponent::JSBind(BindingTarget globalObj)
577 {
578 JSClass<JSAbilityComponent>::Declare("AbilityComponent");
579 MethodOptions opt = MethodOptions::NONE;
580 JSClass<JSAbilityComponent>::StaticMethod("create", &JSAbilityComponent::Create, opt);
581 JSClass<JSAbilityComponent>::StaticMethod("onReady", &JSAbilityComponent::Mock, opt);
582 JSClass<JSAbilityComponent>::StaticMethod("onDestroy", &JSAbilityComponent::Mock, opt);
583 JSClass<JSAbilityComponent>::StaticMethod("onAbilityCreated", &JSAbilityComponent::Mock, opt);
584 JSClass<JSAbilityComponent>::StaticMethod("onAbilityMoveToFront", &JSAbilityComponent::Mock, opt);
585 JSClass<JSAbilityComponent>::StaticMethod("onAbilityWillRemove", &JSAbilityComponent::Mock, opt);
586 JSClass<JSAbilityComponent>::StaticMethod("onConnect", &JSAbilityComponent::Mock, opt);
587 JSClass<JSAbilityComponent>::StaticMethod("onDisconnect", &JSAbilityComponent::Mock, opt);
588 JSClass<JSAbilityComponent>::StaticMethod("width", &JSAbilityComponent::Mock, opt);
589 JSClass<JSAbilityComponent>::StaticMethod("height", &JSAbilityComponent::Mock, opt);
590 JSClass<JSAbilityComponent>::InheritAndBind<JSViewAbstract>(globalObj);
591 }
592
Create(const JSCallbackInfo & info)593 void JSAbilityComponent::Create(const JSCallbackInfo& info)
594 {
595 if (!info[0]->IsObject()) {
596 return;
597 }
598 CreateMockComponent("AbilityComponent");
599 }
600
Mock(const JSCallbackInfo & info)601 void JSAbilityComponent::Mock(const JSCallbackInfo& info) {}
602
JSBind(BindingTarget globalObj)603 void JSSceneView::JSBind(BindingTarget globalObj)
604 {
605 JSClass<JSSceneView>::Declare("Component3D");
606 MethodOptions opt = MethodOptions::NONE;
607 JSClass<JSSceneView>::StaticMethod("create", &JSSceneView::Create, opt);
608 JSClass<JSSceneView>::StaticMethod("gestureAccess", &JSSceneView::Mock);
609 JSClass<JSSceneView>::StaticMethod("environment", &JSSceneView::Mock);
610 JSClass<JSSceneView>::StaticMethod("customRender", &JSSceneView::Mock);
611 JSClass<JSSceneView>::StaticMethod("shader", &JSSceneView::Mock);
612 JSClass<JSSceneView>::StaticMethod("renderWidth", &JSSceneView::Mock);
613 JSClass<JSSceneView>::StaticMethod("renderHeight", &JSSceneView::Mock);
614 JSClass<JSSceneView>::StaticMethod("renderFrameRateHint", &JSSceneView::Mock);
615 JSClass<JSSceneView>::StaticMethod("shaderImageTexture", &JSSceneView::Mock);
616 JSClass<JSSceneView>::StaticMethod("shaderInputBuffer", &JSSceneView::Mock);
617 JSClass<JSSceneView>::StaticMethod("OnError", &JSSceneView::Mock);
618 JSClass<JSSceneView>::StaticMethod("onAttach", &JSSceneView::Mock);
619 JSClass<JSSceneView>::StaticMethod("onAppear", &JSSceneView::Mock);
620 JSClass<JSSceneView>::StaticMethod("onDetach", &JSSceneView::Mock);
621 JSClass<JSSceneView>::StaticMethod("onDisAppear", &JSSceneView::Mock);
622 JSClass<JSSceneView>::StaticMethod("onClick", &JSSceneView::Mock);
623 JSClass<JSSceneView>::InheritAndBind<JSViewAbstract>(globalObj);
624 }
625
Create(const JSCallbackInfo & info)626 void JSSceneView::Create(const JSCallbackInfo& info)
627 {
628 CreateMockComponent("Component3D");
629 }
630
Mock(const JSCallbackInfo & info)631 void JSSceneView::Mock(const JSCallbackInfo& info) {}
632
JSBind(BindingTarget globalObj)633 void JSEmbeddedComponent::JSBind(BindingTarget globalObj)
634 {
635 JSClass<JSEmbeddedComponent>::Declare("EmbeddedComponent");
636 MethodOptions opt = MethodOptions::NONE;
637 JSClass<JSEmbeddedComponent>::StaticMethod("create", &JSEmbeddedComponent::Create, opt);
638 JSClass<JSEmbeddedComponent>::StaticMethod("onTerminated", &JSEmbeddedComponent::Mock);
639 JSClass<JSEmbeddedComponent>::StaticMethod("onError", &JSEmbeddedComponent::Mock);
640 JSClass<JSEmbeddedComponent>::StaticMethod("width", &JSEmbeddedComponent::Mock);
641 JSClass<JSEmbeddedComponent>::StaticMethod("height", &JSEmbeddedComponent::Mock);
642 JSClass<JSEmbeddedComponent>::StaticMethod("constraintSize", &JSEmbeddedComponent::Mock);
643 JSClass<JSEmbeddedComponent>::StaticMethod("aspectRatio", &JSEmbeddedComponent::Mock);
644 JSClass<JSEmbeddedComponent>::StaticMethod("layoutWeight", &JSEmbeddedComponent::Mock);
645 JSClass<JSEmbeddedComponent>::StaticMethod("flexBasis", &JSEmbeddedComponent::Mock);
646 JSClass<JSEmbeddedComponent>::StaticMethod("flexGrow", &JSEmbeddedComponent::Mock);
647 JSClass<JSEmbeddedComponent>::StaticMethod("flexShrink", &JSEmbeddedComponent::Mock);
648 JSClass<JSEmbeddedComponent>::StaticMethod("opacity", &JSEmbeddedComponent::Mock);
649 JSClass<JSEmbeddedComponent>::InheritAndBind<JSViewAbstract>(globalObj);
650 }
651
Create(const JSCallbackInfo & info)652 void JSEmbeddedComponent::Create(const JSCallbackInfo& info)
653 {
654 if (info.Length() < 1 || !info[0]->IsObject()) {
655 return;
656 }
657 CreateMockComponent("EmbeddedComponent");
658 }
659
Mock(const JSCallbackInfo & info)660 void JSEmbeddedComponent::Mock(const JSCallbackInfo& info) {}
661
JSBind(BindingTarget globalObj)662 void JSIsolatedComponent::JSBind(BindingTarget globalObj)
663 {
664 JSClass<JSIsolatedComponent>::Declare("IsolatedComponent");
665 MethodOptions opt = MethodOptions::NONE;
666 JSClass<JSIsolatedComponent>::StaticMethod("create", &JSIsolatedComponent::Create, opt);
667 JSClass<JSIsolatedComponent>::StaticMethod("onError", &JSIsolatedComponent::Mock, opt);
668 JSClass<JSIsolatedComponent>::StaticMethod("onAppear", &JSIsolatedComponent::Mock);
669 JSClass<JSIsolatedComponent>::StaticMethod("onDisAppear", &JSIsolatedComponent::Mock);
670 JSClass<JSIsolatedComponent>::StaticMethod("width", &JSIsolatedComponent::Mock, opt);
671 JSClass<JSIsolatedComponent>::StaticMethod("height", &JSIsolatedComponent::Mock, opt);
672 JSClass<JSIsolatedComponent>::InheritAndBind<JSViewAbstract>(globalObj);
673 }
674
Create(const JSCallbackInfo & info)675 void JSIsolatedComponent::Create(const JSCallbackInfo& info)
676 {
677 if (info.Length() < 1 || !info[0]->IsObject()) {
678 return;
679 }
680 CreateMockComponent("IsolatedComponent");
681 }
682
Mock(const JSCallbackInfo & info)683 void JSIsolatedComponent::Mock(const JSCallbackInfo& info) {}
684
JSBind(BindingTarget globalObj)685 void JSRemoteWindow::JSBind(BindingTarget globalObj)
686 {
687 JSClass<JSRemoteWindow>::Declare("RemoteWindow");
688 MethodOptions opt = MethodOptions::NONE;
689 JSClass<JSRemoteWindow>::StaticMethod("create", &JSRemoteWindow::Create, opt);
690
691 JSClass<JSRemoteWindow>::StaticMethod("onTouch", &JSRemoteWindow::Mock);
692 JSClass<JSRemoteWindow>::StaticMethod("onHover", &JSRemoteWindow::Mock);
693 JSClass<JSRemoteWindow>::StaticMethod("onKeyEvent", &JSRemoteWindow::Mock);
694 JSClass<JSRemoteWindow>::StaticMethod("onDeleteEvent", &JSRemoteWindow::Mock);
695 JSClass<JSRemoteWindow>::StaticMethod("onClick", &JSRemoteWindow::Mock);
696
697 JSClass<JSRemoteWindow>::InheritAndBind<JSViewAbstract>(globalObj);
698 }
699
Create(const JSCallbackInfo & info)700 void JSRemoteWindow::Create(const JSCallbackInfo& info)
701 {
702 if (info.Length() < 1) {
703 return;
704 }
705 CreateMockComponent("RemoteWindow");
706 }
707
Mock(const JSCallbackInfo & info)708 void JSRemoteWindow::Mock(const JSCallbackInfo& info) {}
709 } // namespace OHOS::Ace::Framework
710