Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Unified Diff: components/cryptauth/remote_device_loader_unittest.cc

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: fixes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..91dd4da5982423d5236da4bf78f47c542ea2922d 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;
}
@@ -82,12 +92,36 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadZeroDevices) {
std::vector<cryptauth::RemoteDevice> result;
EXPECT_CALL(*this, LoadCompleted());
loader.Load(
- base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
- base::Unretained(this)));
+ false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
+ base::Unretained(this)));
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_));
+
+ std::vector<cryptauth::RemoteDevice> result;
+ EXPECT_CALL(*this, LoadCompleted());
+ loader.Load(
+ true, 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"));
@@ -97,8 +131,8 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithAddress) {
std::vector<cryptauth::RemoteDevice> result;
EXPECT_CALL(*this, LoadCompleted());
loader.Load(
- base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
- base::Unretained(this)));
+ false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
+ base::Unretained(this)));
EXPECT_EQ(1u, remote_devices_.size());
EXPECT_FALSE(remote_devices_[0].persistent_symmetric_key.empty());
@@ -106,6 +140,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) {
@@ -118,8 +153,8 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadOneDeviceWithoutAddress) {
std::vector<cryptauth::RemoteDevice> result;
EXPECT_CALL(*this, LoadCompleted());
loader.Load(
- base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
- base::Unretained(this)));
+ false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
+ base::Unretained(this)));
EXPECT_EQ(1u, remote_devices_.size());
EXPECT_FALSE(remote_devices_[0].persistent_symmetric_key.empty());
@@ -143,8 +178,8 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, LoadThreeRemoteDevices) {
EXPECT_CALL(*this, LoadCompleted());
loader.Load(
- base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
- base::Unretained(this)));
+ false, base::Bind(&CryptAuthRemoteDeviceLoaderTest::OnRemoteDevicesLoaded,
+ base::Unretained(this)));
EXPECT_EQ(3u, remote_devices_.size());
for (size_t i = 0; i < 3; ++i) {

Powered by Google App Engine
This is Rietveld 408576698