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 "ril_modem_test.h"
17 #include "ril_test_util.h"
18 
19 namespace OHOS {
20 namespace Telephony {
21 using namespace OHOS::HDI::Ril::V1_3;
22 using namespace testing::ext;
23 namespace {
24 sptr<OHOS::HDI::Ril::V1_3::IRil> g_rilInterface = nullptr;
25 }
26 
SetUpTestCase()27 void RILModemTest::SetUpTestCase()
28 {
29     TELEPHONY_LOGI("----------RilCallTest gtest start ------------");
30     RilTestUtil::GetInstance().Init();
31     g_rilInterface = RilTestUtil::GetRilInterface();
32 }
33 
TearDownTestCase()34 void RILModemTest::TearDownTestCase() {}
35 
SetUp()36 void RILModemTest::SetUp() {}
37 
TearDown()38 void RILModemTest::TearDown() {}
39 
40 /**
41  * @tc.number   Telephony_DriverSystem_ShutDown_V1_0100
42  * @tc.name     Shut down
43  * @tc.desc     Function test
44  */
45 HWTEST_F(RILModemTest, Telephony_DriverSystem_ShutDown_V1_0100, Function | MediumTest | Level3)
46 {
47     if (!RilTestUtil::IsReady(SLOTID_1)) {
48         return;
49     }
50     int32_t ret = g_rilInterface->ShutDown(SLOTID_1, RilTestUtil::GetSerialId());
51     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
52     EXPECT_EQ(SUCCESS, ret);
53     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_SHUT_DOWN));
54 }
55 
56 /**
57  * @tc.number   Telephony_DriverSystem_ShutDown_V1_0200
58  * @tc.name     Shut down
59  * @tc.desc     Function test
60  */
61 HWTEST_F(RILModemTest, Telephony_DriverSystem_ShutDown_V1_0200, Function | MediumTest | Level3)
62 {
63     if (!RilTestUtil::IsReady(SLOTID_2)) {
64         return;
65     }
66     int32_t ret = g_rilInterface->ShutDown(SLOTID_2, RilTestUtil::GetSerialId());
67     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
68     EXPECT_EQ(SUCCESS, ret);
69     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_SHUT_DOWN));
70 }
71 
72 /**
73  * @tc.number   Telephony_DriverSystem_SetRadioState_V1_0100
74  * @tc.name     Set radio state
75  * @tc.desc     Function test
76  */
77 HWTEST_F(RILModemTest, Telephony_DriverSystem_SetRadioState_V1_0100, Function | MediumTest | Level3)
78 {
79     if (!RilTestUtil::IsReady(SLOTID_1)) {
80         return;
81     }
82     int32_t ret = g_rilInterface->SetRadioState(SLOTID_1, RilTestUtil::GetSerialId(), 1, 0);
83     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
84     EXPECT_EQ(SUCCESS, ret);
85     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_SET_RADIO_STATUS));
86 }
87 
88 /**
89  * @tc.number   Telephony_DriverSystem_SetRadioState_V1_0200
90  * @tc.name     Set radio state
91  * @tc.desc     Function test
92  */
93 HWTEST_F(RILModemTest, Telephony_DriverSystem_SetRadioState_V1_0200, Function | MediumTest | Level3)
94 {
95     if (!RilTestUtil::IsReady(SLOTID_2)) {
96         return;
97     }
98     int32_t ret = g_rilInterface->SetRadioState(SLOTID_1, RilTestUtil::GetSerialId(), 1, 0);
99     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
100     EXPECT_EQ(SUCCESS, ret);
101     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_SET_RADIO_STATUS));
102 }
103 
104 /**
105  * @tc.number   Telephony_DriverSystem_GetRadioState_V1_0100
106  * @tc.name     Get radio state
107  * @tc.desc     Function test
108  */
109 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetRadioState_V1_0100, Function | MediumTest | Level3)
110 {
111     if (!RilTestUtil::IsReady(SLOTID_1)) {
112         return;
113     }
114     int32_t ret = g_rilInterface->GetRadioState(SLOTID_1, RilTestUtil::GetSerialId());
115     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
116     EXPECT_EQ(SUCCESS, ret);
117     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_RADIO_STATUS));
118 }
119 
120 /**
121  * @tc.number   Telephony_DriverSystem_GetRadioState_V1_0200
122  * @tc.name     Get radio state
123  * @tc.desc     Function test
124  */
125 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetRadioState_V1_0200, Function | MediumTest | Level3)
126 {
127     if (!RilTestUtil::IsReady(SLOTID_2)) {
128         return;
129     }
130     int32_t ret = g_rilInterface->GetRadioState(SLOTID_2, RilTestUtil::GetSerialId());
131     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
132     EXPECT_EQ(SUCCESS, ret);
133     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_RADIO_STATUS));
134 }
135 
136 /**
137  * @tc.number   Telephony_DriverSystem_GetImei_V1_0100
138  * @tc.name     Get imei
139  * @tc.desc     Function test
140  */
141 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetImei_V1_0100, Function | MediumTest | Level3)
142 {
143     if (!RilTestUtil::IsReady(SLOTID_1)) {
144         return;
145     }
146     int32_t ret = g_rilInterface->GetImei(SLOTID_1, RilTestUtil::GetSerialId());
147     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
148     EXPECT_EQ(SUCCESS, ret);
149     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_IMEI));
150 }
151 
152 /**
153  * @tc.number   Telephony_DriverSystem_GetImei_V1_0200
154  * @tc.name     Get imei
155  * @tc.desc     Function test
156  */
157 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetImei_V1_0200, Function | MediumTest | Level3)
158 {
159     if (!RilTestUtil::IsReady(SLOTID_2)) {
160         return;
161     }
162     int32_t ret = g_rilInterface->GetImei(SLOTID_2, RilTestUtil::GetSerialId());
163     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
164     EXPECT_EQ(SUCCESS, ret);
165     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_IMEI));
166 }
167 
168 /**
169  * @tc.number   Telephony_DriverSystem_GetImeiSv_V1_0100
170  * @tc.name     Get imeiSv
171  * @tc.desc     Function test
172  */
173 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetImeiSv_V1_0100, Function | MediumTest | Level3)
174 {
175     if (!RilTestUtil::IsReady(SLOTID_1)) {
176         return;
177     }
178     int32_t ret = g_rilInterface->GetImeiSv(SLOTID_1, RilTestUtil::GetSerialId());
179     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
180     EXPECT_EQ(SUCCESS, ret);
181     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_IMEISV));
182 }
183 
184 /**
185  * @tc.number   Telephony_DriverSystem_GetImeiSv_V1_0200
186  * @tc.name     Get imeiSv
187  * @tc.desc     Function test
188  */
189 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetImeiSv_V1_0200, Function | MediumTest | Level3)
190 {
191     if (!RilTestUtil::IsReady(SLOTID_2)) {
192         return;
193     }
194     int32_t ret = g_rilInterface->GetImeiSv(SLOTID_2, RilTestUtil::GetSerialId());
195     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
196     EXPECT_EQ(SUCCESS, ret);
197     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_IMEISV));
198 }
199 
200 /**
201  * @tc.number   Telephony_DriverSystem_GetMeid_V1_0100
202  * @tc.name     Get meid
203  * @tc.desc     Function test
204  */
205 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetMeid_V1_0100, Function | MediumTest | Level3)
206 {
207     if (!RilTestUtil::IsReady(SLOTID_1)) {
208         return;
209     }
210     int32_t ret = g_rilInterface->GetMeid(SLOTID_1, RilTestUtil::GetSerialId());
211     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
212     EXPECT_EQ(SUCCESS, ret);
213     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_MEID));
214 }
215 
216 /**
217  * @tc.number   Telephony_DriverSystem_GetMeid_V1_0200
218  * @tc.name     Get meid
219  * @tc.desc     Function test
220  */
221 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetMeid_V1_0200, Function | MediumTest | Level3)
222 {
223     if (!RilTestUtil::IsReady(SLOTID_2)) {
224         return;
225     }
226     int32_t ret = g_rilInterface->GetMeid(SLOTID_2, RilTestUtil::GetSerialId());
227     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
228     EXPECT_EQ(SUCCESS, ret);
229     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_MEID));
230 }
231 
232 /**
233  * @tc.number   Telephony_DriverSystem_GetBasebandVersion_V1_0100
234  * @tc.name     Get base band version
235  * @tc.desc     Function test
236  */
237 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetBasebandVersion_V1_0100, Function | MediumTest | Level3)
238 {
239     if (!RilTestUtil::IsReady(SLOTID_1)) {
240         return;
241     }
242     int32_t ret = g_rilInterface->GetBasebandVersion(SLOTID_1, RilTestUtil::GetSerialId());
243     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
244     EXPECT_EQ(SUCCESS, ret);
245     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_BASEBAND_VERSION));
246 }
247 
248 /**
249  * @tc.number   Telephony_DriverSystem_GetBasebandVersion_V1_0200
250  * @tc.name     Get base band version
251  * @tc.desc     Function test
252  */
253 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetBasebandVersion_V1_0200, Function | MediumTest | Level3)
254 {
255     if (!RilTestUtil::IsReady(SLOTID_2)) {
256         return;
257     }
258     int32_t ret = g_rilInterface->GetBasebandVersion(SLOTID_2, RilTestUtil::GetSerialId());
259     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
260     EXPECT_EQ(SUCCESS, ret);
261     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_BASEBAND_VERSION));
262 }
263 
264 /**
265  * @tc.number   Telephony_DriverSystem_GetVoiceRadioTechnology_V1_0100
266  * @tc.name     Get voice radio technology
267  * @tc.desc     Function test
268  */
269 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetVoiceRadioTechnology_V1_0100, Function | MediumTest | Level3)
270 {
271     if (!RilTestUtil::IsReady(SLOTID_1)) {
272         return;
273     }
274     int32_t ret = g_rilInterface->GetVoiceRadioTechnology(SLOTID_1, RilTestUtil::GetSerialId());
275     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
276     EXPECT_EQ(SUCCESS, ret);
277     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_VOICE_RADIO));
278 }
279 
280 /**
281  * @tc.number   Telephony_DriverSystem_GetVoiceRadioTechnology_V1_0200
282  * @tc.name     Get voice radio technology
283  * @tc.desc     Function test
284  */
285 HWTEST_F(RILModemTest, Telephony_DriverSystem_GetVoiceRadioTechnology_V1_0200, Function | MediumTest | Level3)
286 {
287     if (!RilTestUtil::IsReady(SLOTID_2)) {
288         return;
289     }
290     int32_t ret = g_rilInterface->GetVoiceRadioTechnology(SLOTID_2, RilTestUtil::GetSerialId());
291     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
292     EXPECT_EQ(SUCCESS, ret);
293     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_MODEM_GET_VOICE_RADIO));
294 }
295 } // namespace Telephony
296 } // namespace OHOS
297