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("onTouch", &JSForm::Mock);
82 JSClass<JSForm>::StaticMethod("onKeyEvent", &JSForm::Mock);
83 JSClass<JSForm>::StaticMethod("onDeleteEvent", &JSForm::Mock);
84 JSClass<JSForm>::StaticMethod("onClick", &JSForm::Mock);
85
86 JSClass<JSForm>::InheritAndBind<JSViewAbstract>(globalObj);
87 }
88
Create(const JSCallbackInfo & info)89 void JSRichText::Create(const JSCallbackInfo& info)
90 {
91 if (info.Length() < 1) {
92 return;
93 }
94 CreateMockComponent("RichText");
95 }
96
Mock(const JSCallbackInfo & info)97 void JSRichText::Mock(const JSCallbackInfo& info) {}
98
JSBind(BindingTarget globalObj)99 void JSRichText::JSBind(BindingTarget globalObj)
100 {
101 JSClass<JSRichText>::Declare("RichText");
102 JSClass<JSRichText>::StaticMethod("create", &JSRichText::Create);
103 JSClass<JSRichText>::StaticMethod("onStart", &JSRichText::Mock);
104 JSClass<JSRichText>::StaticMethod("onComplete", &JSRichText::Mock);
105 JSClass<JSRichText>::InheritAndBind<JSViewAbstract>(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 return;
245 }
246
247 CreateMockComponent("Web");
248 }
249
Mock(const JSCallbackInfo & info)250 void JSWeb::Mock(const JSCallbackInfo& info) {}
251
JSBind(BindingTarget globalObj)252 void JSWeb::JSBind(BindingTarget globalObj)
253 {
254 JSClass<JSWeb>::Declare("Web");
255 JSClass<JSWeb>::StaticMethod("create", &JSWeb::Create);
256 JSClass<JSWeb>::StaticMethod("onAlert", &JSWeb::Mock);
257 JSClass<JSWeb>::StaticMethod("onBeforeUnload", &JSWeb::Mock);
258 JSClass<JSWeb>::StaticMethod("onConfirm", &JSWeb::Mock);
259 JSClass<JSWeb>::StaticMethod("onPrompt", &JSWeb::Mock);
260 JSClass<JSWeb>::StaticMethod("onConsole", &JSWeb::Mock);
261 JSClass<JSWeb>::StaticMethod("onPageBegin", &JSWeb::Mock);
262 JSClass<JSWeb>::StaticMethod("onPageEnd", &JSWeb::Mock);
263 JSClass<JSWeb>::StaticMethod("onProgressChange", &JSWeb::Mock);
264 JSClass<JSWeb>::StaticMethod("onTitleReceive", &JSWeb::Mock);
265 JSClass<JSWeb>::StaticMethod("onGeolocationHide", &JSWeb::Mock);
266 JSClass<JSWeb>::StaticMethod("onGeolocationShow", &JSWeb::Mock);
267 JSClass<JSWeb>::StaticMethod("onRequestSelected", &JSWeb::Mock);
268 JSClass<JSWeb>::StaticMethod("onShowFileSelector", &JSWeb::Mock);
269 JSClass<JSWeb>::StaticMethod("javaScriptAccess", &JSWeb::Mock);
270 JSClass<JSWeb>::StaticMethod("fileExtendAccess", &JSWeb::Mock);
271 JSClass<JSWeb>::StaticMethod("fileAccess", &JSWeb::Mock);
272 JSClass<JSWeb>::StaticMethod("onDownloadStart", &JSWeb::Mock);
273 JSClass<JSWeb>::StaticMethod("onErrorReceive", &JSWeb::Mock);
274 JSClass<JSWeb>::StaticMethod("onHttpErrorReceive", &JSWeb::Mock);
275 JSClass<JSWeb>::StaticMethod("onUrlLoadIntercept", &JSWeb::Mock);
276 JSClass<JSWeb>::StaticMethod("onlineImageAccess", &JSWeb::Mock);
277 JSClass<JSWeb>::StaticMethod("domStorageAccess", &JSWeb::Mock);
278 JSClass<JSWeb>::StaticMethod("imageAccess", &JSWeb::Mock);
279 JSClass<JSWeb>::StaticMethod("mixedMode", &JSWeb::Mock);
280 JSClass<JSWeb>::StaticMethod("zoomAccess", &JSWeb::Mock);
281 JSClass<JSWeb>::StaticMethod("geolocationAccess", &JSWeb::Mock);
282 JSClass<JSWeb>::StaticMethod("javaScriptProxy", &JSWeb::Mock);
283 JSClass<JSWeb>::StaticMethod("userAgent", &JSWeb::Mock);
284 JSClass<JSWeb>::StaticMethod("onRenderExited", &JSWeb::Mock);
285 JSClass<JSWeb>::StaticMethod("onRefreshAccessedHistory", &JSWeb::Mock);
286 JSClass<JSWeb>::StaticMethod("cacheMode", &JSWeb::Mock);
287 JSClass<JSWeb>::StaticMethod("overviewModeAccess", &JSWeb::Mock);
288 JSClass<JSWeb>::StaticMethod("fileFromUrlAccess", &JSWeb::Mock);
289 JSClass<JSWeb>::StaticMethod("databaseAccess", &JSWeb::Mock);
290 JSClass<JSWeb>::StaticMethod("textZoomAtio", &JSWeb::Mock);
291 JSClass<JSWeb>::StaticMethod("textZoomRatio", &JSWeb::Mock);
292 JSClass<JSWeb>::StaticMethod("webDebuggingAccess", &JSWeb::Mock);
293 JSClass<JSWeb>::StaticMethod("initialScale", &JSWeb::Mock);
294 JSClass<JSWeb>::StaticMethod("backgroundColor", &JSWeb::Mock);
295 JSClass<JSWeb>::StaticMethod("onKeyEvent", &JSWeb::Mock);
296 JSClass<JSWeb>::StaticMethod("onTouch", &JSWeb::Mock);
297 JSClass<JSWeb>::StaticMethod("onMouse", &JSWeb::Mock);
298 JSClass<JSWeb>::StaticMethod("onResourceLoad", &JSWeb::Mock);
299 JSClass<JSWeb>::StaticMethod("onScaleChange", &JSWeb::Mock);
300 JSClass<JSWeb>::StaticMethod("password", &JSWeb::Mock);
301 JSClass<JSWeb>::StaticMethod("tableData", &JSWeb::Mock);
302 JSClass<JSWeb>::StaticMethod("onFileSelectorShow", &JSWeb::Mock);
303 JSClass<JSWeb>::StaticMethod("onHttpAuthRequest", &JSWeb::Mock);
304 JSClass<JSWeb>::StaticMethod("onSslErrorEventReceive", &JSWeb::Mock);
305 JSClass<JSWeb>::StaticMethod("onClientAuthenticationRequest", &JSWeb::Mock);
306 JSClass<JSWeb>::InheritAndBind<JSViewAbstract>(globalObj);
307
308 JSWebDialog::JSBind(globalObj);
309 JSWebGeolocation::JSBind(globalObj);
310 JSWebResourceRequest::JSBind(globalObj);
311 JSWebResourceError::JSBind(globalObj);
312 JSWebResourceResponse::JSBind(globalObj);
313 JSWebConsoleLog::JSBind(globalObj);
314 JSFileSelectorParam::JSBind(globalObj);
315 JSFileSelectorResult::JSBind(globalObj);
316 JSWebHttpAuth::JSBind(globalObj);
317 JSWebSslError::JSBind(globalObj);
318 JSWebSslSelectCert::JSBind(globalObj);
319 }
320
321 class JSWebCookie : public Referenced {
322 public:
JSBind(BindingTarget globalObj)323 static void JSBind(BindingTarget globalObj)
324 {
325 JSClass<JSWebCookie>::Declare("WebCookie");
326 JSClass<JSWebCookie>::StaticMethod("setCookie", &JSWeb::Mock);
327 JSClass<JSWebCookie>::StaticMethod("getCookie", &JSWeb::Mock);
328 JSClass<JSWebCookie>::StaticMethod("deleteEntireCookie", &JSWeb::Mock);
329 JSClass<JSWebCookie>::StaticMethod("saveCookieSync", &JSWeb::Mock);
330 JSClass<JSWebCookie>::Bind(globalObj);
331 }
332 };
333
334 class JSHitTestValue : public Referenced {
335 public:
JSBind(BindingTarget globalObj)336 static void JSBind(BindingTarget globalObj)
337 {
338 JSClass<JSHitTestValue>::Declare("HitTestValue");
339 JSClass<JSHitTestValue>::StaticMethod("getType", &JSWeb::Mock);
340 JSClass<JSHitTestValue>::StaticMethod("getExtra", &JSWeb::Mock);
341 JSClass<JSHitTestValue>::Bind(globalObj);
342 }
343 };
344
JSBind(BindingTarget globalObj)345 void JSWebController::JSBind(BindingTarget globalObj)
346 {
347 JSClass<JSWebController>::Declare("WebController");
348 JSClass<JSWebController>::StaticMethod("loadUrl", &JSWeb::Mock);
349 JSClass<JSWebController>::StaticMethod("runJavaScript", &JSWeb::Mock);
350 JSClass<JSWebController>::StaticMethod("refresh", &JSWeb::Mock);
351 JSClass<JSWebController>::StaticMethod("stop", &JSWeb::Mock);
352 JSClass<JSWebController>::StaticMethod("getHitTest", &JSWeb::Mock);
353 JSClass<JSWebController>::StaticMethod("registerJavaScriptProxy", &JSWeb::Mock);
354 JSClass<JSWebController>::StaticMethod("deleteJavaScriptRegister", &JSWeb::Mock);
355 JSClass<JSWebController>::StaticMethod("onInactive", &JSWeb::Mock);
356 JSClass<JSWebController>::StaticMethod("onActive", &JSWeb::Mock);
357 JSClass<JSWebController>::StaticMethod("zoom", &JSWeb::Mock);
358 JSClass<JSWebController>::StaticMethod("requestFocus", &JSWeb::Mock);
359 JSClass<JSWebController>::StaticMethod("loadData", &JSWeb::Mock);
360 JSClass<JSWebController>::StaticMethod("backward", &JSWeb::Mock);
361 JSClass<JSWebController>::StaticMethod("forward", &JSWeb::Mock);
362 JSClass<JSWebController>::StaticMethod("accessStep", &JSWeb::Mock);
363 JSClass<JSWebController>::StaticMethod("accessForward", &JSWeb::Mock);
364 JSClass<JSWebController>::StaticMethod("accessBackward", &JSWeb::Mock);
365 JSClass<JSWebController>::StaticMethod("clearHistory", &JSWeb::Mock);
366 JSClass<JSWebController>::StaticMethod("clearSslCache", &JSWeb::Mock);
367 JSClass<JSWebController>::StaticMethod("clearClientAuthenticationCache", &JSWeb::Mock);
368 JSClass<JSWebController>::StaticMethod("getCookieManager", &JSWeb::Mock);
369 JSClass<JSWebController>::StaticMethod("getHitTestValue", &JSWeb::Mock);
370 JSClass<JSWebController>::StaticMethod("backOrForward", &JSWeb::Mock);
371 JSClass<JSWebController>::StaticMethod("zoomIn", &JSWeb::Mock);
372 JSClass<JSWebController>::StaticMethod("zoomOut", &JSWeb::Mock);
373 JSClass<JSWebController>::StaticMethod("getPageHeight", &JSWeb::Mock);
374 JSClass<JSWebController>::StaticMethod("getTitle", &JSWeb::Mock);
375 JSClass<JSWebController>::StaticMethod("getWebId", &JSWeb::Mock);
376 JSClass<JSWebController>::StaticMethod("getDefaultUserAgent", &JSWeb::Mock);
377 JSClass<JSWebController>::Bind(globalObj);
378 JSWebCookie::JSBind(globalObj);
379 JSHitTestValue::JSBind(globalObj);
380 }
381
Create(const JSCallbackInfo & info)382 void JSXComponent::Create(const JSCallbackInfo& info)
383 {
384 if (info.Length() < 1 || !info[0]->IsObject()) {
385 return;
386 }
387 CreateMockComponent("XComponent");
388 }
389
Mock(const JSCallbackInfo & info)390 void JSXComponent::Mock(const JSCallbackInfo& info) {}
391
JSBind(BindingTarget globalObj)392 void JSXComponent::JSBind(BindingTarget globalObj)
393 {
394 JSClass<JSXComponent>::Declare("XComponent");
395 JSClass<JSXComponent>::StaticMethod("create", &JSXComponent::Create);
396 JSClass<JSXComponent>::StaticMethod("onLoad", &JSXComponent::Mock);
397 JSClass<JSXComponent>::StaticMethod("onDestroy", &JSXComponent::Mock);
398 JSClass<JSXComponent>::InheritAndBind<JSViewAbstract>(globalObj);
399 }
400
JSBind(BindingTarget globalObj)401 void JSXComponentController::JSBind(BindingTarget globalObj)
402 {
403 JSClass<JSXComponentController>::Declare("XComponentController");
404 JSClass<JSXComponentController>::StaticMethod("getXComponentSurfaceId", &JSXComponentController::Mock);
405 JSClass<JSXComponentController>::StaticMethod("getXComponentContext", &JSXComponentController::Mock);
406 JSClass<JSXComponentController>::StaticMethod("setXComponentSurfaceSize", &JSXComponentController::Mock);
407 JSClass<JSXComponentController>::Bind(globalObj);
408 }
409
Mock(const JSCallbackInfo & info)410 void JSXComponentController::Mock(const JSCallbackInfo& info) {}
411
Create(const JSCallbackInfo & info)412 void JSVideo::Create(const JSCallbackInfo& info)
413 {
414 if (info.Length() <= 0 || !info[0]->IsObject()) {
415 return;
416 }
417 CreateMockComponent("Video");
418 }
419
Mock(const JSCallbackInfo & info)420 void JSVideo::Mock(const JSCallbackInfo& info) {}
421
JSBind(BindingTarget globalObj)422 void JSVideo::JSBind(BindingTarget globalObj)
423 {
424 JSClass<JSVideo>::Declare("Video");
425 MethodOptions opt = MethodOptions::NONE;
426 JSClass<JSVideo>::StaticMethod("create", &JSVideo::Create, opt);
427 JSClass<JSVideo>::StaticMethod("muted", &JSVideo::Mock, opt);
428 JSClass<JSVideo>::StaticMethod("autoPlay", &JSVideo::Mock, opt);
429 JSClass<JSVideo>::StaticMethod("controls", &JSVideo::Mock, opt);
430 JSClass<JSVideo>::StaticMethod("loop", &JSVideo::Mock, opt);
431 JSClass<JSVideo>::StaticMethod("objectFit", &JSVideo::Mock, opt);
432
433 JSClass<JSVideo>::StaticMethod("onStart", &JSVideo::Mock);
434 JSClass<JSVideo>::StaticMethod("onPause", &JSVideo::Mock);
435 JSClass<JSVideo>::StaticMethod("onFinish", &JSVideo::Mock);
436 JSClass<JSVideo>::StaticMethod("onFullscreenChange", &JSVideo::Mock);
437 JSClass<JSVideo>::StaticMethod("onPrepared", &JSVideo::Mock);
438 JSClass<JSVideo>::StaticMethod("onSeeking", &JSVideo::Mock);
439 JSClass<JSVideo>::StaticMethod("onSeeked", &JSVideo::Mock);
440 JSClass<JSVideo>::StaticMethod("onUpdate", &JSVideo::Mock);
441 JSClass<JSVideo>::StaticMethod("onError", &JSVideo::Mock);
442
443 JSClass<JSVideo>::StaticMethod("onTouch", &JSVideo::Mock);
444 JSClass<JSVideo>::StaticMethod("onHover", &JSVideo::Mock);
445 JSClass<JSVideo>::StaticMethod("onKeyEvent", &JSVideo::Mock);
446 JSClass<JSVideo>::StaticMethod("onDeleteEvent", &JSVideo::Mock);
447 JSClass<JSVideo>::StaticMethod("onClick", &JSVideo::Mock);
448 JSClass<JSVideo>::StaticMethod("onAppear", &JSVideo::Mock);
449 JSClass<JSVideo>::StaticMethod("onDisAppear", &JSVideo::Mock);
450 JSClass<JSVideo>::StaticMethod("remoteMessage", &JSVideo::Mock);
451
452 // override method
453 JSClass<JSVideo>::StaticMethod("opacity", &JSVideo::Mock);
454 JSClass<JSVideo>::StaticMethod("transition", &JSVideo::Mock);
455 JSClass<JSVideo>::InheritAndBind<JSViewAbstract>(globalObj);
456 }
457
JSBind(BindingTarget globalObj)458 void JSVideoController::JSBind(BindingTarget globalObj)
459 {
460 JSClass<JSVideoController>::Declare("VideoController");
461 JSClass<JSVideoController>::StaticMethod("start", &JSVideoController::Mock);
462 JSClass<JSVideoController>::StaticMethod("pause", &JSVideoController::Mock);
463 JSClass<JSVideoController>::StaticMethod("stop", &JSVideoController::Mock);
464 JSClass<JSVideoController>::StaticMethod("setCurrentTime", &JSVideoController::Mock);
465 JSClass<JSVideoController>::StaticMethod("requestFullscreen", &JSVideoController::Mock);
466 JSClass<JSVideoController>::StaticMethod("exitFullscreen", &JSVideoController::Mock);
467 JSClass<JSVideoController>::Bind(globalObj);
468 }
469
Mock(const JSCallbackInfo & info)470 void JSVideoController::Mock(const JSCallbackInfo& info) {}
471
Create(const JSCallbackInfo & info)472 void JSPlugin::Create(const JSCallbackInfo& info)
473 {
474 if (info.Length() <= 0 || !info[0]->IsObject()) {
475 return;
476 }
477 CreateMockComponent("PluginComponent");
478 }
479
Mock(const JSCallbackInfo & info)480 void JSPlugin::Mock(const JSCallbackInfo& info) {}
481
JSBind(BindingTarget globalObj)482 void JSPlugin::JSBind(BindingTarget globalObj)
483 {
484 JSClass<JSPlugin>::Declare("PluginComponent");
485 MethodOptions opt = MethodOptions::NONE;
486 JSClass<JSPlugin>::StaticMethod("create", &JSPlugin::Create, opt);
487 JSClass<JSPlugin>::StaticMethod("size", &JSPlugin::Mock, opt);
488 JSClass<JSPlugin>::StaticMethod("width", &JSPlugin::Mock);
489 JSClass<JSPlugin>::StaticMethod("height", &JSPlugin::Mock);
490 JSClass<JSPlugin>::StaticMethod("onComplete", &JSPlugin::Mock);
491 JSClass<JSPlugin>::StaticMethod("onError", &JSPlugin::Mock);
492 JSClass<JSPlugin>::StaticMethod("onAppear", &JSPlugin::Mock);
493 JSClass<JSPlugin>::StaticMethod("onDisAppear", &JSPlugin::Mock);
494 JSClass<JSPlugin>::StaticMethod("onTouch", &JSPlugin::Mock);
495 JSClass<JSPlugin>::StaticMethod("onKeyEvent", &JSPlugin::Mock);
496 JSClass<JSPlugin>::StaticMethod("onDeleteEvent", &JSPlugin::Mock);
497 JSClass<JSPlugin>::StaticMethod("onClick", &JSPlugin::Mock);
498
499 JSClass<JSPlugin>::InheritAndBind<JSViewAbstract>(globalObj);
500 }
501
JSBind(BindingTarget globalObj)502 void JSUIExtension::JSBind(BindingTarget globalObj)
503 {
504 JSClass<JSUIExtension>::Declare("UIExtensionComponent");
505 MethodOptions opt = MethodOptions::NONE;
506 JSClass<JSUIExtension>::StaticMethod("create", &JSUIExtension::Create, opt);
507 JSClass<JSUIExtension>::StaticMethod("onRemoteReady", &JSUIExtension::Mock);
508 JSClass<JSUIExtension>::StaticMethod("onReceive", &JSUIExtension::Mock);
509 JSClass<JSUIExtension>::StaticMethod("onResult", &JSUIExtension::Mock);
510 JSClass<JSUIExtension>::StaticMethod("onRelease", &JSUIExtension::Mock);
511 JSClass<JSUIExtension>::StaticMethod("onError", &JSUIExtension::Mock);
512 JSClass<JSUIExtension>::InheritAndBind<JSViewAbstract>(globalObj);
513 }
514
Create(const JSCallbackInfo & info)515 void JSUIExtension::Create(const JSCallbackInfo& info)
516 {
517 if (!info[0]->IsObject()) {
518 return;
519 }
520 CreateMockComponent("UIExtensionComponent");
521 }
522
Mock(const JSCallbackInfo & info)523 void JSUIExtension::Mock(const JSCallbackInfo& info) {}
524 } // namespace OHOS::Ace::Framework
525