Index: components/cryptauth/remote_device_loader_unittest.cc |
diff --git a/components/cryptauth/remote_device_loader_unittest.cc b/components/cryptauth/remote_device_loader_unittest.cc |
index a164542b9a8bc07aec42c40e70f7dab8240e110e..068f177eefa825d32b19dc9a6ffe9976a344160c 100644 |
--- a/components/cryptauth/remote_device_loader_unittest.cc |
+++ b/components/cryptauth/remote_device_loader_unittest.cc |
@@ -29,6 +29,11 @@ const char kUserId[] = "example@gmail.com"; |
// The public key of the user's local device. |
const char kUserPublicKey[] = "User public key"; |
+// BeaconSeed values. |
+const int64_t kBeaconSeedStartTimeMs = 1000; |
+const int64_t kBeaconSeedEndTimeMs = 2000; |
+const char kBeaconSeedData[] = "Beacon Seed Data"; |
+ |
// Creates and returns an ExternalDeviceInfo proto with the fields appended with |
// |suffix|. |
cryptauth::ExternalDeviceInfo CreateDeviceInfo(const std::string& suffix) { |
@@ -37,6 +42,11 @@ cryptauth::ExternalDeviceInfo CreateDeviceInfo(const std::string& suffix) { |
device_info.set_public_key(std::string(kPublicKeyPrefix) + suffix); |
device_info.set_bluetooth_address(std::string(kBluetoothAddressPrefix) + |
suffix); |
+ device_info.add_beacon_seeds(); |
+ BeaconSeed* beacon_seed = device_info.mutable_beacon_seeds(0); |
+ beacon_seed->set_start_time_millis(kBeaconSeedStartTimeMs); |
+ beacon_seed->set_end_time_millis(kBeaconSeedEndTimeMs); |
+ beacon_seed->set_data(kBeaconSeedData); |
return device_info; |
} |
@@ -88,6 +98,31 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadZeroDevices) { |
EXPECT_EQ(0u, remote_devices_.size()); |
} |
+TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithBeaconSeeds) { |
+ std::vector<cryptauth::ExternalDeviceInfo> device_infos( |
+ 1, CreateDeviceInfo("0")); |
+ RemoteDeviceLoader loader(device_infos, user_private_key_, kUserId, |
+ std::move(secure_message_delegate_)); |
+ loader.set_should_load_beacon_seeds(true); |
+ |
+ std::vector<cryptauth::RemoteDevice> result; |
+ EXPECT_CALL(*this, LoadCompleted()); |
+ loader.Load( |
+ base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded, |
+ base::Unretained(this))); |
+ |
+ EXPECT_EQ(1u, remote_devices_.size()); |
+ EXPECT_FALSE(remote_devices_[0].persistent_symmetric_key.empty()); |
+ EXPECT_EQ(device_infos[0].friendly_device_name(), remote_devices_[0].name); |
+ EXPECT_EQ(device_infos[0].public_key(), remote_devices_[0].public_key); |
+ ASSERT_EQ(1u, remote_devices_[0].beacon_seeds.size()); |
+ |
+ const BeaconSeed& beacon_seed = remote_devices_[0].beacon_seeds[0]; |
+ EXPECT_EQ(kBeaconSeedData, beacon_seed.data()); |
+ EXPECT_EQ(kBeaconSeedStartTimeMs, beacon_seed.start_time_millis()); |
+ EXPECT_EQ(kBeaconSeedEndTimeMs, beacon_seed.end_time_millis()); |
+} |
+ |
TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithAddress) { |
std::vector<cryptauth::ExternalDeviceInfo> device_infos(1, |
CreateDeviceInfo("0")); |
@@ -106,6 +141,7 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithAddress) { |
EXPECT_EQ(device_infos[0].public_key(), remote_devices_[0].public_key); |
EXPECT_EQ(device_infos[0].bluetooth_address(), |
remote_devices_[0].bluetooth_address); |
+ EXPECT_EQ(0u, remote_devices_[0].beacon_seeds.size()); |
} |
TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithoutAddress) { |