1/*
2 * Copyright (c) 2021 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#include "tooling/test/client_utils/test_list.h"
17
18#include "tooling/test/client_utils/test_util.h"
19
20// testcase list
21#include "tooling/test/testcases/js_breakpoint_arrow_test.h"
22#include "tooling/test/testcases/js_breakpoint_async_test.h"
23#include "tooling/test/testcases/js_breakpoint_test.h"
24#include "tooling/test/testcases/js_closure_scope_test.h"
25#include "tooling/test/testcases/js_container_test.h"
26#include "tooling/test/testcases/js_exception_test.h"
27#include "tooling/test/testcases/js_local_variable_scope_test.h"
28#include "tooling/test/testcases/js_module_variable_test.h"
29#include "tooling/test/testcases/js_source_test.h"
30#include "tooling/test/testcases/js_tracing_test.h"
31#include "tooling/test/testcases/js_watch_test.h"
32#include "tooling/test/testcases/js_heapdump_loop_test.h"
33#include "tooling/test/testcases/js_heapdump_test.h"
34#include "tooling/test/testcases/js_allocationtrack_loop_test.h"
35#include "tooling/test/testcases/js_allocationtrack_recursion_test.h"
36#include "tooling/test/testcases/js_allocationtrack_test.h"
37#include "tooling/test/testcases/js_stepinto_test.h"
38#include "tooling/test/testcases/js_stepout_test.h"
39#include "tooling/test/testcases/js_stepover_test.h"
40#include "tooling/test/testcases/js_stepinto_and_stepout_test.h"
41#include "tooling/test/testcases/js_stepout_before_function_test.h"
42#include "tooling/test/testcases/js_special_location_breakpoint_test.h"
43#include "tooling/test/testcases/js_multiple_common_breakpoint_test.h"
44#include "tooling/test/testcases/js_multiple_breakpoint_in_function_test.h"
45#include "tooling/test/testcases/js_breakpoint_cannot_hit_test.h"
46#include "tooling/test/testcases/js_breakpoint_in_different_branch.h"
47#include "tooling/test/testcases/js_watch_variable_test.h"
48#include "tooling/test/testcases/js_stepinto_arrow_test.h"
49#include "tooling/test/testcases/js_stepinto_async_test.h"
50#include "tooling/test/testcases/js_stepout_arrow_test.h"
51#include "tooling/test/testcases/js_stepout_async_test.h"
52#include "tooling/test/testcases/js_heapusage_test.h"
53#include "tooling/test/testcases/js_heapusage_async_test.h"
54#include "tooling/test/testcases/js_heapusage_step_test.h"
55#include "tooling/test/testcases/js_watch_basic_type_test.h"
56#include "tooling/test/testcases/js_watch_set_type_test.h"
57#include "tooling/test/testcases/js_watch_other_type_test.h"
58#include "tooling/test/testcases/js_stepinto_loop_test.h"
59#include "tooling/test/testcases/js_stepinto_recursion_test.h"
60#include "tooling/test/testcases/js_stepinto_switch_test.h"
61#include "tooling/test/testcases/js_stepover_loop_test.h"
62#include "tooling/test/testcases/js_stepover_recursion_test.h"
63#include "tooling/test/testcases/js_stepover_switch_test.h"
64#include "tooling/test/testcases/js_stepout_loop_test.h"
65#include "tooling/test/testcases/js_stepout_recursion_test.h"
66#include "tooling/test/testcases/js_stepout_switch_test.h"
67#include "tooling/test/testcases/js_breakpoint_loop_test.h"
68#include "tooling/test/testcases/js_breakpoint_recursion_test.h"
69#include "tooling/test/testcases/js_breakpoint_switch_test.h"
70#include "tooling/test/testcases/js_heapusage_loop_test.h"
71#include "tooling/test/testcases/js_heapusage_recursion_test.h"
72#include "tooling/test/testcases/js_smart_stepInto_test.h"
73
74namespace panda::ecmascript::tooling::test {
75static std::string g_currentTestName = "";
76
77static void RegisterTests()
78{
79    // Register testcases
80    TestUtil::RegisterTest("JsBreakpointTest", GetJsBreakpointTest());
81    TestUtil::RegisterTest("JsBreakpointArrowTest", GetJsBreakpointArrowTest());
82    TestUtil::RegisterTest("JsBreakpointAsyncTest", GetJsBreakpointAsyncTest());
83    TestUtil::RegisterTest("JsClosureScopeTest", GetJsClosureScopeTest());
84    TestUtil::RegisterTest("JsLocalVariableScopeTest", GetJsLocalVariableScopeTest());
85    TestUtil::RegisterTest("JsExceptionTest", GetJsExceptionTest());
86    TestUtil::RegisterTest("JsContainerTest", GetJsContainerTest());
87    TestUtil::RegisterTest("JsModuleVariableTest", GetJsModuleVariableTest());
88    TestUtil::RegisterTest("JsSourceTest", GetJsSourceTest());
89    TestUtil::RegisterTest("JsTracingTest", GetJsTracingTest());
90    TestUtil::RegisterTest("JsWatchTest", GetJsWatchTest());
91    TestUtil::RegisterTest("JsHeapdumpTest", GetJsHeapdumpTest());
92    TestUtil::RegisterTest("JsAllocationtrackTest", GetJsAllocationtrackTest());
93    TestUtil::RegisterTest("JsStepintoTest", GetJsStepintoTest());
94    TestUtil::RegisterTest("JsStepoutTest", GetJsStepoutTest());
95    TestUtil::RegisterTest("JsStepoverTest", GetJsStepoverTest());
96    TestUtil::RegisterTest("JsStepintoAndStepoutTest", GetJsStepintoAndStepoutTest());
97    TestUtil::RegisterTest("JsStepoutBeforeFunctiontTest", GetJsStepoutBeforeFunctionTest());
98    TestUtil::RegisterTest("JsSpecialLocationBreakpointTest", GetJsSpecialLocationBreakpointTest());
99    TestUtil::RegisterTest("JsMultipleCommonBreakpointTest", GetJsMultipleCommonBreakpointTest());
100    TestUtil::RegisterTest("JsMultipleBreakpointInFunctionTest", GetJsMultipleBreakpointInFunctionTest());
101    TestUtil::RegisterTest("JsBreakpointCannotHitTest", GetJsBreakpointCannotHitTest());
102    TestUtil::RegisterTest("JsBreakpointInDifferentBranchTest", GetJsBreakpointInDifferentBranchTest());
103    TestUtil::RegisterTest("JsWatchVariableTest", GetJsWatchVariableTest());
104    TestUtil::RegisterTest("JsStepintoArrowTest", GetJsStepintoArrowTest());
105    TestUtil::RegisterTest("JsStepintoAsyncTest", GetJsStepintoAsyncTest());
106    TestUtil::RegisterTest("JsStepoutArrowTest", GetJsStepoutArrowTest());
107    TestUtil::RegisterTest("JsStepoutAsyncTest", GetJsStepoutAsyncTest());
108    TestUtil::RegisterTest("JsHeapusageTest", GetJsHeapusageTest());
109    TestUtil::RegisterTest("JsHeapusageAsyncTest", GetJsHeapusageAsyncTest());
110    TestUtil::RegisterTest("JsHeapusageStepTest", GetJsHeapusageStepTest());
111    TestUtil::RegisterTest("JsHeapdumpLoopTest", GetJsHeapdumpLoopTest());
112    TestUtil::RegisterTest("JsAllocationTrackLoopTest", GetJsAllocationTrackLoopTest());
113    TestUtil::RegisterTest("JsAllocationTrackRecursionTest", GetJsAllocationTrackRecursionTest());
114    TestUtil::RegisterTest("JsJsWatchBasicTypeTest", GetJsWatchBasicTypeTest());
115    TestUtil::RegisterTest("JsJsWatchSetTypeTest", GetJsWatchSetTypeTest());
116    TestUtil::RegisterTest("JsJsWatchOtherTypeTest", GetJsWatchOtherTypeTest());
117    TestUtil::RegisterTest("JsStepintoLoopTest", GetJsStepintoLoopTest());
118    TestUtil::RegisterTest("JsStepintoRecursionTest", GetJsStepintoRecursionTest());
119    TestUtil::RegisterTest("JsStepintoSwitchTest", GetJsStepintoSwitchTest());
120    TestUtil::RegisterTest("JsStepoverLoopTest", GetJsStepoverLoopTest());
121    TestUtil::RegisterTest("JsStepoverRecursionTest", GetJsStepoverRecursionTest());
122    TestUtil::RegisterTest("JsStepoverSwitchTest", GetJsStepoverSwitchTest());
123    TestUtil::RegisterTest("JsStepoutLoopTest", GetJsStepoutLoopTest());
124    TestUtil::RegisterTest("JsStepoutRecursionTest", GetJsStepoutRecursionTest());
125    TestUtil::RegisterTest("JsStepoutSwitchTest", GetJsStepoutSwitchTest());
126    TestUtil::RegisterTest("JsBreakpointLoopTest", GetJsBreakpointLoopTest());
127    TestUtil::RegisterTest("JsBreakpointRecursionTest", GetJsBreakpointRecursionTest());
128    TestUtil::RegisterTest("JsBreakpointSwitchTest", GetJsBreakpointSwitchTest());
129    TestUtil::RegisterTest("JsHeapusageLoopTest", GetJsHeapusageLoopTest());
130    TestUtil::RegisterTest("JsHeapusageRecursionTest", GetJsHeapusageRecursionTest());
131    TestUtil::RegisterTest("JsSmartStepoutTest", GetJsSmartStepoutTest());
132}
133
134std::vector<const char *> GetTestList()
135{
136    RegisterTests();
137    std::vector<const char *> res;
138
139    auto &tests = TestUtil::GetTests();
140    for (const auto &entry : tests) {
141        res.push_back(entry.first.c_str());
142    }
143    return res;
144}
145
146void SetCurrentTestName(const std::string &testName)
147{
148    g_currentTestName = testName;
149}
150
151std::string GetCurrentTestName()
152{
153    return g_currentTestName;
154}
155
156std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName)
157{
158    return TestUtil::GetTest(testName)->GetEntryPoint();
159}
160}  // namespace panda::ecmascript::tooling::test
161