1 /*
2 * Copyright (c) 2022 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 private public
19 #define protected public
20 #include "js_runtime.h"
21 #include "js_runtime_utils.h"
22 #include "js_worker.h"
23 #include "hdc_register.h"
24 #undef private
25 #undef protected
26
27 #include "event_runner.h"
28 #include "mock_js_runtime.h"
29 #include "hilog_wrapper.h"
30
31 using namespace testing;
32 using namespace testing::ext;
33
34 namespace OHOS {
35 namespace AbilityRuntime {
36 class HdcRegisterTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp() override;
41 void TearDown() override;
42 };
43
SetUpTestCase()44 void HdcRegisterTest::SetUpTestCase()
45 {}
46
TearDownTestCase()47 void HdcRegisterTest::TearDownTestCase()
48 {}
49
SetUp()50 void HdcRegisterTest::SetUp()
51 {}
52
TearDown()53 void HdcRegisterTest::TearDown()
54 {}
55
56 /**
57 * @tc.name: HdcRegisterTest_0100
58 * @tc.desc: HdcRegisterTest Test
59 * @tc.type: FUNC
60 */
61 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0100, TestSize.Level0)
62 {
63 const std::string processName = "";
64 const std::string bundleName = "";
65 bool debugApp = true;
66 auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
67
68 pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, nullptr);
69
70 EXPECT_TRUE(true);
71 }
72
73 /**
74 * @tc.name: HdcRegisterTest_0200
75 * @tc.desc: HdcRegisterTest Test
76 * @tc.type: FUNC
77 */
78 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0200, TestSize.Level0)
79 {
80 auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
81 pHdcRegister.registerHandler_ = nullptr;
82 pHdcRegister.StopHdcRegister();
83
84 EXPECT_TRUE(true);
85 }
86
87 /**
88 * @tc.name: HdcRegisterTest_0300
89 * @tc.desc: HdcRegisterTest Test
90 * @tc.type: FUNC
91 */
92 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0300, TestSize.Level0)
93 {
94 const std::string processName = "123";
95 const std::string bundleName = "123";
96 bool debugApp = true;
97 auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
98 pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, nullptr);
99 pHdcRegister.StopHdcRegister();
100
101 EXPECT_TRUE(true);
102 }
103 } // namespace AbilityRuntime
104 } // namespace OHOS
105