From c3f3beb34938f1039b52ef23ef60b3c32a28fb17 Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Fri, 9 Aug 2024 09:51:00 -0700 Subject: [PATCH] Uniformly return kOutOfOrderApiCall when APIs are not called in correct order. PiperOrigin-RevId: 661300308 --- sharing/nearby_sharing_service_impl.cc | 2 +- sharing/nearby_sharing_service_impl_test.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sharing/nearby_sharing_service_impl.cc b/sharing/nearby_sharing_service_impl.cc index 5254cf85..5df89c83 100644 --- a/sharing/nearby_sharing_service_impl.cc +++ b/sharing/nearby_sharing_service_impl.cc @@ -726,7 +726,7 @@ void NearbySharingServiceImpl::SendAttachments( if (!is_scanning_) { NL_LOG(WARNING) << __func__ << ": Failed to send attachments. Not scanning."; - std::move(status_codes_callback)(StatusCodes::kError); + std::move(status_codes_callback)(StatusCodes::kOutOfOrderApiCall); return; } diff --git a/sharing/nearby_sharing_service_impl_test.cc b/sharing/nearby_sharing_service_impl_test.cc index 74764a11..32b6e88b 100644 --- a/sharing/nearby_sharing_service_impl_test.cc +++ b/sharing/nearby_sharing_service_impl_test.cc @@ -3336,14 +3336,14 @@ TEST_F(NearbySharingServiceImplTest, SendTextAlreadySending) { // We're now in the sending state, try to send again should fail EXPECT_EQ(SendAttachments(target_id, CreateTextAttachments({kTextPayload})), - NearbySharingServiceImpl::StatusCodes::kError); + NearbySharingServiceImpl::StatusCodes::kOutOfOrderApiCall); UnregisterSendSurface(&transfer_callback); } TEST_F(NearbySharingServiceImplTest, SendTextWithoutScanning) { EXPECT_EQ(SendAttachments(325626L, CreateTextAttachments({kTextPayload})), - NearbySharingServiceImpl::StatusCodes::kError); + NearbySharingServiceImpl::StatusCodes::kOutOfOrderApiCall); } TEST_F(NearbySharingServiceImplTest, SendTextUnknownTarget) {