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
GetInstance()28 PreviewMockModel* PreviewMockModel::GetInstance()
29 {
30 if (!instance_) {
31 if (Container::IsCurrentUseNewPipeline()) {
32 instance_.reset(new NG::PreviewMockModelNG());
33 } else {
34 instance_.reset(new Framework::PreviewMockModelImpl());
35 }
36 }
37 return instance_.get();
38 }
39
40 } // namespace OHOS::Ace
41
42 namespace OHOS::Ace::Framework {
43
CreateMockComponent(const std::string inspectorTag)44 void CreateMockComponent(const std::string inspectorTag)
45 {
46 OHOS::Ace::PreviewMockModel::GetInstance()->Create(inspectorTag);
47 }
48
Create(const JSCallbackInfo & info)49 void JSForm::Create(const JSCallbackInfo& info)
50 {
51 if (info.Length() == 0 || !info[0]->IsObject()) {
52 LOGE("form create fail due to FormComponent construct param is empty or type is not Object");
53 return;
54 }
55
56 CreateMockComponent("FormComponent");
57 }
58
Mock(const JSCallbackInfo & info)59 void JSForm::Mock(const JSCallbackInfo& info) {}
60
JSBind(BindingTarget globalObj)61 void JSForm::JSBind(BindingTarget globalObj)
62 {
63 JSClass<JSForm>::Declare("FormComponent");
64 MethodOptions opt = MethodOptions::NONE;
65 JSClass<JSForm>::StaticMethod("create", &JSForm::Create, opt);
66 JSClass<JSForm>::StaticMethod("size", &JSForm::Mock, opt);
67 JSClass<JSForm>::StaticMethod("dimension", &JSForm::Mock, opt);
68 JSClass<JSForm>::StaticMethod("allowUpdate", &JSForm::Mock, opt);
69 JSClass<JSForm>::StaticMethod("visibility", &JSForm::Mock, opt);
70 JSClass<JSForm>::StaticMethod("clip", &JSForm::Mock, opt);
71
72 JSClass<JSForm>::StaticMethod("onAcquired", &JSForm::Mock);
73 JSClass<JSForm>::StaticMethod("onError", &JSForm::Mock);
74 JSClass<JSForm>::StaticMethod("onUninstall", &JSForm::Mock);
75 JSClass<JSForm>::StaticMethod("onRouter", &JSForm::Mock);
76 JSClass<JSForm>::StaticMethod("onAppear", &JSForm::Mock);
77 JSClass<JSForm>::StaticMethod("onDisAppear", &JSForm::Mock);
78 JSClass<JSForm>::StaticMethod("onTouch", &JSForm::Mock);
79 JSClass<JSForm>::StaticMethod("onKeyEvent", &JSForm::Mock);
80 JSClass<JSForm>::StaticMethod("onDeleteEvent", &JSForm::Mock);
81 JSClass<JSForm>::StaticMethod("onClick", &JSForm::Mock);
82
83 JSClass<JSForm>::Inherit<JSViewAbstract>();
84 JSClass<JSForm>::Bind<>(globalObj);
85 }
86
Create(const JSCallbackInfo & info)87 void JSRichText::Create(const JSCallbackInfo& info)
88 {
89 if (info.Length() < 1) {
90 LOGI("richtext create error, info is non-valid");
91 return;
92 }
93 CreateMockComponent("RichText");
94 }
95
Mock(const JSCallbackInfo & info)96 void JSRichText::Mock(const JSCallbackInfo& info) {}
97
JSBind(BindingTarget globalObj)98 void JSRichText::JSBind(BindingTarget globalObj)
99 {
100 JSClass<JSRichText>::Declare("RichText");
101 JSClass<JSRichText>::StaticMethod("create", &JSRichText::Create);
102 JSClass<JSRichText>::StaticMethod("onStart", &JSRichText::Mock);
103 JSClass<JSRichText>::StaticMethod("onComplete", &JSRichText::Mock);
104 JSClass<JSRichText>::Inherit<JSViewAbstract>();
105 JSClass<JSRichText>::Bind<>(globalObj);
106 }
107
108 class JSWebDialog : public Referenced {
109 public:
JSBind(BindingTarget globalObj)110 static void JSBind(BindingTarget globalObj)
111 {
112 JSClass<JSWebDialog>::Declare("WebDialog");
113 JSClass<JSWebDialog>::StaticMethod("handleConfirm", &JSWeb::Mock);
114 JSClass<JSWebDialog>::StaticMethod("handleCancel", &JSWeb::Mock);
115 JSClass<JSWebDialog>::StaticMethod("handlePromptConfirm", &JSWeb::Mock);
116 JSClass<JSWebDialog>::Bind(globalObj);
117 }
118 };
119
120 class JSWebHttpAuth : public Referenced {
121 public:
JSBind(BindingTarget globalObj)122 static void JSBind(BindingTarget globalObj)
123 {
124 JSClass<JSWebHttpAuth>::Declare("WebHttpAuthResult");
125 JSClass<JSWebHttpAuth>::StaticMethod("confirm", &JSWeb::Mock);
126 JSClass<JSWebHttpAuth>::StaticMethod("cancel", &JSWeb::Mock);
127 JSClass<JSWebHttpAuth>::StaticMethod("isHttpAuthInfoSaved", &JSWeb::Mock);
128 JSClass<JSWebHttpAuth>::Bind(globalObj);
129 }
130 };
131
132 class JSWebSslError : public Referenced {
133 public:
JSBind(BindingTarget globalObj)134 static void JSBind(BindingTarget globalObj)
135 {
136 JSClass<JSWebSslError>::Declare("WebSslErrorResult");
137 JSClass<JSWebSslError>::StaticMethod("handleConfirm", &JSWeb::Mock);
138 JSClass<JSWebSslError>::StaticMethod("handleCancel", &JSWeb::Mock);
139 JSClass<JSWebSslError>::Bind(globalObj);
140 }
141 };
142
143 class JSWebSslSelectCert : public Referenced {
144 public:
JSBind(BindingTarget globalObj)145 static void JSBind(BindingTarget globalObj)
146 {
147 JSClass<JSWebSslSelectCert>::Declare("WebSelectCertResult");
148 JSClass<JSWebSslSelectCert>::StaticMethod("confirm", &JSWeb::Mock);
149 JSClass<JSWebSslSelectCert>::StaticMethod("cancel", &JSWeb::Mock);
150 JSClass<JSWebSslSelectCert>::StaticMethod("ignore", &JSWeb::Mock);
151 JSClass<JSWebSslSelectCert>::Bind(globalObj);
152 }
153 };
154
155 class JSWebConsoleLog : public Referenced {
156 public:
JSBind(BindingTarget globalObj)157 static void JSBind(BindingTarget globalObj)
158 {
159 JSClass<JSWebConsoleLog>::Declare("ConsoleMessage");
160 JSClass<JSWebConsoleLog>::StaticMethod("getLineNumber", &JSWeb::Mock);
161 JSClass<JSWebConsoleLog>::StaticMethod("getMessage", &JSWeb::Mock);
162 JSClass<JSWebConsoleLog>::StaticMethod("getMessageLevel", &JSWeb::Mock);
163 JSClass<JSWebConsoleLog>::StaticMethod("getSourceId", &JSWeb::Mock);
164 JSClass<JSWebConsoleLog>::Bind(globalObj);
165 }
166 };
167
168 class JSWebGeolocation : public Referenced {
169 public:
JSBind(BindingTarget globalObj)170 static void JSBind(BindingTarget globalObj)
171 {
172 JSClass<JSWebGeolocation>::Declare("WebGeolocation");
173 JSClass<JSWebGeolocation>::StaticMethod("invoke", &JSWeb::Mock);
174 JSClass<JSWebGeolocation>::Bind(globalObj);
175 }
176 };
177
178 class JSWebResourceError : public Referenced {
179 public:
JSBind(BindingTarget globalObj)180 static void JSBind(BindingTarget globalObj)
181 {
182 JSClass<JSWebResourceError>::Declare("WebResourceError");
183 JSClass<JSWebResourceError>::StaticMethod("getErrorCode", &JSWeb::Mock);
184 JSClass<JSWebResourceError>::StaticMethod("getErrorInfo", &JSWeb::Mock);
185 JSClass<JSWebResourceError>::Bind(globalObj);
186 }
187 };
188
189 class JSWebResourceResponse : public Referenced {
190 public:
JSBind(BindingTarget globalObj)191 static void JSBind(BindingTarget globalObj)
192 {
193 JSClass<JSWebResourceResponse>::Declare("WebResourceResponse");
194 JSClass<JSWebResourceResponse>::StaticMethod("getResponseData", &JSWeb::Mock);
195 JSClass<JSWebResourceResponse>::StaticMethod("getResponseEncoding", &JSWeb::Mock);
196 JSClass<JSWebResourceResponse>::StaticMethod("getResponseMimeType", &JSWeb::Mock);
197 JSClass<JSWebResourceResponse>::StaticMethod("getReasonMessage", &JSWeb::Mock);
198 JSClass<JSWebResourceResponse>::StaticMethod("getResponseCode", &JSWeb::Mock);
199 JSClass<JSWebResourceResponse>::StaticMethod("getResponseHeader", &JSWeb::Mock);
200 JSClass<JSWebResourceResponse>::Bind(globalObj);
201 }
202 };
203
204 class JSWebResourceRequest : public Referenced {
205 public:
JSBind(BindingTarget globalObj)206 static void JSBind(BindingTarget globalObj)
207 {
208 JSClass<JSWebResourceRequest>::Declare("WebResourceRequest");
209 JSClass<JSWebResourceRequest>::StaticMethod("getRequestUrl", &JSWeb::Mock);
210 JSClass<JSWebResourceRequest>::StaticMethod("getRequestHeader", &JSWeb::Mock);
211 JSClass<JSWebResourceRequest>::StaticMethod("isRequestGesture", &JSWeb::Mock);
212 JSClass<JSWebResourceRequest>::StaticMethod("isMainFrame", &JSWeb::Mock);
213 JSClass<JSWebResourceRequest>::StaticMethod("isRedirect", &JSWeb::Mock);
214 JSClass<JSWebResourceRequest>::Bind(globalObj);
215 }
216 };
217
218 class JSFileSelectorParam : public Referenced {
219 public:
JSBind(BindingTarget globalObj)220 static void JSBind(BindingTarget globalObj)
221 {
222 JSClass<JSFileSelectorParam>::Declare("FileSelectorParam");
223 JSClass<JSFileSelectorParam>::StaticMethod("getTitle", &JSWeb::Mock);
224 JSClass<JSFileSelectorParam>::StaticMethod("getMode", &JSWeb::Mock);
225 JSClass<JSFileSelectorParam>::StaticMethod("getAcceptType", &JSWeb::Mock);
226 JSClass<JSFileSelectorParam>::StaticMethod("isCapture", &JSWeb::Mock);
227 JSClass<JSFileSelectorParam>::Bind(globalObj);
228 }
229 };
230
231 class JSFileSelectorResult : public Referenced {
232 public:
JSBind(BindingTarget globalObj)233 static void JSBind(BindingTarget globalObj)
234 {
235 JSClass<JSFileSelectorResult>::Declare("FileSelectorResult");
236 JSClass<JSFileSelectorResult>::StaticMethod("handleFileList", &JSWeb::Mock);
237 JSClass<JSFileSelectorResult>::Bind(globalObj);
238 }
239 };
240
Create(const JSCallbackInfo & info)241 void JSWeb::Create(const JSCallbackInfo& info)
242 {
243 if (info.Length() < 1 || !info[0]->IsObject()) {
244 LOGI("web create error, info is invalid");
245 return;
246 }
247
248 CreateMockComponent("Web");
249 }
250
Mock(const JSCallbackInfo & info)251 void JSWeb::Mock(const JSCallbackInfo& info) {}
252
JSBind(BindingTarget globalObj)253 void JSWeb::JSBind(BindingTarget globalObj)
254 {
255 JSClass<JSWeb>::Declare("Web");
256 JSClass<JSWeb>::StaticMethod("create", &JSWeb::Create);
257 JSClass<JSWeb>::StaticMethod("onAlert", &JSWeb::Mock);
258 JSClass<JSWeb>::StaticMethod("onBeforeUnload", &JSWeb::Mock);
259 JSClass<JSWeb>::StaticMethod("onConfirm", &JSWeb::Mock);
260 JSClass<JSWeb>::StaticMethod("onPrompt", &JSWeb::Mock);
261 JSClass<JSWeb>::StaticMethod("onConsole", &JSWeb::Mock);
262 JSClass<JSWeb>::StaticMethod("onPageBegin", &JSWeb::Mock);
263 JSClass<JSWeb>::StaticMethod("onPageEnd", &JSWeb::Mock);
264 JSClass<JSWeb>::StaticMethod("onProgressChange", &JSWeb::Mock);
265 JSClass<JSWeb>::StaticMethod("onTitleReceive", &JSWeb::Mock);
266 JSClass<JSWeb>::StaticMethod("onGeolocationHide", &JSWeb::Mock);
267 JSClass<JSWeb>::StaticMethod("onGeolocationShow", &JSWeb::Mock);
268 JSClass<JSWeb>::StaticMethod("onRequestSelected", &JSWeb::Mock);
269 JSClass<JSWeb>::StaticMethod("onShowFileSelector", &JSWeb::Mock);
270 JSClass<JSWeb>::StaticMethod("javaScriptAccess", &JSWeb::Mock);
271 JSClass<JSWeb>::StaticMethod("fileExtendAccess", &JSWeb::Mock);
272 JSClass<JSWeb>::StaticMethod("fileAccess", &JSWeb::Mock);
273 JSClass<JSWeb>::StaticMethod("onDownloadStart", &JSWeb::Mock);
274 JSClass<JSWeb>::StaticMethod("onErrorReceive", &JSWeb::Mock);
275 JSClass<JSWeb>::StaticMethod("onHttpErrorReceive", &JSWeb::Mock);
276 JSClass<JSWeb>::StaticMethod("onUrlLoadIntercept", &JSWeb::Mock);
277 JSClass<JSWeb>::StaticMethod("onlineImageAccess", &JSWeb::Mock);
278 JSClass<JSWeb>::StaticMethod("domStorageAccess", &JSWeb::Mock);
279 JSClass<JSWeb>::StaticMethod("imageAccess", &JSWeb::Mock);
280 JSClass<JSWeb>::StaticMethod("mixedMode", &JSWeb::Mock);
281 JSClass<JSWeb>::StaticMethod("zoomAccess", &JSWeb::Mock);
282 JSClass<JSWeb>::StaticMethod("geolocationAccess", &JSWeb::Mock);
283 JSClass<JSWeb>::StaticMethod("javaScriptProxy", &JSWeb::Mock);
284 JSClass<JSWeb>::StaticMethod("userAgent", &JSWeb::Mock);
285 JSClass<JSWeb>::StaticMethod("onRenderExited", &JSWeb::Mock);
286 JSClass<JSWeb>::StaticMethod("onRefreshAccessedHistory", &JSWeb::Mock);
287 JSClass<JSWeb>::StaticMethod("cacheMode", &JSWeb::Mock);
288 JSClass<JSWeb>::StaticMethod("overviewModeAccess", &JSWeb::Mock);
289 JSClass<JSWeb>::StaticMethod("fileFromUrlAccess", &JSWeb::Mock);
290 JSClass<JSWeb>::StaticMethod("databaseAccess", &JSWeb::Mock);
291 JSClass<JSWeb>::StaticMethod("textZoomAtio", &JSWeb::Mock);
292 JSClass<JSWeb>::StaticMethod("textZoomRatio", &JSWeb::Mock);
293 JSClass<JSWeb>::StaticMethod("webDebuggingAccess", &JSWeb::Mock);
294 JSClass<JSWeb>::StaticMethod("initialScale", &JSWeb::Mock);
295 JSClass<JSWeb>::StaticMethod("backgroundColor", &JSWeb::Mock);
296 JSClass<JSWeb>::StaticMethod("onKeyEvent", &JSWeb::Mock);
297 JSClass<JSWeb>::StaticMethod("onTouch", &JSWeb::Mock);
298 JSClass<JSWeb>::StaticMethod("onMouse", &JSWeb::Mock);
299 JSClass<JSWeb>::StaticMethod("onResourceLoad", &JSWeb::Mock);
300 JSClass<JSWeb>::StaticMethod("onScaleChange", &JSWeb::Mock);
301 JSClass<JSWeb>::StaticMethod("password", &JSWeb::Mock);
302 JSClass<JSWeb>::StaticMethod("tableData", &JSWeb::Mock);
303 JSClass<JSWeb>::StaticMethod("onFileSelectorShow", &JSWeb::Mock);
304 JSClass<JSWeb>::StaticMethod("onHttpAuthRequest", &JSWeb::Mock);
305 JSClass<JSWeb>::StaticMethod("onSslErrorEventReceive", &JSWeb::Mock);
306 JSClass<JSWeb>::StaticMethod("onClientAuthenticationRequest", &JSWeb::Mock);
307 JSClass<JSWeb>::Inherit<JSViewAbstract>();
308 JSClass<JSWeb>::Bind(globalObj);
309
310 JSWebDialog::JSBind(globalObj);
311 JSWebGeolocation::JSBind(globalObj);
312 JSWebResourceRequest::JSBind(globalObj);
313 JSWebResourceError::JSBind(globalObj);
314 JSWebResourceResponse::JSBind(globalObj);
315 JSWebConsoleLog::JSBind(globalObj);
316 JSFileSelectorParam::JSBind(globalObj);
317 JSFileSelectorResult::JSBind(globalObj);
318 JSWebHttpAuth::JSBind(globalObj);
319 JSWebSslError::JSBind(globalObj);
320 JSWebSslSelectCert::JSBind(globalObj);
321 }
322
323 class JSWebCookie : public Referenced {
324 public:
JSBind(BindingTarget globalObj)325 static void JSBind(BindingTarget globalObj)
326 {
327 JSClass<JSWebCookie>::Declare("WebCookie");
328 JSClass<JSWebCookie>::StaticMethod("setCookie", &JSWeb::Mock);
329 JSClass<JSWebCookie>::StaticMethod("getCookie", &JSWeb::Mock);
330 JSClass<JSWebCookie>::StaticMethod("deleteEntireCookie", &JSWeb::Mock);
331 JSClass<JSWebCookie>::StaticMethod("saveCookieSync", &JSWeb::Mock);
332 JSClass<JSWebCookie>::Bind(globalObj);
333 }
334 };
335
336 class JSHitTestValue : public Referenced {
337 public:
JSBind(BindingTarget globalObj)338 static void JSBind(BindingTarget globalObj)
339 {
340 JSClass<JSHitTestValue>::Declare("HitTestValue");
341 JSClass<JSHitTestValue>::StaticMethod("getType", &JSWeb::Mock);
342 JSClass<JSHitTestValue>::StaticMethod("getExtra", &JSWeb::Mock);
343 JSClass<JSHitTestValue>::Bind(globalObj);
344 }
345 };
346
JSBind(BindingTarget globalObj)347 void JSWebController::JSBind(BindingTarget globalObj)
348 {
349 JSClass<JSWebController>::Declare("WebController");
350 JSClass<JSWebController>::StaticMethod("loadUrl", &JSWeb::Mock);
351 JSClass<JSWebController>::StaticMethod("runJavaScript", &JSWeb::Mock);
352 JSClass<JSWebController>::StaticMethod("refresh", &JSWeb::Mock);
353 JSClass<JSWebController>::StaticMethod("stop", &JSWeb::Mock);
354 JSClass<JSWebController>::StaticMethod("getHitTest", &JSWeb::Mock);
355 JSClass<JSWebController>::StaticMethod("registerJavaScriptProxy", &JSWeb::Mock);
356 JSClass<JSWebController>::StaticMethod("deleteJavaScriptRegister", &JSWeb::Mock);
357 JSClass<JSWebController>::StaticMethod("onInactive", &JSWeb::Mock);
358 JSClass<JSWebController>::StaticMethod("onActive", &JSWeb::Mock);
359 JSClass<JSWebController>::StaticMethod("zoom", &JSWeb::Mock);
360 JSClass<JSWebController>::StaticMethod("requestFocus", &JSWeb::Mock);
361 JSClass<JSWebController>::StaticMethod("loadData", &JSWeb::Mock);
362 JSClass<JSWebController>::StaticMethod("backward", &JSWeb::Mock);
363 JSClass<JSWebController>::StaticMethod("forward", &JSWeb::Mock);
364 JSClass<JSWebController>::StaticMethod("accessStep", &JSWeb::Mock);
365 JSClass<JSWebController>::StaticMethod("accessForward", &JSWeb::Mock);
366 JSClass<JSWebController>::StaticMethod("accessBackward", &JSWeb::Mock);
367 JSClass<JSWebController>::StaticMethod("clearHistory", &JSWeb::Mock);
368 JSClass<JSWebController>::StaticMethod("clearSslCache", &JSWeb::Mock);
369 JSClass<JSWebController>::StaticMethod("clearClientAuthenticationCache", &JSWeb::Mock);
370 JSClass<JSWebController>::StaticMethod("getCookieManager", &JSWeb::Mock);
371 JSClass<JSWebController>::StaticMethod("getHitTestValue", &JSWeb::Mock);
372 JSClass<JSWebController>::StaticMethod("backOrForward", &JSWeb::Mock);
373 JSClass<JSWebController>::StaticMethod("zoomIn", &JSWeb::Mock);
374 JSClass<JSWebController>::StaticMethod("zoomOut", &JSWeb::Mock);
375 JSClass<JSWebController>::StaticMethod("getPageHeight", &JSWeb::Mock);
376 JSClass<JSWebController>::StaticMethod("getTitle", &JSWeb::Mock);
377 JSClass<JSWebController>::StaticMethod("getWebId", &JSWeb::Mock);
378 JSClass<JSWebController>::StaticMethod("getDefaultUserAgent", &JSWeb::Mock);
379 JSClass<JSWebController>::Bind(globalObj);
380 JSWebCookie::JSBind(globalObj);
381 JSHitTestValue::JSBind(globalObj);
382 }
383
Create(const JSCallbackInfo & info)384 void JSXComponent::Create(const JSCallbackInfo& info)
385 {
386 if (info.Length() < 1 || !info[0]->IsObject()) {
387 LOGI("xcomponent create error, info is invalid");
388 return;
389 }
390 CreateMockComponent("XComponent");
391 }
392
Mock(const JSCallbackInfo & info)393 void JSXComponent::Mock(const JSCallbackInfo& info) {}
394
JSBind(BindingTarget globalObj)395 void JSXComponent::JSBind(BindingTarget globalObj)
396 {
397 JSClass<JSXComponent>::Declare("XComponent");
398 JSClass<JSXComponent>::StaticMethod("create", &JSXComponent::Create);
399 JSClass<JSXComponent>::StaticMethod("onLoad", &JSXComponent::Mock);
400 JSClass<JSXComponent>::StaticMethod("onDestroy", &JSXComponent::Mock);
401 JSClass<JSXComponent>::Inherit<JSViewAbstract>();
402 JSClass<JSXComponent>::Bind(globalObj);
403 }
404
JSBind(BindingTarget globalObj)405 void JSXComponentController::JSBind(BindingTarget globalObj)
406 {
407 JSClass<JSXComponentController>::Declare("XComponentController");
408 JSClass<JSXComponentController>::StaticMethod("getXComponentSurfaceId", &JSXComponentController::Mock);
409 JSClass<JSXComponentController>::StaticMethod("getXComponentContext", &JSXComponentController::Mock);
410 JSClass<JSXComponentController>::StaticMethod("setXComponentSurfaceSize", &JSXComponentController::Mock);
411 JSClass<JSXComponentController>::Bind(globalObj);
412 }
413
Mock(const JSCallbackInfo & info)414 void JSXComponentController::Mock(const JSCallbackInfo& info) {}
415
Create(const JSCallbackInfo & info)416 void JSVideo::Create(const JSCallbackInfo& info)
417 {
418 if (info.Length() <= 0 || !info[0]->IsObject()) {
419 LOGE("video create error, info is invalid.");
420 return;
421 }
422 CreateMockComponent("Video");
423 }
424
Mock(const JSCallbackInfo & info)425 void JSVideo::Mock(const JSCallbackInfo& info) {}
426
JSBind(BindingTarget globalObj)427 void JSVideo::JSBind(BindingTarget globalObj)
428 {
429 JSClass<JSVideo>::Declare("Video");
430 MethodOptions opt = MethodOptions::NONE;
431 JSClass<JSVideo>::StaticMethod("create", &JSVideo::Create, opt);
432 JSClass<JSVideo>::StaticMethod("muted", &JSVideo::Mock, opt);
433 JSClass<JSVideo>::StaticMethod("autoPlay", &JSVideo::Mock, opt);
434 JSClass<JSVideo>::StaticMethod("controls", &JSVideo::Mock, opt);
435 JSClass<JSVideo>::StaticMethod("loop", &JSVideo::Mock, opt);
436 JSClass<JSVideo>::StaticMethod("objectFit", &JSVideo::Mock, opt);
437
438 JSClass<JSVideo>::StaticMethod("onStart", &JSVideo::Mock);
439 JSClass<JSVideo>::StaticMethod("onPause", &JSVideo::Mock);
440 JSClass<JSVideo>::StaticMethod("onFinish", &JSVideo::Mock);
441 JSClass<JSVideo>::StaticMethod("onFullscreenChange", &JSVideo::Mock);
442 JSClass<JSVideo>::StaticMethod("onPrepared", &JSVideo::Mock);
443 JSClass<JSVideo>::StaticMethod("onSeeking", &JSVideo::Mock);
444 JSClass<JSVideo>::StaticMethod("onSeeked", &JSVideo::Mock);
445 JSClass<JSVideo>::StaticMethod("onUpdate", &JSVideo::Mock);
446 JSClass<JSVideo>::StaticMethod("onError", &JSVideo::Mock);
447
448 JSClass<JSVideo>::StaticMethod("onTouch", &JSVideo::Mock);
449 JSClass<JSVideo>::StaticMethod("onHover", &JSVideo::Mock);
450 JSClass<JSVideo>::StaticMethod("onKeyEvent", &JSVideo::Mock);
451 JSClass<JSVideo>::StaticMethod("onDeleteEvent", &JSVideo::Mock);
452 JSClass<JSVideo>::StaticMethod("onClick", &JSVideo::Mock);
453 JSClass<JSVideo>::StaticMethod("onAppear", &JSVideo::Mock);
454 JSClass<JSVideo>::StaticMethod("onDisAppear", &JSVideo::Mock);
455 JSClass<JSVideo>::StaticMethod("remoteMessage", &JSVideo::Mock);
456
457 JSClass<JSVideo>::Inherit<JSViewAbstract>();
458 // override method
459 JSClass<JSVideo>::StaticMethod("opacity", &JSVideo::Mock);
460 JSClass<JSVideo>::StaticMethod("transition", &JSVideo::Mock);
461 JSClass<JSVideo>::Bind<>(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 LOGE("plugin create error, info is invalid.");
482 return;
483 }
484 CreateMockComponent("PluginComponent");
485 }
486
Mock(const JSCallbackInfo & info)487 void JSPlugin::Mock(const JSCallbackInfo& info) {}
488
JSBind(BindingTarget globalObj)489 void JSPlugin::JSBind(BindingTarget globalObj)
490 {
491 JSClass<JSPlugin>::Declare("PluginComponent");
492 MethodOptions opt = MethodOptions::NONE;
493 JSClass<JSPlugin>::StaticMethod("create", &JSPlugin::Create, opt);
494 JSClass<JSPlugin>::StaticMethod("size", &JSPlugin::Mock, opt);
495 JSClass<JSPlugin>::StaticMethod("width", &JSPlugin::Mock);
496 JSClass<JSPlugin>::StaticMethod("height", &JSPlugin::Mock);
497 JSClass<JSPlugin>::StaticMethod("onComplete", &JSPlugin::Mock);
498 JSClass<JSPlugin>::StaticMethod("onError", &JSPlugin::Mock);
499 JSClass<JSPlugin>::StaticMethod("onAppear", &JSPlugin::Mock);
500 JSClass<JSPlugin>::StaticMethod("onDisAppear", &JSPlugin::Mock);
501 JSClass<JSPlugin>::StaticMethod("onTouch", &JSPlugin::Mock);
502 JSClass<JSPlugin>::StaticMethod("onKeyEvent", &JSPlugin::Mock);
503 JSClass<JSPlugin>::StaticMethod("onDeleteEvent", &JSPlugin::Mock);
504 JSClass<JSPlugin>::StaticMethod("onClick", &JSPlugin::Mock);
505
506 JSClass<JSPlugin>::Inherit<JSViewAbstract>();
507 JSClass<JSPlugin>::Bind<>(globalObj);
508 }
509
510 } // namespace OHOS::Ace::Framework
511