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 MOCK_RUNTIME_H 17 #define MOCK_RUNTIME_H 18 19 #include <gtest/gtest.h> 20 21 #include "cj_runtime.h" 22 23 namespace OHOS { 24 namespace AbilityRuntime { 25 class cjMockRuntime : public CJRuntime { 26 public: 27 cjMockRuntime() = default; 28 ~cjMockRuntime() = default; 29 30 Language GetLanguage() const override 31 { 32 return Language::CJ; 33 } 34 35 void StartDebugMode(const DebugOption debugOption) override {} 36 37 void FinishPreload() override {} 38 bool LoadRepairPatch(const std::string& patchFile, const std::string& baseFile) override 39 { 40 return true; 41 } 42 bool NotifyHotReloadPage() override 43 { 44 return true; 45 } 46 bool SuspendVM(uint32_t tid) override 47 { 48 return true; 49 } 50 void ResumeVM(uint32_t tid) override {} 51 bool UnLoadRepairPatch(const std::string& patchFile) override 52 { 53 return true; 54 } 55 void DumpHeapSnapshot(bool isPrivate) override 56 { 57 return; 58 } 59 void DestroyHeapProfiler() override 60 { 61 return; 62 } 63 void ForceFullGC() override 64 { 65 return; 66 } 67 void AllowCrossThreadExecution() override 68 { 69 return; 70 } 71 void GetHeapPrepare() override 72 { 73 return; 74 } 75 void NotifyApplicationState(bool isBackground) override 76 { 77 return; 78 } 79 void PreloadSystemModule(const std::string& moduleName) override 80 { 81 return; 82 } RunScript(const std::string& path, const std::string& hapPath, bool useCommonChunk = false)83 bool RunScript(const std::string& path, const std::string& hapPath, bool useCommonChunk = false) 84 { 85 return true; 86 } Initialize(const Options& options)87 bool Initialize(const Options& options) 88 { 89 return true; 90 } Deinitialize()91 void Deinitialize() {} LoadScript(const std::string& path, std::vector<uint8_t>* buffer = nullptr, bool isBundle = false)92 bool LoadScript(const std::string& path, std::vector<uint8_t>* buffer = nullptr, bool isBundle = false) 93 { 94 return true; 95 } 96 void RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath) override 97 { 98 return; 99 } 100 void SetDeviceDisconnectCallback(const std::function<bool()> &cb) override 101 { 102 return; 103 } 104 105 void StartProfiler(const DebugOption debugOption) override {} 106 public: 107 Language language; 108 }; 109 } // namespace AbilityRuntime 110 } // namespace OHOS 111 #endif // MOCK_RUNTIME_H 112