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 OHOS_ABILITY_RUNTIME_CJ_TEST_RUNNER_OBJECT_H 17 #define OHOS_ABILITY_RUNTIME_CJ_TEST_RUNNER_OBJECT_H 18 19 #include <memory> 20 21 #ifdef WINDOWS_PLATFORM 22 #define CJ_EXPORT __declspec(dllexport) 23 #else 24 #define CJ_EXPORT __attribute__((visibility("default"))) 25 #endif 26 27 extern "C" { 28 struct CJTestRunnerFuncs { 29 int64_t (*cjTestRunnerCreate)(const char* name); 30 void (*cjTestRunnerRelease)(int64_t id); 31 void (*cjTestRunnerOnRun)(int64_t id); 32 void (*cjTestRunnerOnPrepare)(int64_t id); 33 }; 34 35 CJ_EXPORT void RegisterCJTestRunnerFuncs(void (*registerFunc)(CJTestRunnerFuncs*)); 36 } 37 38 namespace OHOS { 39 namespace RunnerRuntime { 40 class CJTestRunnerObject { 41 public: 42 static std::shared_ptr<CJTestRunnerObject> LoadModule(const std::string& name); CJTestRunnerObject(int64_t id)43 explicit CJTestRunnerObject(int64_t id) : id_(id) {} 44 ~CJTestRunnerObject(); 45 void OnRun() const; 46 void OnPrepare() const; 47 private: 48 int64_t id_ = -1; 49 }; 50 } // namespace RunnerRuntime 51 } // namespace OHOS 52 53 #endif // OHOS_ABILITY_RUNTIME_CJ_TEST_RUNNER_OBJECT_H 54