1 /* 2 * Copyright (C) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 #include "cJSON.h" 18 #include "cs_call.h" 19 #include "ims_call.h" 20 #include "call_object_manager.h" 21 #include "distributed_data_controller.h" 22 #include "distributed_data_sink_controller.h" 23 #include "distributed_data_source_controller.h" 24 #include "transmission_manager.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 using namespace testing::ext; 29 30 class DataSessionCallbackTest : public ISessionCallback { 31 public: OnConnected()32 void OnConnected() override {} OnReceiveMsg(const char * data,uint32_t dataLen)33 void OnReceiveMsg(const char* data, uint32_t dataLen) override {} 34 }; 35 36 class DistributedDataTest : public testing::Test { 37 public: SetUpTestCase()38 static void SetUpTestCase() {} TearDownTestCase()39 static void TearDownTestCase() {} SetUp()40 virtual void SetUp() {} TearDown()41 virtual void TearDown() {} 42 }; 43 44 /** 45 * @tc.number Telephony_DistributedDataTest_001 46 * @tc.name test data sink controller destroyed call 47 * @tc.desc Function test 48 */ 49 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_001, Function | MediumTest | Level1) 50 { 51 auto controller = std::make_shared<DistributedDataSinkController>(); 52 sptr<CallBase> call = nullptr; 53 std::string devId = ""; 54 controller->OnCallCreated(call, devId); 55 controller->ProcessCallInfo(call, DistributedDataType::NAME); 56 CallObjectManager::callObjectPtrList_.emplace_back(nullptr); 57 controller->OnCallDestroyed(); 58 controller->OnConnected(); 59 CallObjectManager::callObjectPtrList_.clear(); 60 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 61 controller->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 62 controller->OnCallDestroyed(); 63 EXPECT_TRUE(controller->queryInfo_.empty()); 64 } 65 66 /** 67 * @tc.number Telephony_DistributedDataTest_002 68 * @tc.name test data sink controller handle recv msg 69 * @tc.desc Function test 70 */ 71 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_002, Function | MediumTest | Level1) 72 { 73 auto controller = std::make_shared<DistributedDataSinkController>(); 74 ASSERT_NO_THROW(controller->HandleRecvMsg(0, nullptr)); 75 std::string json = "{ \"dataType\": 101 }"; 76 cJSON *msg = cJSON_Parse(json.c_str()); 77 ASSERT_NO_THROW(controller->HandleRecvMsg(101, msg)); 78 ASSERT_NO_THROW(controller->HandleRecvMsg(106, msg)); 79 ASSERT_NO_THROW(controller->HandleRecvMsg(0, msg)); 80 cJSON_Delete(msg); 81 } 82 83 /** 84 * @tc.number Telephony_DistributedDataTest_003 85 * @tc.name test data sink controller connect remote 86 * @tc.desc Function test 87 */ 88 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_003, Function | MediumTest | Level1) 89 { 90 auto controller = std::make_shared<DistributedDataSinkController>(); 91 std::string devId = ""; 92 ASSERT_NO_THROW(controller->ConnectRemote(devId)); 93 ASSERT_NO_THROW(controller->ConnectRemote(devId)); // check session is not null 94 } 95 96 /** 97 * @tc.number Telephony_DistributedDataTest_004 98 * @tc.name test data sink controller check local data 99 * @tc.desc Function test 100 */ 101 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_004, Function | MediumTest | Level1) 102 { 103 auto controller = std::make_shared<DistributedDataSinkController>(); 104 sptr<CallBase> call = nullptr; 105 ASSERT_NO_THROW(controller->CheckLocalData(call, DistributedDataType::NAME)); 106 DialParaInfo paraInfo; 107 call = (std::make_unique<IMSCall>(paraInfo)).release(); 108 call->accountNumber_ = ""; 109 ASSERT_NO_THROW(controller->CheckLocalData(call, DistributedDataType::NAME)); 110 call->accountNumber_ = "13512345678"; 111 call->numberLocation_ = "default"; 112 call->contactInfo_.name = ""; 113 ASSERT_NO_THROW(controller->CheckLocalData(call, DistributedDataType::NAME)); 114 ASSERT_NO_THROW(controller->CheckLocalData(call, DistributedDataType::LOCATION)); 115 } 116 117 /** 118 * @tc.number Telephony_DistributedDataTest_005 119 * @tc.name test data sink controller send query req 120 * @tc.desc Function test 121 */ 122 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_005, Function | MediumTest | Level1) 123 { 124 auto controller = std::make_shared<DistributedDataSinkController>(); 125 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 126 controller->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 127 ASSERT_NO_THROW(controller->SendDataQueryReq()); 128 controller->session_->socket_ = 0; 129 controller->queryInfo_["13512345678"] = 2; 130 ASSERT_NO_THROW(controller->SendDataQueryReq()); 131 EXPECT_EQ(controller->queryInfo_["13512345678"], 0); 132 } 133 134 /** 135 * @tc.number Telephony_DistributedDataTest_006 136 * @tc.name test data sink controller handle data query response 137 * @tc.desc Function test 138 */ 139 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_006, Function | MediumTest | Level1) 140 { 141 auto controller = std::make_shared<DistributedDataSinkController>(); 142 cJSON *msg = cJSON_Parse("{ \"dataType\": 101 }"); 143 ASSERT_NO_THROW(controller->HandleDataQueryRsp(msg)); 144 cJSON_Delete(msg); 145 146 msg = cJSON_Parse("{ \"itemType\": 0 }"); 147 ASSERT_NO_THROW(controller->HandleDataQueryRsp(msg)); 148 cJSON_Delete(msg); 149 150 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\" }"); 151 ASSERT_NO_THROW(controller->HandleDataQueryRsp(msg)); 152 DialParaInfo paraInfo; 153 sptr<CallBase> call = (std::make_unique<IMSCall>(paraInfo)).release(); 154 call->accountNumber_ = "123456"; 155 CallObjectManager::callObjectPtrList_.emplace_back(call); 156 ASSERT_NO_THROW(controller->HandleDataQueryRsp(msg)); 157 cJSON_Delete(msg); 158 159 msg = cJSON_Parse("{ \"itemType\": 1, \"num\": \"123456\" }"); 160 ASSERT_NO_THROW(controller->HandleDataQueryRsp(msg)); 161 cJSON_Delete(msg); 162 CallObjectManager::callObjectPtrList_.clear(); 163 } 164 165 /** 166 * @tc.number Telephony_DistributedDataTest_007 167 * @tc.name test data sink controller update call info 168 * @tc.desc Function test 169 */ 170 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_007, Function | MediumTest | Level1) 171 { 172 DialParaInfo paraInfo; 173 sptr<CallBase> call = (std::make_unique<IMSCall>(paraInfo)).release(); 174 call->accountNumber_ = "123456"; 175 176 auto controller = std::make_shared<DistributedDataSinkController>(); 177 cJSON *msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\" }"); 178 ASSERT_NO_THROW(controller->UpdateCallName(call, msg)); 179 cJSON_Delete(msg); 180 181 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\", \"name\": \"\" }"); 182 ASSERT_NO_THROW(controller->UpdateCallName(call, msg)); 183 cJSON_Delete(msg); 184 185 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\", \"name\": \"test\" }"); 186 ASSERT_NO_THROW(controller->UpdateCallName(call, msg)); 187 cJSON_Delete(msg); 188 189 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\" }"); 190 ASSERT_NO_THROW(controller->UpdateCallLocation(call, msg)); 191 cJSON_Delete(msg); 192 193 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\", \"location\": \"test\" }"); 194 ASSERT_NO_THROW(controller->UpdateCallLocation(call, msg)); 195 cJSON_Delete(msg); 196 } 197 198 /** 199 * @tc.number Telephony_DistributedDataTest_008 200 * @tc.name test data sink controller send current data query req 201 * @tc.desc Function test 202 */ 203 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_008, Function | MediumTest | Level1) 204 { 205 DialParaInfo paraInfo; 206 sptr<CallBase> call1 = (std::make_unique<IMSCall>(paraInfo)).release(); 207 call1->callType_ = CallType::TYPE_OTT; 208 sptr<CallBase> call2 = (std::make_unique<IMSCall>(paraInfo)).release(); 209 call2->callType_ = CallType::TYPE_IMS; 210 CallObjectManager::callObjectPtrList_.emplace_back(nullptr); 211 CallObjectManager::callObjectPtrList_.emplace_back(call1); 212 CallObjectManager::callObjectPtrList_.emplace_back(call2); 213 sptr<CallBase> call = new IMSCall(paraInfo); 214 call->callType_ = CallType::TYPE_IMS; 215 CallObjectManager::callObjectPtrList_.push_back(call); 216 auto controller = std::make_shared<DistributedDataSinkController>(); 217 ASSERT_NO_THROW(controller->SendCurrentDataQueryReq()); 218 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 219 controller->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 220 ASSERT_NO_THROW(controller->SendCurrentDataQueryReq()); 221 CallObjectManager::callObjectPtrList_.clear(); 222 } 223 224 /** 225 * @tc.number Telephony_DistributedDataTest_009 226 * @tc.name test data sink controller handle current data response 227 * @tc.desc Function test 228 */ 229 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_009, Function | MediumTest | Level1) 230 { 231 auto controller = std::make_shared<DistributedDataSinkController>(); 232 ASSERT_NO_THROW(controller->HandleCurrentDataQueryRsp(nullptr)); 233 234 cJSON *msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\" }"); 235 ASSERT_NO_THROW(controller->HandleCurrentDataQueryRsp(msg)); 236 cJSON_Delete(msg); 237 238 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\", \"direction\": 3 }"); 239 ASSERT_NO_THROW(controller->HandleCurrentDataQueryRsp(msg)); 240 cJSON_Delete(msg); 241 242 DialParaInfo paraInfo; 243 sptr<CallBase> call = (std::make_unique<IMSCall>(paraInfo)).release(); 244 call->accountNumber_ = "123456"; 245 CallObjectManager::callObjectPtrList_.emplace_back(call); 246 247 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\", \"direction\": 0 }"); 248 ASSERT_NO_THROW(controller->HandleCurrentDataQueryRsp(msg)); 249 std::string num = "123"; 250 std::string reqMsg = controller->CreateCurrentDataReqMsg(num); 251 EXPECT_FALSE(reqMsg.empty()); 252 cJSON_Delete(msg); 253 } 254 255 /** 256 * @tc.number Telephony_DistributedDataTest_010 257 * @tc.name test normal function 258 * @tc.desc Function test 259 */ 260 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_010, Function | MediumTest | Level1) 261 { 262 std::string num = "number1"; 263 std::string data = "data"; 264 std::string numLocation = "location_one"; 265 DistributedDataType type = DistributedDataType::LOCATION; 266 std::string devId = "UnitTestDeviceId"; 267 std::string devName = "UnitTestDeviceName"; 268 std::string json = "{ \"dataType\": 101 }"; 269 cJSON *msg = cJSON_Parse(json.c_str()); 270 DialParaInfo mDialParaInfo; 271 sptr<CallBase> csCall = new CSCall(mDialParaInfo); 272 AudioDeviceType deviceType = AudioDeviceType::DEVICE_DISTRIBUTED_PHONE; 273 auto sourceController = std::make_shared<DistributedDataSourceController>(); 274 ASSERT_NO_THROW(sourceController->OnDeviceOnline(devId, devName, deviceType)); 275 ASSERT_NO_THROW(sourceController->OnDeviceOffline(devId, devName, deviceType)); 276 ASSERT_NO_THROW(sourceController->OnCallDestroyed()); 277 ASSERT_NO_THROW(sourceController->OnConnected()); 278 ASSERT_NO_THROW(sourceController->HandleRecvMsg(0, nullptr)); 279 ASSERT_NO_THROW(sourceController->HandleRecvMsg(static_cast<int32_t>(DistributedMsgType::DATA_REQ), msg)); 280 ASSERT_NO_THROW(sourceController->HandleRecvMsg(static_cast<int32_t>(DistributedMsgType::CURRENT_DATA_REQ), msg)); 281 ASSERT_NO_THROW(sourceController->HandleRecvMsg(static_cast<int32_t>(DistributedMsgType::MUTE), msg)); 282 ASSERT_NO_THROW(sourceController->SaveLocalData(num, type, data)); 283 ASSERT_NO_THROW(sourceController->SaveLocalData(num, type, data)); 284 cJSON_Delete(msg); 285 286 type = DistributedDataType::NAME; 287 ASSERT_NO_THROW(csCall->SetAccountNumber("")); 288 ASSERT_NO_THROW(sourceController->SaveLocalData(csCall, type)); // Account number empty 289 ASSERT_NO_THROW(csCall->SetAccountNumber(num)); 290 ASSERT_NO_THROW(sourceController->SaveLocalData(csCall, type)); 291 292 type = DistributedDataType::LOCATION; 293 ASSERT_NO_THROW(csCall->SetNumberLocation(numLocation)); 294 ASSERT_NO_THROW(sourceController->SaveLocalData(csCall, type)); 295 ASSERT_NO_THROW(sourceController->SendLocalDataRsp()); 296 ASSERT_NO_THROW(sourceController->OnDeviceOnline(devId, devName, deviceType)); 297 ASSERT_NO_THROW(sourceController->SendLocalDataRsp()); 298 std::string ret = sourceController->CreateDataRspMsg(DistributedMsgType::DATA_REQ, 1, num, devName, data); 299 ASSERT_FALSE(ret.empty()); 300 } 301 302 /** 303 * @tc.number Telephony_DistributedDataTest_011 304 * @tc.name test data msg 305 * @tc.desc Function test 306 */ 307 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_011, Function | MediumTest | Level1) 308 { 309 bool isMuted = true; 310 int32_t direction = 0; 311 std::string num = "number_1"; 312 cJSON *msg = cJSON_Parse("{ \"testKey\": 0 }"); 313 auto sourceController = std::make_shared<DistributedDataSourceController>(); 314 ASSERT_NO_THROW(sourceController->HandleDataQueryMsg(msg)); 315 cJSON_Delete(msg); 316 317 msg = cJSON_Parse("{ \"itemType\": 0 }"); 318 ASSERT_NO_THROW(sourceController->HandleCurrentDataQueryMsg(msg)); 319 ASSERT_NO_THROW(sourceController->HandleDataQueryMsg(msg)); 320 cJSON_Delete(msg); 321 322 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"123456\" }"); 323 ASSERT_NO_THROW(sourceController->HandleCurrentDataQueryMsg(msg)); 324 ASSERT_NO_THROW(sourceController->HandleDataQueryMsg(msg)); 325 ASSERT_NO_THROW(sourceController->HandleDataQueryMsg(msg)); 326 327 msg = cJSON_Parse("{ \"itemType\": 0, \"num\": \"\" }"); 328 ASSERT_NO_THROW(sourceController->HandleDataQueryMsg(msg)); 329 std::string rspMsg = sourceController->CreateCurrentDataRspMsg(num, isMuted, direction); 330 ASSERT_FALSE(rspMsg.empty()); 331 cJSON_Delete(msg); 332 } 333 334 /** 335 * @tc.number Telephony_DistributedDataTest_012 336 * @tc.name test data controller receive msg 337 * @tc.desc Function test 338 */ 339 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_012, Function | MediumTest | Level1) 340 { 341 auto controller = std::make_shared<DistributedDataSinkController>(); 342 ASSERT_NO_THROW(controller->OnReceiveMsg(nullptr, DISTRIBUTED_MAX_RECV_DATA_LEN + 1)); 343 std::string data = "test"; 344 ASSERT_NO_THROW(controller->OnReceiveMsg(data.c_str(), data.length())); 345 346 data = "{ \"itemType\": 0, \"num\": \"123456\" }"; 347 ASSERT_NO_THROW(controller->OnReceiveMsg(data.c_str(), data.length())); 348 349 data = "{ \"dataType\": 104, \"itemType\": 0, \"num\": \"123456\" }"; 350 ASSERT_NO_THROW(controller->OnReceiveMsg(data.c_str(), data.length())); 351 352 data = "{ \"dataType\": 102, \"itemType\": 0, \"num\": \"123456\" }"; 353 ASSERT_NO_THROW(controller->OnReceiveMsg(data.c_str(), data.length())); 354 355 data = "{ \"dataType\": 0, \"itemType\": 0, \"num\": \"123456\" }"; 356 ASSERT_NO_THROW(controller->OnReceiveMsg(data.c_str(), data.length())); 357 } 358 359 /** 360 * @tc.number Telephony_DistributedDataTest_013 361 * @tc.name test data controller mute 362 * @tc.desc Function test 363 */ 364 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_013, Function | MediumTest | Level1) 365 { 366 auto controller = std::make_shared<DistributedDataSinkController>(); 367 controller->session_ = nullptr; 368 ASSERT_NO_THROW(controller->SetMuted(true)); 369 ASSERT_NO_THROW(controller->MuteRinger()); 370 371 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 372 controller->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 373 ASSERT_NO_THROW(controller->SetMuted(true)); 374 ASSERT_NO_THROW(controller->MuteRinger()); 375 } 376 377 /** 378 * @tc.number Telephony_DistributedDataTest_014 379 * @tc.name test get json value 380 * @tc.desc Function test 381 */ 382 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_014, Function | MediumTest | Level1) 383 { 384 auto controller = std::make_shared<DistributedDataSinkController>(); 385 cJSON *msg = cJSON_Parse("{ \"test\": 0 }"); 386 std::string name = "test"; 387 std::string stringValue = ""; 388 int32_t intValue = 0; 389 cJSON *dataJson = cJSON_GetObjectItem(msg, name.c_str()); 390 EXPECT_TRUE(controller->GetInt32Value(msg, name, intValue)); 391 EXPECT_FALSE(controller->GetStringValue(msg, name, stringValue)); 392 cJSON_Delete(msg); 393 394 msg = cJSON_Parse("{ \"test\": \"hello\" }"); 395 EXPECT_FALSE(controller->GetInt32Value(msg, name, intValue)); 396 EXPECT_TRUE(controller->GetStringValue(msg, name, stringValue)); 397 bool boolValue = false; 398 EXPECT_FALSE(controller->GetBoolValue(msg, name, boolValue)); 399 cJSON_Delete(msg); 400 401 msg = cJSON_Parse("{ \"test\": true }"); 402 EXPECT_TRUE(controller->GetBoolValue(msg, name, boolValue)); 403 cJSON_Delete(msg); 404 } 405 406 /** 407 * @tc.number Telephony_DistributedDataTest_015 408 * @tc.name test handle mute 409 * @tc.desc Function test 410 */ 411 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_015, Function | MediumTest | Level1) 412 { 413 auto controller = std::make_shared<DistributedDataSinkController>(); 414 cJSON *msg = cJSON_Parse("{ \"test\": 0 }"); 415 ASSERT_NO_THROW(controller->HandleMuted(msg)); 416 cJSON_Delete(msg); 417 418 msg = cJSON_Parse("{ \"mute\": true }"); 419 ASSERT_NO_THROW(controller->HandleMuted(msg)); 420 cJSON_Delete(msg); 421 } 422 423 /** 424 * @tc.number Telephony_DistributedDataTest_016 425 * @tc.name test data msg 426 * @tc.desc Function test 427 */ 428 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_016, Function | MediumTest | Level1) 429 { 430 DialParaInfo mDialParaInfo; 431 sptr<CallBase> imsCall = nullptr; 432 ContactInfo info; 433 info.name = "name"; 434 auto sourceController = std::make_shared<DistributedDataSourceController>(); 435 ASSERT_NO_THROW(sourceController->SaveLocalData(imsCall, DistributedDataType::LOCATION)); 436 imsCall = new IMSCall(mDialParaInfo); 437 imsCall->SetCallerInfo(info); 438 imsCall->SetAccountNumber("number"); 439 ASSERT_NO_THROW(sourceController->SaveLocalData(imsCall, DistributedDataType::NAME)); 440 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 441 sourceController->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 442 sourceController->session_->socket_ = INVALID_SOCKET_ID + 1; // session is ready 443 ASSERT_NO_THROW(sourceController->SendLocalDataRsp()); // both localInfo_ and queryInfo_ empty 444 sourceController->queryInfo_["name_1"] = 1; 445 sourceController->queryInfo_["name_2"] = 2; 446 sourceController->queryInfo_["name_3"] = 2; // local info not contain queried number 447 std::map<uint32_t, std::string> localInfo; 448 sourceController->localInfo_["name_1"] = localInfo; 449 sourceController->localInfo_["name_2"] = localInfo; 450 ASSERT_NO_THROW(sourceController->SendLocalDataRsp()); // localInfo_["name"] is empty 451 localInfo[0] = "zero"; 452 localInfo[1] = "one"; 453 localInfo[2] = "two"; 454 sourceController->localInfo_["name_1"] = localInfo; 455 sourceController->localInfo_["name_2"] = localInfo; 456 ASSERT_NO_THROW(sourceController->SendLocalDataRsp()); // both localInfo_ and queryInfo_ not empty 457 sourceController->localInfo_.clear(); 458 sourceController->queryInfo_.clear(); 459 cJSON *msg = cJSON_Parse("{ \"num\": \"123\" }"); 460 imsCall->SetAccountNumber("123"); 461 CallObjectManager::callObjectPtrList_.push_back(imsCall); 462 ASSERT_NO_THROW(sourceController->HandleCurrentDataQueryMsg(msg)); 463 msg = cJSON_Parse("{ \"num\": \"2\" }"); 464 ASSERT_NO_THROW(sourceController->HandleCurrentDataQueryMsg(msg)); // not find distributed call 465 CallObjectManager::callObjectPtrList_.clear(); 466 cJSON_Delete(msg); 467 } 468 469 /** 470 * @tc.number Telephony_DistributedDataTest_017 471 * @tc.name test data msg 472 * @tc.desc Function test 473 */ 474 HWTEST_F(DistributedDataTest, Telephony_DistributedDataTest_017, Function | MediumTest | Level1) 475 { 476 DialParaInfo mDialParaInfo; 477 AudioDeviceType deviceType = AudioDeviceType::DEVICE_DISTRIBUTED_PHONE; 478 std::string devId = "UnitTestDeviceId"; 479 std::string devName = "UnitTestDeviceName"; 480 sptr<CallBase> imsCall = new IMSCall(mDialParaInfo); 481 imsCall->callType_ = CallType::TYPE_IMS; 482 auto sourceController = std::make_shared<DistributedDataSourceController>(); 483 std::shared_ptr<ISessionCallback> callback = std::make_shared<DataSessionCallbackTest>(); 484 sourceController->session_ = DelayedSingleton<TransmissionManager>::GetInstance()->CreateServerSession(callback); 485 ASSERT_NO_THROW(sourceController->OnDeviceOnline(devId, devName, deviceType)); 486 sourceController->session_ = nullptr; 487 CallObjectManager::callObjectPtrList_.emplace_back(nullptr); 488 CallObjectManager::callObjectPtrList_.emplace_back(imsCall); 489 ASSERT_NO_THROW(sourceController->OnDeviceOnline(devId, devName, deviceType)); 490 ASSERT_NO_THROW(sourceController->OnCallCreated(imsCall, devId)); 491 CallObjectManager::callObjectPtrList_.clear(); 492 ASSERT_NO_THROW(sourceController->OnCallDestroyed()); 493 ASSERT_NO_THROW(sourceController->ProcessCallInfo(imsCall, DistributedDataType::NAME)); 494 } 495 496 } // namespace Telephony 497 } // namespace OHOS 498