• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ecmascript/ecma_vm.h"
17 #include "ecmascript/napi/include/jsnapi.h"
18 #include "ecmascript/tests/test_helper.h"
19 #include "tooling/test/utils/test_list.h"
20 #include "ecmascript/debugger/js_debugger.h"
21 
22 namespace panda::ecmascript::tooling::test {
23 using panda::test::TestHelper;
24 
25 class DebuggerEntryTest : public testing::TestWithParam<const char *> {
26 public:
SetUpTestCase()27     static void SetUpTestCase()
28     {
29         GTEST_LOG_(INFO) << "SetUpTestCase";
30     }
31 
TearDownTestCase()32     static void TearDownTestCase()
33     {
34         GTEST_LOG_(INFO) << "TearDownCase";
35     }
36 
SetUp()37     void SetUp() override
38     {
39         SetCurrentTestName(GetParam());
40         TestHelper::CreateEcmaVMWithScope(instance, thread, scope);
41         JSNApi::DebugOption debugOption = {DEBUGGER_TEST_LIBRARY, true, -1};
42         JSNApi::StartDebugger(instance, debugOption);
43         if (instance->GetJsDebuggerManager() != nullptr) {
44             instance->GetJsDebuggerManager()->DisableObjectHashDisplay();
45         }
46     }
47 
TearDown()48     void TearDown() override
49     {
50         JSNApi::StopDebugger(instance);
51         TestHelper::DestroyEcmaVMWithScope(instance, scope);
52     }
53 
54     EcmaVM *instance {nullptr};
55     EcmaHandleScope *scope {nullptr};
56     JSThread *thread {nullptr};
57 };
58 
HWTEST_P_L0(DebuggerEntryTest,DebuggerSuite)59 HWTEST_P_L0(DebuggerEntryTest, DebuggerSuite)
60 {
61     std::string testName = GetCurrentTestName();
62     std::cout << "Running " << testName << std::endl;
63     ASSERT_NE(instance, nullptr);
64     auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
65     auto res = JSNApi::Execute(instance, pandaFile.c_str(), entryPoint.c_str());
66     ASSERT_TRUE(res);
67 }
68 
69 INSTANTIATE_TEST_SUITE_P(DebugAbcTest, DebuggerEntryTest, testing::ValuesIn(GetTestList()));
70 }  // namespace panda::ecmascript::tooling::test
71