• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <gtest/gtest.h>
17 
18 #define protected public
19 #include "js_child_process.h"
20 #undef protected
21 #include "hilog_wrapper.h"
22 #include "js_runtime.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace AbilityRuntime {
29 class JsChildProcessTest : public testing::Test {
30 public:
31     static void SetUpTestCase();
32     static void TearDownTestCase();
33     void SetUp() override;
34     void TearDown() override;
35 };
36 
SetUpTestCase()37 void JsChildProcessTest::SetUpTestCase()
38 {}
39 
TearDownTestCase()40 void JsChildProcessTest::TearDownTestCase()
41 {}
42 
SetUp()43 void JsChildProcessTest::SetUp()
44 {}
45 
TearDown()46 void JsChildProcessTest::TearDown()
47 {}
48 
49 /**
50  * @tc.number: JsChildProcessCreate_0100
51  * @tc.desc: Test JsChildProcessTest Create works
52  * @tc.type: FUNC
53  */
54 HWTEST_F(JsChildProcessTest, JsChildProcessCreate_0100, TestSize.Level0)
55 {
56     HILOG_DEBUG("JsChildProcessCreate_0100 called.");
57     std::unique_ptr<Runtime> runtime = std::make_unique<JsRuntime>();
58     auto process = JsChildProcess::Create(runtime);
59     EXPECT_TRUE(process != nullptr);
60 }
61 
62 /**
63  * @tc.number: JsChildProcessInit_0100
64  * @tc.desc: Test JsChildProcess Init works
65  * @tc.type: FUNC
66  */
67 HWTEST_F(JsChildProcessTest, JsChildProcessInit_0100, TestSize.Level0)
68 {
69     HILOG_DEBUG("JsChildProcessInit_0100 called.");
70     std::unique_ptr<Runtime> runtime = std::make_unique<JsRuntime>();
71     auto process = JsChildProcess::Create(runtime);
72     EXPECT_TRUE(process != nullptr);
73 
74     std::shared_ptr<ChildProcessStartInfo> info = std::make_shared<ChildProcessStartInfo>();
75     info->name = "AProcess";
76     info->srcEntry = "./ets/process/AProcess.ts";
77     info->moduleName = "entry";
78 
79     process->Init(info);
80     EXPECT_TRUE(process->processStartInfo_ != nullptr);
81 }
82 }  // namespace AbilityRuntime
83 }  // namespace OHOS