• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-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 "core_service_client.h"
17 #include "gtest/gtest.h"
18 #include "i_sms_service_interface.h"
19 #include "if_system_ability_manager.h"
20 #include "iservice_registry.h"
21 #include "radio_event.h"
22 #include "sms_broadcast_subscriber_gtest.h"
23 #include "sms_mms_gtest.h"
24 #include "sms_mms_test_helper.h"
25 #include "sms_service.h"
26 #include "sms_service_manager_client.h"
27 #include "telephony_log_wrapper.h"
28 #include "telephony_types.h"
29 
30 namespace OHOS {
31 namespace Telephony {
32 namespace {
33 sptr<ISmsServiceInterface> g_telephonyService = nullptr;
34 } // namespace
35 using namespace testing::ext;
36 
37 class CbGtest : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp();
42     void TearDown();
43     static sptr<ISmsServiceInterface> GetProxy();
HasSimCard(int32_t slotId)44     static bool HasSimCard(int32_t slotId)
45     {
46         bool hasSimCard = false;
47         if (CoreServiceClient::GetInstance().GetProxy() == nullptr) {
48             return hasSimCard;
49         }
50         CoreServiceClient::GetInstance().HasSimCard(slotId, hasSimCard);
51         return hasSimCard;
52     }
53 };
54 
55 constexpr uint32_t EVENT_RELEASE_DATA_SHARE_HELPER = 10000;
TearDownTestCase()56 void CbGtest::TearDownTestCase()
57 {
58     DelayedSingleton<SmsPersistHelper>::GetInstance()->RemoveEvent(EVENT_RELEASE_DATA_SHARE_HELPER);
59 }
60 
SetUp()61 void CbGtest::SetUp() {}
62 
TearDown()63 void CbGtest::TearDown() {}
64 
65 const int32_t DEFAULT_SIM_SLOT_ID_1 = 1;
66 const uint16_t MESSAGE_TYPE = 4;
67 const uint16_t CB_PDU_LEN = 100;
68 
SetUpTestCase()69 void CbGtest::SetUpTestCase()
70 {
71     TELEPHONY_LOGI("SetUpTestCase slotId%{public}d", DEFAULT_SIM_SLOT_ID_1);
72     g_telephonyService = GetProxy();
73     if (g_telephonyService == nullptr) {
74         return;
75     }
76     Singleton<SmsServiceManagerClient>::GetInstance().ResetSmsServiceProxy();
77     Singleton<SmsServiceManagerClient>::GetInstance().InitSmsServiceProxy();
78 }
79 
GetProxy()80 sptr<ISmsServiceInterface> CbGtest::GetProxy()
81 {
82     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
83     if (systemAbilityMgr == nullptr) {
84         return nullptr;
85     }
86     sptr<IRemoteObject> remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_SMS_MMS_SYS_ABILITY_ID);
87     if (remote) {
88         sptr<ISmsServiceInterface> smsService = iface_cast<ISmsServiceInterface>(remote);
89         return smsService;
90     }
91     return nullptr;
92 }
93 
94 #ifndef TEL_TEST_UNSUPPORT
OpenCellBroadcastTestFuc(SmsMmsTestHelper & helper)95 void OpenCellBroadcastTestFuc(SmsMmsTestHelper &helper)
96 {
97     AccessMmsToken token;
98     bool enable = true;
99     uint32_t fromMsgId = 0;
100     uint32_t toMsgId = 10;
101     uint8_t netType = 1;
102     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
103         helper.slotId, enable, fromMsgId, toMsgId, netType);
104     helper.SetIntResult(result);
105     helper.NotifyAll();
106 }
107 
108 /**
109  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0001
110  * @tc.name     Open cellBroadcast slotId is -1
111  * @tc.desc     Function test
112  */
113 HWTEST_F(CbGtest, OpenCellBroadcast_0001, TestSize.Level0)
114 {
115     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0001 -->");
116     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
117     SmsMmsTestHelper helper;
118     helper.slotId = DEFAULT_SIM_SLOT_ID_REMOVE;
119     if (!helper.Run(OpenCellBroadcastTestFuc, std::ref(helper))) {
120         TELEPHONY_LOGI("OpenCellBroadcastTestFuc out of time");
121         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc, std::ref(helper)));
122     }
123     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0001 -->finished");
124     EXPECT_NE(helper.GetIntResult(), 0);
125 }
126 
OpenCellBroadcastTestFuc2(SmsMmsTestHelper & helper)127 void OpenCellBroadcastTestFuc2(SmsMmsTestHelper &helper)
128 {
129     AccessMmsToken token;
130     bool enable = true;
131     uint32_t fromMsgId = 20;
132     uint32_t toMsgId = 10;
133     uint8_t netType = 1;
134     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
135         helper.slotId, enable, fromMsgId, toMsgId, netType);
136     helper.SetIntResult(result);
137     helper.NotifyAll();
138 }
139 
OpenCellBroadcastTestFuc3(SmsMmsTestHelper & helper)140 void OpenCellBroadcastTestFuc3(SmsMmsTestHelper &helper)
141 {
142     AccessMmsToken token;
143     bool enable = true;
144     uint32_t fromMsgId = 0;
145     uint32_t toMsgId = 10;
146     uint8_t netType = 3;
147     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
148         helper.slotId, enable, fromMsgId, toMsgId, netType);
149     helper.SetIntResult(result);
150     helper.NotifyAll();
151 }
152 
153 /**
154  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0003
155  * @tc.name     Open cellBroadcast netType is unknown.
156  * @tc.desc     Function test
157  */
158 HWTEST_F(CbGtest, OpenCellBroadcast_0003, TestSize.Level0)
159 {
160     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0003 -->");
161     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
162     SmsMmsTestHelper helper;
163     helper.slotId = DEFAULT_SIM_SLOT_ID;
164     if (!helper.Run(OpenCellBroadcastTestFuc3, std::ref(helper))) {
165         TELEPHONY_LOGI("OpenCellBroadcastTestFuc3 out of time");
166         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc3, std::ref(helper)));
167     }
168     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0003 -->finished");
169     EXPECT_NE(helper.GetIntResult(), 0);
170 }
171 
OpenCellBroadcastTestFuc4(SmsMmsTestHelper & helper)172 void OpenCellBroadcastTestFuc4(SmsMmsTestHelper &helper)
173 {
174     AccessMmsToken token;
175     bool enable = true;
176     uint32_t fromMsgId = 0;
177     uint32_t toMsgId = 10;
178     uint8_t netType = 1;
179     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
180         helper.slotId, enable, fromMsgId, toMsgId, netType);
181     helper.SetIntResult(result);
182     helper.NotifyAll();
183 }
184 
185 /**
186  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0004
187  * @tc.name     Open cellBroadcast parameter is valid.
188  * @tc.desc     Function test
189  */
190 HWTEST_F(CbGtest, OpenCellBroadcast_0004, TestSize.Level0)
191 {
192     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0004 -->");
193     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
194     SmsMmsTestHelper helper;
195     helper.slotId = DEFAULT_SIM_SLOT_ID;
196     if (!helper.Run(OpenCellBroadcastTestFuc4, std::ref(helper))) {
197         TELEPHONY_LOGI("OpenCellBroadcastTestFuc4 out of time");
198         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc4, std::ref(helper)));
199     }
200     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0004 -->finished");
201     ASSERT_GE(helper.GetIntResult(), 0);
202 }
203 
OpenCellBroadcastTestFuc5(SmsMmsTestHelper & helper)204 void OpenCellBroadcastTestFuc5(SmsMmsTestHelper &helper)
205 {
206     AccessMmsToken token;
207     bool enable = true;
208     uint32_t fromMsgId = 0;
209     uint32_t toMsgId = 1000;
210     uint8_t netType = 1;
211     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
212         helper.slotId, enable, fromMsgId, toMsgId, netType);
213     helper.SetIntResult(result);
214     helper.NotifyAll();
215 }
216 
217 /**
218  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0005
219  * @tc.name     Open cellBroadcast parameter is valid
220  * @tc.desc     Function test
221  */
222 HWTEST_F(CbGtest, OpenCellBroadcast_0005, TestSize.Level0)
223 {
224     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0005 -->");
225     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
226     SmsMmsTestHelper helper;
227     helper.slotId = DEFAULT_SIM_SLOT_ID;
228     if (!helper.Run(OpenCellBroadcastTestFuc5, std::ref(helper))) {
229         TELEPHONY_LOGI("OpenCellBroadcastTestFuc5 out of time");
230         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc5, std::ref(helper)));
231     }
232     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0005 -->finished");
233     ASSERT_GE(helper.GetIntResult(), 0);
234 }
235 
OpenCellBroadcastTestFuc6(SmsMmsTestHelper & helper)236 void OpenCellBroadcastTestFuc6(SmsMmsTestHelper &helper)
237 {
238     bool enable = true;
239     uint32_t fromMsgId = 0;
240     uint32_t toMsgId = 0;
241     uint8_t netType = 1;
242     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
243         helper.slotId, enable, fromMsgId, toMsgId, netType);
244     helper.SetIntResult(result);
245     helper.NotifyAll();
246 }
247 
OpenCellBroadcastTestFuc6WithToken(SmsMmsTestHelper & helper)248 void OpenCellBroadcastTestFuc6WithToken(SmsMmsTestHelper &helper)
249 {
250     AccessMmsToken token;
251     OpenCellBroadcastTestFuc6(helper);
252 }
253 
254 /**
255  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0006
256  * @tc.name     Open cellBroadcast parameter is valid
257  * @tc.desc     Function test
258  */
259 HWTEST_F(CbGtest, OpenCellBroadcast_0006, TestSize.Level0)
260 {
261     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0006 -->");
262     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
263     SmsMmsTestHelper helper;
264     helper.slotId = DEFAULT_SIM_SLOT_ID;
265     if (!helper.Run(OpenCellBroadcastTestFuc6WithToken, std::ref(helper))) {
266         TELEPHONY_LOGI("OpenCellBroadcastTestFuc6WithToken out of time");
267         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc6WithToken, std::ref(helper)));
268     }
269     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0006 -->finished");
270     ASSERT_GE(helper.GetIntResult(), 0);
271 }
272 
273 /**
274  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0007
275  * @tc.name     Open cellBroadcast fromMsgId less than toMsgId
276  * @tc.desc     Function test
277  */
278 HWTEST_F(CbGtest, OpenCellBroadcast_0007, TestSize.Level0)
279 {
280     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0007 -->");
281     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
282         TELEPHONY_LOGI("no sim card");
283         return;
284     }
285     SmsMmsTestHelper helper;
286     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
287     if (!helper.Run(OpenCellBroadcastTestFuc2, std::ref(helper))) {
288         TELEPHONY_LOGI("OpenCellBroadcastTestFuc2 out of time");
289         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc2, std::ref(helper)));
290     }
291     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0007 -->finished");
292     EXPECT_NE(helper.GetIntResult(), 0);
293 }
294 
295 /**
296  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0008
297  * @tc.name     Open cellBroadcast netType is unknown.
298  * @tc.desc     Function test
299  */
300 HWTEST_F(CbGtest, OpenCellBroadcast_0008, TestSize.Level0)
301 {
302     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0008 -->");
303     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
304         TELEPHONY_LOGI("no sim card");
305         return;
306     }
307     SmsMmsTestHelper helper;
308     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
309     if (!helper.Run(OpenCellBroadcastTestFuc3, std::ref(helper))) {
310         TELEPHONY_LOGI("OpenCellBroadcastTestFuc3 out of time");
311         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc3, std::ref(helper)));
312     }
313     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0008 -->finished");
314     EXPECT_NE(helper.GetIntResult(), 0);
315 }
316 
317 /**
318  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0009
319  * @tc.name     Open cellBroadcast parameter is valid.
320  * @tc.desc     Function test
321  */
322 HWTEST_F(CbGtest, OpenCellBroadcast_0009, TestSize.Level0)
323 {
324     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0009 -->");
325     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
326         TELEPHONY_LOGI("no sim card");
327         return;
328     }
329     SmsMmsTestHelper helper;
330     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
331     if (!helper.Run(OpenCellBroadcastTestFuc4, std::ref(helper))) {
332         TELEPHONY_LOGI("OpenCellBroadcastTestFuc4 out of time");
333         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc4, std::ref(helper)));
334     }
335     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0009 -->finished");
336     ASSERT_GE(helper.GetIntResult(), 0);
337 }
338 
339 /**
340  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0010
341  * @tc.name     Open cellBroadcast parameter is valid
342  * @tc.desc     Function test
343  */
344 HWTEST_F(CbGtest, OpenCellBroadcast_00010, TestSize.Level1)
345 {
346     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0010 -->");
347     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
348         TELEPHONY_LOGI("no sim card");
349         return;
350     }
351     SmsMmsTestHelper helper;
352     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
353     if (!helper.Run(OpenCellBroadcastTestFuc5, std::ref(helper))) {
354         TELEPHONY_LOGI("OpenCellBroadcastTestFuc5 out of time");
355         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc5, std::ref(helper)));
356     }
357     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0010 -->finished");
358     ASSERT_GE(helper.GetIntResult(), 0);
359 }
360 
361 /**
362  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0011
363  * @tc.name     Open cellBroadcast parameter is valid
364  * @tc.desc     Function test
365  */
366 HWTEST_F(CbGtest, OpenCellBroadcast_0011, TestSize.Level0)
367 {
368     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0011 -->");
369     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
370         TELEPHONY_LOGI("no sim card");
371         return;
372     }
373     SmsMmsTestHelper helper;
374     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
375     if (!helper.Run(OpenCellBroadcastTestFuc6WithToken, std::ref(helper))) {
376         TELEPHONY_LOGI("OpenCellBroadcastTestFuc6WithToken out of time");
377         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc6WithToken, std::ref(helper)));
378     }
379     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0011 -->finished");
380     ASSERT_GE(helper.GetIntResult(), 0);
381 }
382 
383 /**
384  * @tc.number   Telephony_SmsMmsGtest_OpenCellBroadcast_0012
385  * @tc.name     Open cellBroadcast parameter is valid
386  * @tc.desc     Function test
387  */
388 HWTEST_F(CbGtest, OpenCellBroadcast_0012, TestSize.Level0)
389 {
390     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0012 -->");
391     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
392     SmsMmsTestHelper helper;
393     helper.slotId = DEFAULT_SIM_SLOT_ID;
394     if (!helper.Run(OpenCellBroadcastTestFuc6, std::ref(helper))) {
395         TELEPHONY_LOGI("OpenCellBroadcastTestFuc6 out of time");
396         ASSERT_TRUE(helper.Run(OpenCellBroadcastTestFuc6, std::ref(helper)));
397     }
398     TELEPHONY_LOGI("TelSMSMMSTest::OpenCellBroadcast_0012 -->finished");
399     EXPECT_NE(helper.GetIntResult(), 0);
400 }
401 
CloseCellBroadcastTestFuc(SmsMmsTestHelper & helper)402 void CloseCellBroadcastTestFuc(SmsMmsTestHelper &helper)
403 {
404     AccessMmsToken token;
405     bool enable = false;
406     uint32_t fromMsgId = 0;
407     uint32_t toMsgId = 10;
408     uint8_t netType = 1;
409     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
410         helper.slotId, enable, fromMsgId, toMsgId, netType);
411     helper.SetIntResult(result);
412     helper.NotifyAll();
413 }
414 
415 /**
416  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0001
417  * @tc.name     Close cellBroadcast slotId is -1
418  * @tc.desc     Function test
419  */
420 HWTEST_F(CbGtest, CloseCellBroadcast_0001, TestSize.Level0)
421 {
422     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0001 -->");
423     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
424     SmsMmsTestHelper helper;
425     helper.slotId = DEFAULT_SIM_SLOT_ID_REMOVE;
426     if (!helper.Run(CloseCellBroadcastTestFuc, std::ref(helper))) {
427         TELEPHONY_LOGI("CloseCellBroadcastTestFuc out of time");
428         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc, std::ref(helper)));
429     }
430     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0001 -->finished");
431     EXPECT_NE(helper.GetIntResult(), 0);
432 }
433 
CloseCellBroadcastTestFuc2(SmsMmsTestHelper & helper)434 void CloseCellBroadcastTestFuc2(SmsMmsTestHelper &helper)
435 {
436     AccessMmsToken token;
437     bool enable = false;
438     uint32_t fromMsgId = 20;
439     uint32_t toMsgId = 10;
440     uint8_t netType = 1;
441     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
442         helper.slotId, enable, fromMsgId, toMsgId, netType);
443     helper.SetIntResult(result);
444     helper.NotifyAll();
445 }
446 
447 /**
448  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0002
449  * @tc.name     Close cellBroadcast fromMsgId less than toMsgId
450  * @tc.desc     Function test
451  */
452 HWTEST_F(CbGtest, CloseCellBroadcast_0002, TestSize.Level0)
453 {
454     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0002 -->");
455     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
456     SmsMmsTestHelper helper;
457     helper.slotId = DEFAULT_SIM_SLOT_ID;
458     if (!helper.Run(CloseCellBroadcastTestFuc2, std::ref(helper))) {
459         TELEPHONY_LOGI("CloseCellBroadcastTestFuc2 out of time");
460         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc2, std::ref(helper)));
461     }
462     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0002 -->finished");
463     EXPECT_NE(helper.GetIntResult(), 0);
464 }
465 
CloseCellBroadcastTestFuc3(SmsMmsTestHelper & helper)466 void CloseCellBroadcastTestFuc3(SmsMmsTestHelper &helper)
467 {
468     AccessMmsToken token;
469     bool enable = false;
470     uint32_t fromMsgId = 0;
471     uint32_t toMsgId = 10;
472     uint8_t netType = 3;
473     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
474         helper.slotId, enable, fromMsgId, toMsgId, netType);
475     helper.SetIntResult(result);
476     helper.NotifyAll();
477 }
478 
479 /**
480  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0003
481  * @tc.name     Close cellBroadcast netType is unknown
482  * @tc.desc     Function test
483  */
484 HWTEST_F(CbGtest, CloseCellBroadcast_0003, TestSize.Level0)
485 {
486     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0003 -->");
487     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
488     SmsMmsTestHelper helper;
489     helper.slotId = DEFAULT_SIM_SLOT_ID;
490     if (!helper.Run(CloseCellBroadcastTestFuc3, std::ref(helper))) {
491         TELEPHONY_LOGI("CloseCellBroadcastTestFuc3 out of time");
492         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc3, std::ref(helper)));
493     }
494     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0003-->finished");
495     EXPECT_NE(helper.GetIntResult(), 0);
496 }
497 
CloseCellBroadcastTestFuc4(SmsMmsTestHelper & helper)498 void CloseCellBroadcastTestFuc4(SmsMmsTestHelper &helper)
499 {
500     AccessMmsToken token;
501     bool enable = false;
502     uint32_t fromMsgId = 0;
503     uint32_t toMsgId = 10;
504     uint8_t netType = 1;
505     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
506         helper.slotId, enable, fromMsgId, toMsgId, netType);
507     helper.SetIntResult(result);
508     helper.NotifyAll();
509 }
510 
511 /**
512  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0004
513  * @tc.name     Close cellBroadcast parameter is valid
514  * @tc.desc     Function test
515  */
516 HWTEST_F(CbGtest, CloseCellBroadcast_0004, TestSize.Level0)
517 {
518     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0004 -->");
519     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
520     SmsMmsTestHelper helper;
521     helper.slotId = DEFAULT_SIM_SLOT_ID;
522     if (!helper.Run(CloseCellBroadcastTestFuc4, std::ref(helper))) {
523         TELEPHONY_LOGI("CloseCellBroadcastTestFuc4 out of time");
524         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc4, std::ref(helper)));
525     }
526     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0004 -->finished");
527     ASSERT_GE(helper.GetIntResult(), 0);
528 }
529 
CloseCellBroadcastTestFuc5(SmsMmsTestHelper & helper)530 void CloseCellBroadcastTestFuc5(SmsMmsTestHelper &helper)
531 {
532     AccessMmsToken token;
533     bool enable = false;
534     uint32_t fromMsgId = 0;
535     uint32_t toMsgId = 1000;
536     uint8_t netType = 1;
537     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
538         helper.slotId, enable, fromMsgId, toMsgId, netType);
539     helper.SetIntResult(result);
540     helper.NotifyAll();
541 }
542 
543 /**
544  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0005
545  * @tc.name     Close cellBroadcast parameter is valid
546  * @tc.desc     Function test
547  */
548 HWTEST_F(CbGtest, CloseCellBroadcast_0005, TestSize.Level0)
549 {
550     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0005 -->");
551     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
552     SmsMmsTestHelper helper;
553     helper.slotId = DEFAULT_SIM_SLOT_ID;
554     if (!helper.Run(CloseCellBroadcastTestFuc5, std::ref(helper))) {
555         TELEPHONY_LOGI("CloseCellBroadcastTestFuc5 out of time");
556         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc5, std::ref(helper)));
557     }
558     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0005 -->finished");
559     ASSERT_GE(helper.GetIntResult(), 0);
560 }
561 
CloseCellBroadcastTestFuc6(SmsMmsTestHelper & helper)562 void CloseCellBroadcastTestFuc6(SmsMmsTestHelper &helper)
563 {
564     bool enable = false;
565     uint32_t fromMsgId = 0;
566     uint32_t toMsgId = 0;
567     uint8_t netType = 1;
568     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfig(
569         helper.slotId, enable, fromMsgId, toMsgId, netType);
570     helper.SetIntResult(result);
571     helper.NotifyAll();
572 }
573 
CloseCellBroadcastTestFuc6WithToken(SmsMmsTestHelper & helper)574 void CloseCellBroadcastTestFuc6WithToken(SmsMmsTestHelper &helper)
575 {
576     AccessMmsToken token;
577     CloseCellBroadcastTestFuc6(helper);
578 }
579 
580 /**
581  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0006
582  * @tc.name     Close cellBroadcast parameter is valid
583  * @tc.desc     Function test
584  */
585 HWTEST_F(CbGtest, CloseCellBroadcast_0006, TestSize.Level0)
586 {
587     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0006 -->");
588     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
589     SmsMmsTestHelper helper;
590     helper.slotId = DEFAULT_SIM_SLOT_ID;
591     if (!helper.Run(CloseCellBroadcastTestFuc6WithToken, std::ref(helper))) {
592         TELEPHONY_LOGI("CloseCellBroadcastTestFuc6WithToken out of time");
593         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc6WithToken, std::ref(helper)));
594     }
595     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0006 -->finished");
596     ASSERT_GE(helper.GetIntResult(), 0);
597 }
598 
599 /**
600  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0007
601  * @tc.name     Close cellBroadcast fromMsgId less than toMsgId
602  * @tc.desc     Function test
603  */
604 HWTEST_F(CbGtest, CloseCellBroadcast_0007, TestSize.Level0)
605 {
606     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0007 -->");
607     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
608         return;
609     }
610     SmsMmsTestHelper helper;
611     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
612     if (!helper.Run(CloseCellBroadcastTestFuc2, std::ref(helper))) {
613         TELEPHONY_LOGI("CloseCellBroadcastTestFuc7 out of time");
614         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc2, std::ref(helper)));
615     }
616     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0007 -->finished");
617     EXPECT_NE(helper.GetIntResult(), 0);
618 }
619 
620 /**
621  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0008
622  * @tc.name     Close cellBroadcast netType is unknown
623  * @tc.desc     Function test
624  */
625 HWTEST_F(CbGtest, CloseCellBroadcast_0008, TestSize.Level0)
626 {
627     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0008 -->");
628     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
629         return;
630     }
631     SmsMmsTestHelper helper;
632     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
633     if (!helper.Run(CloseCellBroadcastTestFuc3, std::ref(helper))) {
634         TELEPHONY_LOGI("CloseCellBroadcastTestFuc8 out of time");
635         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc3, std::ref(helper)));
636     }
637     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0008-->finished");
638     EXPECT_NE(helper.GetIntResult(), 0);
639 }
640 
641 /**
642  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0009
643  * @tc.name     Close cellBroadcast parameter is valid
644  * @tc.desc     Function test
645  */
646 HWTEST_F(CbGtest, CloseCellBroadcast_0009, TestSize.Level0)
647 {
648     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0009 -->");
649     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
650         return;
651     }
652     SmsMmsTestHelper helper;
653     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
654     if (!helper.Run(CloseCellBroadcastTestFuc4, std::ref(helper))) {
655         TELEPHONY_LOGI("CloseCellBroadcastTestFuc9 out of time");
656         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc4, std::ref(helper)));
657     }
658     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0009 -->finished");
659     ASSERT_GE(helper.GetIntResult(), 0);
660 }
661 
662 /**
663  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0010
664  * @tc.name     Close cellBroadcast parameter is valid
665  * @tc.desc     Function test
666  */
667 HWTEST_F(CbGtest, CloseCellBroadcast_0010, TestSize.Level0)
668 {
669     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0010 -->");
670     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
671         return;
672     }
673     SmsMmsTestHelper helper;
674     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
675     if (!helper.Run(CloseCellBroadcastTestFuc5, std::ref(helper))) {
676         TELEPHONY_LOGI("CloseCellBroadcastTestFuc10 out of time");
677         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc5, std::ref(helper)));
678     }
679     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0010 -->finished");
680     ASSERT_GE(helper.GetIntResult(), 0);
681 }
682 
683 /**
684  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0011
685  * @tc.name     Close cellBroadcast parameter is valid
686  * @tc.desc     Function test
687  */
688 HWTEST_F(CbGtest, CloseCellBroadcast_00011, TestSize.Level0)
689 {
690     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0011 -->");
691     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
692         return;
693     }
694     SmsMmsTestHelper helper;
695     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
696     if (!helper.Run(CloseCellBroadcastTestFuc6WithToken, std::ref(helper))) {
697         TELEPHONY_LOGI("CloseCellBroadcastTestFuc6WithToken out of time");
698         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc6WithToken, std::ref(helper)));
699     }
700     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0011 -->finished");
701     ASSERT_GE(helper.GetIntResult(), 0);
702 }
703 
704 /**
705  * @tc.number   Telephony_SmsMmsGtest_CloseCellBroadcast_0012
706  * @tc.name     Close cellBroadcast parameter is valid
707  * @tc.desc     Function test
708  */
709 HWTEST_F(CbGtest, CloseCellBroadcast_0012, TestSize.Level0)
710 {
711     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0012 -->");
712     if ((CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
713         return;
714     }
715     SmsMmsTestHelper helper;
716     helper.slotId = DEFAULT_SIM_SLOT_ID;
717     if (!helper.Run(CloseCellBroadcastTestFuc6, std::ref(helper))) {
718         TELEPHONY_LOGI("CloseCellBroadcastTestFuc6 out of time");
719         ASSERT_TRUE(helper.Run(CloseCellBroadcastTestFuc6, std::ref(helper)));
720     }
721     TELEPHONY_LOGI("TelSMSMMSTest::CloseCellBroadcast_0012 -->finished");
722     EXPECT_NE(helper.GetIntResult(), 0);
723 }
724 
ReceiveCellBroadCastTestFunc(SmsMmsTestHelper & helper)725 void ReceiveCellBroadCastTestFunc(SmsMmsTestHelper &helper)
726 {
727     AccessMmsToken token;
728     auto gsmSmsCbHandler = std::make_shared<GsmSmsCbHandler>(helper.slotId);
729     auto message = std::make_shared<CBConfigReportInfo>();
730     message->indicationType = MESSAGE_TYPE;
731     message->sn = 0;
732     message->mid = 0;
733     message->page = 0;
734     message->pages = 0;
735     message->dcs = "";
736     message->data = "";
737     message->length = CB_PDU_LEN;
738     message->pdu = "01a41f51101102ea3030a830ea30a230e130fc30eb914d4fe130c630b930c8000d000a3053308c306f8a669a137528306e3"
739                    "0e130c330bb30fc30b8306730593002000d000aff080032003000310033002f00310031002f003252ea3000370020003100"
740                    "35003a00340034ff09000d000aff0830a830ea30a25e02ff090000000000000000000000000000000000000000000000000"
741                    "0000000000000000000000000000000000000000000000022";
742     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_CELL_BROADCAST, message);
743     gsmSmsCbHandler->ProcessEvent(event);
744 }
745 
ReceiveCellBroadCastTestFunc2(SmsMmsTestHelper & helper)746 void ReceiveCellBroadCastTestFunc2(SmsMmsTestHelper &helper)
747 {
748     AccessMmsToken token;
749     auto gsmSmsCbHandler = std::make_shared<GsmSmsCbHandler>(helper.slotId);
750     auto message = std::make_shared<CBConfigReportInfo>();
751     message->indicationType = MESSAGE_TYPE;
752     message->sn = 0;
753     message->mid = 0;
754     message->page = 0;
755     message->pages = 0;
756     message->dcs = "";
757     message->data = "";
758     message->length = CB_PDU_LEN;
759     message->pdu = "C0000032401174747A0E4ACF41E8B0BCFD76E741EF39685C66B34162F93B4C1E87E77410BD3CA7836EC2341D440ED3C321";
760     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_CELL_BROADCAST, message);
761     gsmSmsCbHandler->ProcessEvent(event);
762 }
763 
764 /**
765  * @tc.number   Telephony_SmsMmsGtest_Receive_Cell_BroadCast_0001
766  * @tc.name     Receive a 3g Cell Broadcast
767  * @tc.desc     Function test
768  */
769 HWTEST_F(CbGtest, Receive_Cell_BroadCast_0001, Function | MediumTest | Level2)
770 {
771     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0001 -->");
772     int32_t slotId = DEFAULT_SIM_SLOT_ID;
773     ASSERT_TRUE(CbGtest::HasSimCard(slotId));
774     SmsMmsTestHelper helper;
775     helper.slotId = slotId;
776 
777     EventFwk::MatchingSkills matchingSkills;
778     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED);
779     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED);
780     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
781     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
782         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
783     ASSERT_NE(subscriberTest, nullptr);
784     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
785     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
786 
787     EXPECT_TRUE(!helper.Run(ReceiveCellBroadCastTestFunc, helper) || helper.GetBoolResult());
788     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0001 -->finished");
789 }
790 
791 /**
792  * @tc.number   Telephony_SmsMmsGtest_Receive_Cell_BroadCast_0002
793  * @tc.name     Receive a 2g Cell Broadcast
794  * @tc.desc     Function test
795  */
796 HWTEST_F(CbGtest, Receive_Cell_BroadCast_0002, Function | MediumTest | Level2)
797 {
798     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0002 -->");
799     int32_t slotId = DEFAULT_SIM_SLOT_ID;
800     ASSERT_TRUE(CbGtest::HasSimCard(slotId));
801     SmsMmsTestHelper helper;
802     helper.slotId = slotId;
803 
804     EventFwk::MatchingSkills matchingSkills;
805     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED);
806     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED);
807     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
808     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
809         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
810     ASSERT_NE(subscriberTest, nullptr);
811     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
812     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
813 
814     EXPECT_TRUE(!helper.Run(ReceiveCellBroadCastTestFunc2, helper) || helper.GetBoolResult());
815     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0002 -->finished");
816 }
817 
818 /**
819  * @tc.number   Telephony_SmsMmsGtest_Receive_Cell_BroadCast_0003
820  * @tc.name     Receive a 3g Cell Broadcast
821  * @tc.desc     Function test
822  */
823 HWTEST_F(CbGtest, Receive_Cell_BroadCast_0003, Function | MediumTest | Level2)
824 {
825     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0003 -->");
826     int32_t slotId = DEFAULT_SIM_SLOT_ID_1;
827     if (!(CbGtest::HasSimCard(slotId))) {
828         return;
829     }
830     SmsMmsTestHelper helper;
831     helper.slotId = slotId;
832 
833     EventFwk::MatchingSkills matchingSkills;
834     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED);
835     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED);
836     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
837     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
838         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
839     ASSERT_NE(subscriberTest, nullptr);
840     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
841     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
842 
843     EXPECT_TRUE(!helper.Run(ReceiveCellBroadCastTestFunc, helper) || helper.GetBoolResult());
844     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0003 -->finished");
845 }
846 
847 /**
848  * @tc.number   Telephony_SmsMmsGtest_Receive_Cell_BroadCast_0004
849  * @tc.name     Receive a 2g Cell Broadcast
850  * @tc.desc     Function test
851  */
852 HWTEST_F(CbGtest, Receive_Cell_BroadCast_0004, Function | MediumTest | Level2)
853 {
854     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0004 -->");
855     int32_t slotId = DEFAULT_SIM_SLOT_ID_1;
856     if (!(CbGtest::HasSimCard(slotId))) {
857         return;
858     }
859     SmsMmsTestHelper helper;
860     helper.slotId = slotId;
861 
862     EventFwk::MatchingSkills matchingSkills;
863     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED);
864     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED);
865     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
866     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
867         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
868     ASSERT_NE(subscriberTest, nullptr);
869     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
870     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
871 
872     EXPECT_TRUE(!helper.Run(ReceiveCellBroadCastTestFunc2, helper) || helper.GetBoolResult());
873 
874     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Cell_BroadCast_0004 -->finished");
875 }
876 
SetCBConfigListTestFunc1(SmsMmsTestHelper & helper)877 void SetCBConfigListTestFunc1(SmsMmsTestHelper &helper)
878 {
879     AccessMmsToken token;
880     std::vector<int32_t> messageIds = {4352, 4359, 4388, 4389};
881     int32_t ranType = 1;
882     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfigList(
883         helper.slotId, messageIds, ranType);
884     helper.SetIntResult(result);
885     helper.NotifyAll();
886 }
887 
888 /**
889  * @tc.number   Telephony_SmsMmsGtest_SetCBConfigList_0001
890  * @tc.name     SetCBConfigList slotId is -1
891  * @tc.desc     Function test
892  */
893 HWTEST_F(CbGtest, SetCBConfigList_0001, TestSize.Level0)
894 {
895     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0001 -->");
896     ASSERT_TRUE(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID));
897     SmsMmsTestHelper helper;
898     helper.slotId = DEFAULT_SIM_SLOT_ID_REMOVE;
899     if (!helper.Run(SetCBConfigListTestFunc1, std::ref(helper))) {
900         TELEPHONY_LOGI("SetCBConfigListTestFunc1 out of time");
901     }
902     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0001 -->finished");
903     EXPECT_NE(helper.GetIntResult(), 0);
904 }
905 
SetCBConfigListTestFunc2(SmsMmsTestHelper & helper)906 void SetCBConfigListTestFunc2(SmsMmsTestHelper &helper)
907 {
908     AccessMmsToken token;
909     std::vector<int32_t> messageIds = {4352, 4352, 4388, 4389};
910     int32_t ranType = 1;
911     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfigList(
912         helper.slotId, messageIds, ranType);
913     helper.SetIntResult(result);
914     helper.NotifyAll();
915 }
916 
917 /**
918  * @tc.number   Telephony_SmsMmsGtest_SetCBConfigList_0002
919  * @tc.name     SetCBConfigList fromMsgId and toMsgId are equal
920  * @tc.desc     Function test
921  */
922 HWTEST_F(CbGtest, SetCBConfigList_0002, TestSize.Level0)
923 {
924     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0002 -->");
925     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
926         return;
927     }
928     SmsMmsTestHelper helper;
929     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
930     if (!helper.Run(SetCBConfigListTestFunc2, std::ref(helper))) {
931         TELEPHONY_LOGI("SetCBConfigListTestFunc2 out of time");
932     }
933     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0002 -->finished");
934     EXPECT_NE(helper.GetIntResult(), 0);
935 }
936 
SetCBConfigListTestFunc3(SmsMmsTestHelper & helper)937 void SetCBConfigListTestFunc3(SmsMmsTestHelper &helper)
938 {
939     AccessMmsToken token;
940     std::vector<int32_t> messageIds = {4352, 4355, 4388, 4387};
941     int32_t ranType = 1;
942     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfigList(
943         helper.slotId, messageIds, ranType);
944     helper.SetIntResult(result);
945     helper.NotifyAll();
946 }
947 
948 /**
949  * @tc.number   Telephony_SmsMmsGtest_SetCBConfigList_0003
950  * @tc.name     SetCBConfigList fromMsgId less than toMsgId
951  * @tc.desc     Function test
952  */
953 HWTEST_F(CbGtest, SetCBConfigList_0003, TestSize.Level0)
954 {
955     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0003 -->");
956     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
957         return;
958     }
959     SmsMmsTestHelper helper;
960     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
961     if (!helper.Run(SetCBConfigListTestFunc3, std::ref(helper))) {
962         TELEPHONY_LOGI("SetCBConfigListTestFunc3 out of time");
963     }
964     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0003 -->finished");
965     EXPECT_NE(helper.GetIntResult(), 0);
966 }
967 
SetCBConfigListTestFunc4(SmsMmsTestHelper & helper)968 void SetCBConfigListTestFunc4(SmsMmsTestHelper &helper)
969 {
970     AccessMmsToken token;
971     std::vector<int32_t> messageIds = {4352, 4352, 4388, 4389};
972     int32_t ranType = 3;
973     int32_t result = Singleton<SmsServiceManagerClient>::GetInstance().SetCBConfigList(
974         helper.slotId, messageIds, ranType);
975     helper.SetIntResult(result);
976     helper.NotifyAll();
977 }
978 
979 /**
980  * @tc.number   Telephony_SmsMmsGtest_SetCBConfigList_0004
981  * @tc.name     SetCBConfigList netType is unknown.
982  * @tc.desc     Function test
983  */
984 HWTEST_F(CbGtest, SetCBConfigList_0004, TestSize.Level0)
985 {
986     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0004 -->");
987     if (!(CbGtest::HasSimCard(DEFAULT_SIM_SLOT_ID_1))) {
988         return;
989     }
990     SmsMmsTestHelper helper;
991     helper.slotId = DEFAULT_SIM_SLOT_ID_1;
992     if (!helper.Run(SetCBConfigListTestFunc4, std::ref(helper))) {
993         TELEPHONY_LOGI("SetCBConfigListTestFunc4 out of time");
994     }
995     TELEPHONY_LOGI("TelSMSMMSTest::SetCBConfigList_0004 -->finished");
996     EXPECT_NE(helper.GetIntResult(), 0);
997 }
998 #endif // TEL_TEST_UNSUPPORT
999 } // namespace Telephony
1000 } // namespace OHOS