mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Set contacts visibility when logging in so the user is ready to share immediately.
PiperOrigin-RevId: 668690895
This commit is contained in:
committed by
Copybara-Service
parent
b376b9456b
commit
16d9e867c9
@@ -3562,6 +3562,9 @@ void NearbySharingServiceImpl::ResetAllSettings(bool logout) {
|
||||
settings_->OnLocalDeviceDataChanged(/*did_device_name_change=*/true,
|
||||
/*did_full_name_change=*/false,
|
||||
/*did_icon_url_change=*/false);
|
||||
// Set contacts visibility when logging in so the user is ready to share
|
||||
// immediately. Notify observers as well.
|
||||
settings_->SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
}
|
||||
|
||||
// Start services again.
|
||||
|
||||
@@ -4527,6 +4527,31 @@ TEST_F(NearbySharingServiceImplTest, LoginAndLogoutShouldResetSettings) {
|
||||
EXPECT_TRUE(sharing_service_task_runner_->SyncWithTimeout(kTaskWaitTimeout));
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest, LoginShouldSetContactsVisibility) {
|
||||
SetConnectionType(ConnectionType::kWifi);
|
||||
|
||||
// Create account.
|
||||
AccountManager::Account account;
|
||||
account.id = kTestAccountId;
|
||||
|
||||
// Login user.
|
||||
absl::Notification login_notification;
|
||||
account_manager().SetAccount(account);
|
||||
service_->GetAccountManager()->Login(
|
||||
"test_client_id", "test_client_secret",
|
||||
[&](AccountManager::Account account) {
|
||||
EXPECT_EQ(account.id, kTestAccountId);
|
||||
login_notification.Notify();
|
||||
},
|
||||
[](absl::Status status) {});
|
||||
|
||||
ASSERT_TRUE(login_notification.WaitForNotificationWithTimeout(kWaitTimeout));
|
||||
ASSERT_TRUE(sharing_service_task_runner_->SyncWithTimeout(kTaskWaitTimeout));
|
||||
|
||||
EXPECT_EQ(service_->GetSettings()->GetVisibility(),
|
||||
DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
}
|
||||
|
||||
TEST_F(NearbySharingServiceImplTest, LogoutShouldSetValidVisibility) {
|
||||
SetConnectionType(ConnectionType::kWifi);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user