1e509ee18Sopenharmony_ci/*
2e509ee18Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3e509ee18Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e509ee18Sopenharmony_ci * you may not use this file except in compliance with the License.
5e509ee18Sopenharmony_ci * You may obtain a copy of the License at
6e509ee18Sopenharmony_ci *
7e509ee18Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e509ee18Sopenharmony_ci *
9e509ee18Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e509ee18Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e509ee18Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e509ee18Sopenharmony_ci * See the License for the specific language governing permissions and
13e509ee18Sopenharmony_ci * limitations under the License.
14e509ee18Sopenharmony_ci */
15e509ee18Sopenharmony_ci
16e509ee18Sopenharmony_ci#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H
17e509ee18Sopenharmony_ci#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H
18e509ee18Sopenharmony_ci
19e509ee18Sopenharmony_ci#include <utility>
20e509ee18Sopenharmony_ci
21e509ee18Sopenharmony_ci#include "agent/runtime_impl.h"
22e509ee18Sopenharmony_ci#include "backend/js_pt_hooks.h"
23e509ee18Sopenharmony_ci#include "test/utils/test_channel.h"
24e509ee18Sopenharmony_ci
25e509ee18Sopenharmony_cinamespace panda::ecmascript::tooling::test {
26e509ee18Sopenharmony_ciusing DebuggerStmtCallback = std::function<bool(const JSPtLocation &)>;
27e509ee18Sopenharmony_ciusing BreakpointCallback = std::function<bool(const JSPtLocation &)>;
28e509ee18Sopenharmony_ciusing LoadModuleCallback = std::function<bool(std::string_view)>;
29e509ee18Sopenharmony_ciusing ExceptionCallback = std::function<bool(const JSPtLocation &)>;
30e509ee18Sopenharmony_ciusing SingleStepCallback = std::function<bool(const JSPtLocation &)>;
31e509ee18Sopenharmony_ciusing NativeOutCallback = std::function<bool()>;
32e509ee18Sopenharmony_ciusing VmStartCallback = std::function<bool()>;
33e509ee18Sopenharmony_ciusing VmDeathCallback = std::function<bool()>;
34e509ee18Sopenharmony_ciusing Scenario = std::function<bool()>;
35e509ee18Sopenharmony_ci
36e509ee18Sopenharmony_cienum class DebugEvent {
37e509ee18Sopenharmony_ci    BREAKPOINT,
38e509ee18Sopenharmony_ci    LOAD_MODULE,
39e509ee18Sopenharmony_ci    PAUSED,
40e509ee18Sopenharmony_ci    STEP_COMPLETE,
41e509ee18Sopenharmony_ci    EXCEPTION,
42e509ee18Sopenharmony_ci    METHOD_ENTRY,
43e509ee18Sopenharmony_ci    SINGLE_STEP,
44e509ee18Sopenharmony_ci    VM_START,
45e509ee18Sopenharmony_ci    VM_INITIALIZATION,
46e509ee18Sopenharmony_ci    VM_DEATH,
47e509ee18Sopenharmony_ci    UNINITIALIZED,
48e509ee18Sopenharmony_ci    DROPFRAME,
49e509ee18Sopenharmony_ci    CHECK_COMPLETE
50e509ee18Sopenharmony_ci};
51e509ee18Sopenharmony_ci
52e509ee18Sopenharmony_cistd::ostream &operator<<(std::ostream &out, DebugEvent value);
53e509ee18Sopenharmony_ci
54e509ee18Sopenharmony_cistruct TestEvents {
55e509ee18Sopenharmony_ci    DebuggerStmtCallback debuggerStmt;
56e509ee18Sopenharmony_ci    BreakpointCallback breakpoint;
57e509ee18Sopenharmony_ci    LoadModuleCallback loadModule;
58e509ee18Sopenharmony_ci    ExceptionCallback exception;
59e509ee18Sopenharmony_ci    SingleStepCallback singleStep;
60e509ee18Sopenharmony_ci    NativeOutCallback nativeOut;
61e509ee18Sopenharmony_ci    VmStartCallback vmStart;
62e509ee18Sopenharmony_ci    VmDeathCallback vmDeath;
63e509ee18Sopenharmony_ci
64e509ee18Sopenharmony_ci    Scenario scenario;
65e509ee18Sopenharmony_ci    const EcmaVM *vm_ {nullptr};
66e509ee18Sopenharmony_ci    JSDebugger *debugInterface_ {nullptr};
67e509ee18Sopenharmony_ci    DebuggerImpl *debugger_ {nullptr};
68e509ee18Sopenharmony_ci    RuntimeImpl *runtime_ {nullptr};
69e509ee18Sopenharmony_ci    TestChannel *channel_ {nullptr};
70e509ee18Sopenharmony_ci    TestEvents();
71e509ee18Sopenharmony_ci    virtual ~TestEvents() = default;
72e509ee18Sopenharmony_ci
73e509ee18Sopenharmony_ci    virtual std::pair<std::string, std::string> GetEntryPoint() = 0;
74e509ee18Sopenharmony_ci};
75e509ee18Sopenharmony_ci}  // namespace panda::ecmascript::tooling::test
76e509ee18Sopenharmony_ci
77e509ee18Sopenharmony_ci#endif  // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H
78