xref: /base/startup/appspawn/test/mock/js_runtime.h (revision 69570cc8)
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 STUB_JS_RUNTIME_H
17#define STUB_JS_RUNTIME_H
18
19#include <iostream>
20#include <map>
21#include <memory>
22#include <string>
23
24namespace OHOS {
25namespace AbilityRuntime {
26    class Runtime {
27    public:
28        enum class Language {
29            JS = 0,
30        };
31
32        struct Options {
33            Language lang = Language::JS;
34            std::string bundleName;
35            std::string moduleName;
36            bool loadAce = true;
37            bool preload = false;
38            bool isBundle = true;
39            bool isDebugVersion = false;
40            bool isJsFramework = false;
41            bool isStageModel = true;
42            bool isTestFramework = false;
43            int32_t uid = -1;
44            // ArkTsCard start
45            bool isUnique = false;
46        };
47
48        static std::unique_ptr<Runtime> Create(const Options &options)
49        {
50            return std::make_unique<Runtime>();
51        }
52        static void SavePreloaded(std::unique_ptr<Runtime> &&instance) {}
53
54        Runtime() {};
55        ~Runtime() {};
56
57        void PreloadSystemModule(const std::string &moduleName)
58        {
59            return;
60        }
61
62        Runtime(const Runtime &) = delete;
63        Runtime(Runtime &&) = delete;
64        Runtime &operator=(const Runtime &) = delete;
65        Runtime &operator=(Runtime &&) = delete;
66    };
67}  // namespace AbilityRuntime
68namespace Ace {
69    class AceForwardCompatibility {
70    public:
71        AceForwardCompatibility() {}
72        ~AceForwardCompatibility() {}
73
74        static const char *GetAceLibName()
75        {
76            return "";
77        }
78
79        static void ReclaimFileCache(int32_t pid)
80        {
81            return;
82        }
83    };
84}  // namespace Ace
85
86namespace AppExecFwk {
87    class MainThread {
88    public:
89        MainThread() {}
90        ~MainThread() {}
91
92        static void PreloadExtensionPlugin() {}
93        static void Start() {}
94        static void StartChild(std::map<std::string, int> &map) {}
95    };
96}  // namespace AppExecFwk
97
98}  // namespace OHOS
99#endif  // STUB_JS_RUNTIME_H