diff --git a/common/test/unittest/common/utils/data_buffer_test.cpp b/common/test/unittest/common/utils/data_buffer_test.cpp index 9868c0b2c93f0d99a5a2da53745722d18bcbff56..4d2306667816041ad42d524892986ed84e646980 100644 --- a/common/test/unittest/common/utils/data_buffer_test.cpp +++ b/common/test/unittest/common/utils/data_buffer_test.cpp @@ -67,9 +67,7 @@ HWTEST_F(DataBufferTest, SetRange_001, TestSize.Level1) { size_t offset = 0; size_t size = 0; - if (dataBuffer_ == nullptr) { - return; - } + ASSERT_NE(dataBuffer_, nullptr); int32_t ret = dataBuffer_->SetRange(offset, size); EXPECT_EQ(DCAMERA_OK, ret); offset = dataBuffer_->Offset() + 2; @@ -88,9 +86,7 @@ HWTEST_F(DataBufferTest, FindInt32_001, TestSize.Level1) { string name = "test"; int32_t value = 1; - if (dataBuffer_ == nullptr) { - return; - } + ASSERT_NE(dataBuffer_, nullptr); dataBuffer_->SetInt32(name, value); bool ret = dataBuffer_->FindInt32(name, value); EXPECT_EQ(true, ret); @@ -109,9 +105,7 @@ HWTEST_F(DataBufferTest, FindInt62_001, TestSize.Level1) { string name = "test"; int64_t value = 1; - if (dataBuffer_ == nullptr) { - return; - } + ASSERT_NE(dataBuffer_, nullptr); dataBuffer_->SetInt64(name, value); bool ret = dataBuffer_->FindInt64(name, value); EXPECT_EQ(true, ret); @@ -130,9 +124,7 @@ HWTEST_F(DataBufferTest, FindString_001, TestSize.Level1) { string name = "test"; string value = "test"; - if (dataBuffer_ == nullptr) { - return; - } + ASSERT_NE(dataBuffer_, nullptr); dataBuffer_->SetString(name, value); bool ret = dataBuffer_->FindString(name, value); EXPECT_EQ(true, ret); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp index 4223d55105fb5f3c9b00f2b06b31646df8878817..2c3cb0486880107acf512574642c520c9d8e75f2 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp @@ -170,9 +170,7 @@ HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_005, TestSize.Level1) SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); sptr loadCallback(new DCameraSinkLoadCallback(params)); - if (loadCallback == nullptr) { - return; - } + ASSERT_NE(loadCallback, nullptr); loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); remoteObject = nullptr; @@ -194,9 +192,7 @@ HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_006, TestSize.Level1) std::string params = "test006"; int32_t systemAbilityId = 4804; sptr loadCallback(new DCameraSinkLoadCallback(params)); - if (loadCallback == nullptr) { - return; - } + ASSERT_NE(loadCallback, nullptr); loadCallback->OnLoadSystemAbilityFail(systemAbilityId); systemAbilityId = 1; @@ -263,9 +259,7 @@ HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_010, TestSize.Level1) SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); sptr loadCallback(new DCameraSinkLoadCallback(params)); - if (loadCallback == nullptr) { - return; - } + ASSERT_NE(loadCallback, nullptr); loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); remoteObject = nullptr; diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/callback/dcamera_source_callback_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/callback/dcamera_source_callback_test.cpp index b9b416287be492dbb22a9af30853bc1b81591114..63d45bcf8b756c172d2c4941bb750a3aee639063 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/callback/dcamera_source_callback_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/callback/dcamera_source_callback_test.cpp @@ -143,9 +143,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_002, TestSize.L std::string reqId = "reqId"; int32_t status = 0; std::string data = "data"; - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->OnNotifyRegResult(devId, dhId, reqId, status, data); EXPECT_EQ(DCAMERA_NOT_FOUND, ret); } @@ -183,9 +181,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_004, TestSize.L std::string reqId = "reqId"; int32_t status = 0; std::string data = "data"; - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->OnNotifyUnregResult(devId, dhId, reqId, status, data); EXPECT_EQ(DCAMERA_NOT_FOUND, ret); } @@ -202,9 +198,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_005, TestSize.L std::string dhId = "dhId"; std::string reqId = "reqId"; std::string result = "result"; - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->CheckParams(devId, dhId, reqId, result); EXPECT_EQ(false, ret); devId += std::string(DID_MAX_SIZE + 1, 'a'); @@ -252,9 +246,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_006, TestSize.L data.WriteString(devId); data.WriteString(dhId); data.WriteString(reqId); - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->OnRemoteRequest(code, data, reply, option); EXPECT_NE(DCAMERA_OK, ret); code = DCameraSourceCallback::NOTIFY_REG_RESULT; @@ -310,9 +302,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_008, TestSize.L data.WriteString(reqId); data.WriteInt32(status); data.WriteString(result); - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->NotifyUnregResultInner(data, reply); sourceCallback_->RegisterStateListener(nullptr); sourceCallback_->UnRegisterStateListener(); @@ -332,9 +322,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_009, TestSize.L std::string devId = "devId"; std::string dhId = "dhId"; int32_t status = 1; - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->OnHardwareStateChanged(devId, dhId, status); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); std::shared_ptr listener = @@ -372,9 +360,7 @@ HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_009, TestSize.L HWTEST_F(DCameraSourceCallbackTest, dcamera_source_callback_test_010, TestSize.Level1) { std::string devId = ""; - if (sourceCallback_ == nullptr) { - return; - } + ASSERT_NE(sourceCallback_, nullptr); int32_t ret = sourceCallback_->OnDataSyncTrigger(devId); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); devId += std::string(DID_MAX_SIZE + 1, 'a'); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp index 60ca4282d44759c0966d23c09ed15d3e45b4fa41..0a9588be36514e4d72e2ea5ae76771871786d8b9 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp @@ -156,9 +156,7 @@ HWTEST_F(DCameraSourceHandlerTest, dcamera_source_handler_test_005, TestSize.Lev SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); sptr loadCallback(new DCameraSourceLoadCallback(params)); - if (loadCallback == nullptr) { - return; - } + ASSERT_NE(loadCallback, nullptr); loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); remoteObject = nullptr; @@ -180,9 +178,7 @@ HWTEST_F(DCameraSourceHandlerTest, dcamera_source_handler_test_006, TestSize.Lev std::string params = "test006"; int32_t systemAbilityId = 4803; sptr loadCallback(new DCameraSourceLoadCallback(params)); - if (loadCallback == nullptr) { - return; - } + ASSERT_NE(loadCallback, nullptr); loadCallback->OnLoadSystemAbilityFail(systemAbilityId); systemAbilityId = 1; diff --git a/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp b/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp index 3c4e0c6067129f40a898f0d5690def2db610a909..862620c84d6bb77da273d4bcc2cc16695f0f153c 100644 --- a/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp +++ b/services/cameraservice/base/src/dcamera_capture_info_cmd.cpp @@ -166,7 +166,7 @@ int32_t DCameraCaptureInfoCmd::UmarshalSettings(cJSON *valueJson, std::shared_ptr& captureInfo) { if (captureInfo == nullptr) { - return DCAMERA_BAD_VALUE; + return DCAMERA_BAD_VALUE; } cJSON *captureSetting = nullptr; cJSON_ArrayForEach(captureSetting, valueJson) {