• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "hdc_register.h"
21 #undef private
22 #undef protected
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace AbilityRuntime {
29 class HdcRegisterTest : 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 HdcRegisterTest::SetUpTestCase()
38 {}
39 
TearDownTestCase()40 void HdcRegisterTest::TearDownTestCase()
41 {}
42 
SetUp()43 void HdcRegisterTest::SetUp()
44 {}
45 
TearDown()46 void HdcRegisterTest::TearDown()
47 {}
48 
49 /**
50  * @tc.name: HdcRegisterTest_0100
51  * @tc.desc: HdcRegisterTest Test
52  * @tc.type: FUNC
53  */
54 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0100, TestSize.Level0)
55 {
56     const std::string processName = "";
57     const std::string bundleName = "";
58     bool debugApp = true;
59     auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
60 
61     pHdcRegister.StartHdcRegister(bundleName, processName, debugApp,
62         AbilityRuntime::HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, nullptr);
63 
64     EXPECT_NE(pHdcRegister.registerHdcHandler_, nullptr);
65 }
66 
67 /**
68  * @tc.name: HdcRegisterTest_0200
69  * @tc.desc: HdcRegisterTest Test
70  * @tc.type: FUNC
71  */
72 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0200, TestSize.Level0)
73 {
74     auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
75     pHdcRegister.registerHdcHandler_ = nullptr;
76     pHdcRegister.StopHdcRegister();
77 
78     EXPECT_EQ(pHdcRegister.registerHdcHandler_, nullptr);
79 }
80 
81 /**
82  * @tc.name: HdcRegisterTest_0300
83  * @tc.desc: HdcRegisterTest Test
84  * @tc.type: FUNC
85  */
86 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0300, TestSize.Level1)
87 {
88     const std::string processName = "123";
89     const std::string bundleName = "123";
90     bool debugApp = true;
91     auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
92     pHdcRegister.StartHdcRegister(bundleName, processName, debugApp,
93         AbilityRuntime::HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, nullptr);
94     pHdcRegister.StopHdcRegister();
95 
96     EXPECT_EQ(pHdcRegister.registerHdcHandler_, nullptr);
97 }
98 
99 /**
100  * @tc.name: HdcRegisterTest_0400
101  * @tc.desc: HdcRegisterTest Test
102  * @tc.type: FUNC
103  */
104 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0400, TestSize.Level1)
105 {
106     const std::string processName = "123";
107     const std::string bundleName = "123";
108     bool debugApp = true;
109     auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
110     pHdcRegister.StartHdcRegister(bundleName, processName, debugApp,
111         AbilityRuntime::HdcRegister::DebugRegisterMode::LOCAL_DEBUG_REG, nullptr);
112     EXPECT_EQ(pHdcRegister.registerLocalHandler_, nullptr);
113     pHdcRegister.StopHdcRegister();
114     EXPECT_EQ(pHdcRegister.registerLocalHandler_, nullptr);
115 }
116 
117 /**
118  * @tc.name: HdcRegisterTest_0500
119  * @tc.desc: HdcRegisterTest Test
120  * @tc.type: FUNC
121  */
122 HWTEST_F(HdcRegisterTest, HdcRegisterTest_0500, TestSize.Level1)
123 {
124     const std::string processName = "123";
125     const std::string bundleName = "123";
126     bool debugApp = true;
127     auto &pHdcRegister = AbilityRuntime::HdcRegister::Get();
128     pHdcRegister.StartHdcRegister(bundleName, processName, debugApp,
129         AbilityRuntime::HdcRegister::DebugRegisterMode::BOTH_REG, nullptr);
130     EXPECT_NE(pHdcRegister.registerHdcHandler_, nullptr);
131     EXPECT_EQ(pHdcRegister.registerLocalHandler_, nullptr);
132     pHdcRegister.StopHdcRegister();
133     EXPECT_EQ(pHdcRegister.registerHdcHandler_, nullptr);
134     EXPECT_EQ(pHdcRegister.registerLocalHandler_, nullptr);
135 }
136 }  // namespace AbilityRuntime
137 }  // namespace OHOS
138