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