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#include "test/utils/test_list.h"
17e509ee18Sopenharmony_ci
18e509ee18Sopenharmony_ci#include "test/utils/test_util.h"
19e509ee18Sopenharmony_ci
20e509ee18Sopenharmony_ci// testcase list
21e509ee18Sopenharmony_ci#include "test/testcases/js_range_error_test.h"
22e509ee18Sopenharmony_ci#include "test/testcases/js_single_step_test.h"
23e509ee18Sopenharmony_ci#include "test/testcases/js_step_into_test.h"
24e509ee18Sopenharmony_ci#include "test/testcases/js_step_over_test.h"
25e509ee18Sopenharmony_ci#include "test/testcases/js_step_out_test.h"
26e509ee18Sopenharmony_ci#include "test/testcases/js_syntax_exception_test.h"
27e509ee18Sopenharmony_ci#include "test/testcases/js_throw_exception_test.h"
28e509ee18Sopenharmony_ci#include "test/testcases/js_variable_first_test.h"
29e509ee18Sopenharmony_ci#include "test/testcases/js_variable_second_test.h"
30e509ee18Sopenharmony_ci#include "test/testcases/js_dropframe_test.h"
31e509ee18Sopenharmony_ci
32e509ee18Sopenharmony_cinamespace panda::ecmascript::tooling::test {
33e509ee18Sopenharmony_cistatic std::string g_currentTestName = "";
34e509ee18Sopenharmony_ci
35e509ee18Sopenharmony_cistatic void RegisterTests()
36e509ee18Sopenharmony_ci{
37e509ee18Sopenharmony_ci    // Register testcases
38e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsSingleStepTest", GetJsSingleStepTest());
39e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsRangeErrorTest", GetJsRangeErrorTest());
40e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsSyntaxExceptionTest", GetJsSyntaxExceptionTest());
41e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsThrowExceptionTest", GetJsThrowExceptionTest());
42e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsStepIntoTest", GetJsStepIntoTest());
43e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsStepOverTest", GetJsStepOverTest());
44e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsStepOutTest", GetJsStepOutTest());
45e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JSDropFrameTest", GetJsDropFrameTest());
46e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsVariableFirstTest", GetJsVariableFirstTest());
47e509ee18Sopenharmony_ci    TestUtil::RegisterTest("JsVariableSecondTest", GetJsVariableSecondTest());
48e509ee18Sopenharmony_ci}
49e509ee18Sopenharmony_ci
50e509ee18Sopenharmony_cistd::vector<const char *> GetTestList()
51e509ee18Sopenharmony_ci{
52e509ee18Sopenharmony_ci    RegisterTests();
53e509ee18Sopenharmony_ci    std::vector<const char *> res;
54e509ee18Sopenharmony_ci
55e509ee18Sopenharmony_ci    auto &tests = TestUtil::GetTests();
56e509ee18Sopenharmony_ci    for (const auto &entry : tests) {
57e509ee18Sopenharmony_ci        res.push_back(entry.first.c_str());
58e509ee18Sopenharmony_ci    }
59e509ee18Sopenharmony_ci    return res;
60e509ee18Sopenharmony_ci}
61e509ee18Sopenharmony_ci
62e509ee18Sopenharmony_civoid SetCurrentTestName(const std::string &testName)
63e509ee18Sopenharmony_ci{
64e509ee18Sopenharmony_ci    g_currentTestName = testName;
65e509ee18Sopenharmony_ci}
66e509ee18Sopenharmony_ci
67e509ee18Sopenharmony_cistd::string GetCurrentTestName()
68e509ee18Sopenharmony_ci{
69e509ee18Sopenharmony_ci    return g_currentTestName;
70e509ee18Sopenharmony_ci}
71e509ee18Sopenharmony_ci
72e509ee18Sopenharmony_cistd::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName)
73e509ee18Sopenharmony_ci{
74e509ee18Sopenharmony_ci    return TestUtil::GetTest(testName)->GetEntryPoint();
75e509ee18Sopenharmony_ci}
76e509ee18Sopenharmony_ci}  // namespace panda::ecmascript::tooling::test
77