• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "dh_modem_context_ext.h"
19 #include "distributed_hardware_errno.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 namespace {
26 
27 class DHModemContextExtTest : public testing::Test {
28 public:
29     static void SetUpTestCase(void);
30     static void TearDownTestCase(void);
31     void SetUp();
32     void TearDown();
33 };
34 
SetUp()35 void DHModemContextExtTest::SetUp() {}
36 
TearDown()37 void DHModemContextExtTest::TearDown() {}
38 
SetUpTestCase()39 void DHModemContextExtTest::SetUpTestCase() {}
40 
TearDownTestCase()41 void DHModemContextExtTest::TearDownTestCase() {}
42 
43 #ifdef DHARDWARE_OPEN_MODEM_EXT
44     HWTEST_F(DHModemContextExtTest, GetHandler_001, TestSize.Level1)
45     {
46         int32_t ret = DHModemContextExt::GetInstance().GetHandler();
47         EXPECT_EQ(ret, DH_FWK_SUCCESS);
48     }
49 
50     HWTEST_F(DHModemContextExtTest, GetModemExtInstance_001, TestSize.Level1)
51     {
52         DHModemContextExt::GetInstance().soHandle_ = nullptr;
53         DHModemContextExt::GetInstance().GetModemExtInstance();
54         EXPECT_NE(DHModemContextExt::GetInstance().distributedModemExt_, nullptr);
55     }
56 
57     HWTEST_F(DHModemContextExtTest, GetModemExtInstance_002, TestSize.Level1)
58     {
59         int32_t ret = DHModemContextExt::GetInstance().GetHandler();
60         EXPECT_EQ(ret, DH_FWK_SUCCESS);
61         DHModemContextExt::GetInstance().GetModemExtInstance();
62         EXPECT_NE(DHModemContextExt::GetInstance().distributedModemExt_, nullptr);
63     }
64 
65     HWTEST_F(DHModemContextExtTest, UnInit_001, TestSize.Level1)
66     {
67         DHModemContextExt::GetInstance().soHandle_ = nullptr;
68         int32_t ret = DHModemContextExt::GetInstance().UnInit();
69         EXPECT_EQ(ret, ERR_DH_FWK_LOADER_HANDLER_IS_NULL);
70     }
71 
72     HWTEST_F(DHModemContextExtTest, UnInit_002, TestSize.Level1)
73     {
74         int32_t ret = DHModemContextExt::GetInstance().GetHandler();
75         EXPECT_EQ(ret, DH_FWK_SUCCESS);
76         ret = DHModemContextExt::GetInstance().UnInit();
77         EXPECT_EQ(ret, DH_FWK_SUCCESS);
78     }
79 #endif
80 }
81 }
82 }