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