Skip to content

Commit

Permalink
Add unittest.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 715553625
  • Loading branch information
ftsui authored and copybara-github committed Jan 15, 2025
1 parent 6694e2b commit e066409
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sharing/certificates/nearby_share_certificate_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,24 @@ TEST_F(NearbyShareCertificateManagerImplTest,
3 * kNearbyShareNumPrivateCertificates);
}

TEST_F(NearbyShareCertificateManagerImplTest,
RefreshPrivateCertificates_NotLoggedIn_DoesNotCallPublishDevice) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_sharing_feature::kCallNearbyIdentityApi,
true);
fake_account_manager_.SetAccount(std::nullopt);
// All private certificates are valid.
cert_store_->ReplacePrivateCertificates({});
cert_manager_->PrivateCertificateRefresh(/*force_upload=*/true);
Sync();

upload_scheduler_->InvokeRequestCallback();
Sync();

EXPECT_EQ(cert_store_->GetPrivateCertificates()->size(), 0);
EXPECT_EQ(local_device_data_manager_->publish_device_calls().size(), 0);
}

TEST_F(NearbyShareCertificateManagerImplTest,
RefreshPrivateCertificates_NoCertificates_UploadFailure) {
cert_store_->ReplacePrivateCertificates({});
Expand Down

0 comments on commit e066409

Please sign in to comment.