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