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 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_MOCK_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_MOCK_H 18 19 #include "bridge/declarative_frontend/engine/bindings.h" 20 #include "bridge/declarative_frontend/engine/bindings_defines.h" 21 #include "bridge/declarative_frontend/engine/functions/js_function.h" 22 #include "bridge/declarative_frontend/engine/js_types.h" 23 24 namespace OHOS::Ace::Framework { 25 class JSMock { 26 public: 27 static void JSBind(BindingTarget globalObj); 28 static bool PreloadWorkerRequireNative(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& global); 29 static bool InitModule(const shared_ptr<JsRuntime>& runtime, shared_ptr<JsValue>& thisObj, 30 const std::string& moduleName); 31 }; 32 33 class JSMockBaseNode { 34 public: 35 JSMockBaseNode() = default; 36 ~JSMockBaseNode() = default; 37 38 static void JSBind(BindingTarget globalObj); ConstructorCallback(const JSCallbackInfo & info)39 static void ConstructorCallback(const JSCallbackInfo& info) {} DestructorCallback(JSMockBaseNode * node)40 static void DestructorCallback(JSMockBaseNode* node) {} FinishUpdateFunc(const JSCallbackInfo & info)41 void FinishUpdateFunc(const JSCallbackInfo& info) {} Create(const JSCallbackInfo & info)42 void Create(const JSCallbackInfo& info) {} PostTouchEvent(const JSCallbackInfo & info)43 void PostTouchEvent(const JSCallbackInfo& info) {} UpdateStart(const JSCallbackInfo & info)44 void UpdateStart(const JSCallbackInfo& info) {} UpdateEnd(const JSCallbackInfo & info)45 void UpdateEnd(const JSCallbackInfo& info) {} Dispose(const JSCallbackInfo & info)46 void Dispose(const JSCallbackInfo& info) {} 47 }; 48 49 class JSMockViewPU { 50 public: 51 JSMockViewPU() = default; 52 ~JSMockViewPU() = default; 53 54 static void JSBind(BindingTarget globalObj, std::string name); Id(const JSCallbackInfo & info)55 void Id(const JSCallbackInfo& info) {} UpdateStateVars(const JSCallbackInfo & info)56 void UpdateStateVars(const JSCallbackInfo& info) {} AboutToReuseInternal(const JSCallbackInfo & info)57 void AboutToReuseInternal(const JSCallbackInfo& info) {} AboutToRecycleInternal(const JSCallbackInfo & info)58 void AboutToRecycleInternal(const JSCallbackInfo& info) {} UpdateDirtyElements(const JSCallbackInfo & info)59 void UpdateDirtyElements(const JSCallbackInfo& info) {} 60 }; 61 62 class JSMockScopeUtil { 63 public: 64 JSMockScopeUtil() = default; 65 ~JSMockScopeUtil() = default; 66 67 static void JSBind(BindingTarget globalObj); SyncInstanceId(const JSCallbackInfo & info)68 static void SyncInstanceId(const JSCallbackInfo& info) {} RestoreInstanceId(const JSCallbackInfo & info)69 static void RestoreInstanceId(const JSCallbackInfo& info) {} 70 }; 71 72 class MockCustomDialogController { 73 public: 74 MockCustomDialogController() = default; 75 ~MockCustomDialogController() = default; 76 77 static void JSBind(BindingTarget globalObj); Open(const JSCallbackInfo & info)78 void Open(const JSCallbackInfo& info) {} Close(const JSCallbackInfo & info)79 void Close(const JSCallbackInfo& info) {} 80 }; 81 82 class JSMockNativeCustomSpan { 83 public: 84 JSMockNativeCustomSpan() = default; 85 ~JSMockNativeCustomSpan() = default; 86 87 static void JSBind(BindingTarget globalObj); Invalidate(const JSCallbackInfo & info)88 void Invalidate(const JSCallbackInfo& info) {} 89 }; 90 91 class JSMockViewBuildNodeBase { 92 public: 93 JSMockViewBuildNodeBase() = default; 94 ~JSMockViewBuildNodeBase() = default; 95 96 static void JSBind(BindingTarget globalObj); ConstructorCallback(const JSCallbackInfo & info)97 static void ConstructorCallback(const JSCallbackInfo& info) {} DestructorCallback(JSMockViewBuildNodeBase * node)98 static void DestructorCallback(JSMockViewBuildNodeBase* node) {} SetArkThemeScopeManager(const JSCallbackInfo & info)99 static void SetArkThemeScopeManager(const JSCallbackInfo& info) {} Id(const JSCallbackInfo & info)100 void Id(const JSCallbackInfo& info) {} DebugInfo(const JSCallbackInfo & info)101 void DebugInfo(const JSCallbackInfo& info) {} DebugInfoElmtId(const JSCallbackInfo & info)102 void DebugInfoElmtId(const JSCallbackInfo& info) {} GetChildById(const JSCallbackInfo & info)103 void GetChildById(const JSCallbackInfo& info) {} AddChild(const JSCallbackInfo & info)104 void AddChild(const JSCallbackInfo& info) {} PurgeDeletedElmtIds(const JSCallbackInfo & info)105 void PurgeDeletedElmtIds(const JSCallbackInfo& info) {} UpdateStateVarsOfChildByElmtId(const JSCallbackInfo & info)106 void UpdateStateVarsOfChildByElmtId(const JSCallbackInfo& info) {} CreateOrGetNode(const JSCallbackInfo & info)107 void CreateOrGetNode(const JSCallbackInfo& info) {} IfElseBranchUpdateFunction(const JSCallbackInfo & info)108 void IfElseBranchUpdateFunction(const JSCallbackInfo& info) {} OnWillApplyThemeInternally(const JSCallbackInfo & info)109 void OnWillApplyThemeInternally(const JSCallbackInfo& info) {} OnWillApplyTheme(const JSCallbackInfo & info)110 void OnWillApplyTheme(const JSCallbackInfo& info) {} OnGlobalThemeChanged(const JSCallbackInfo & info)111 void OnGlobalThemeChanged(const JSCallbackInfo& info) {} 112 }; 113 } // namespace OHOS::Ace::Framework 114 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_MOCK_H 115