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

Unified Diff: components/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc

Issue 2847233003: [EasyUnlock] Move DataWithTimestamp out of ForegroundEidGenerator so it can be shared. (Closed)
Patch Set: Created 3 years, 8 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/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc
diff --git a/components/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc b/components/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc
index e596b8d661e4e85ced12f1ad98b732dfeef5c461..b4b65f3c60bf9f31a39fb3529bbae910e541bd5f 100644
--- a/components/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc
+++ b/components/proximity_auth/bluetooth_low_energy_connection_finder_unittest.cc
@@ -51,6 +51,7 @@ const char kEidForPreviousTimeQuantum[] = "\x12\x34";
const char kEidForCurrentTimeQuantum[] = "\xab\xcd";
const char kEidForNextTimeQuantum[] = "\x56\x78";
const char kWrongEid[] = "\xff\xff";
+const int64_t kEidPeriodMs = 60 * 1000 * 15;
Kyle Horimoto 2017/04/28 22:19:17 nit: Use a constant kEidPeriodMinutes = 15 and use
Tim Song 2017/04/29 01:07:50 It seems cleaner to use milliseconds directly as I
Kyle Horimoto 2017/04/30 03:17:42 Alright, can you add a "15 minutes" comment then?
Tim Song 2017/05/01 22:23:38 Done.
std::vector<cryptauth::BeaconSeed> CreateBeaconSeeds() {
std::vector<cryptauth::BeaconSeed> beacon_seeds;
@@ -69,7 +70,7 @@ class FakeEidGenerator : public cryptauth::BackgroundEidGenerator {
: connection_finder_(connection_finder) {}
~FakeEidGenerator() override {}
- std::vector<std::string> GenerateNearestEids(
+ std::vector<cryptauth::EidDataWithTimestamp> GenerateNearestEids(
const std::vector<cryptauth::BeaconSeed>& beacon_seed) const override;
private:
@@ -131,9 +132,20 @@ class MockBluetoothLowEnergyConnectionFinder
// Not declared in-line due to dependency on
// MockBluetoothLowEnergyConnectionFinder.
-std::vector<std::string> FakeEidGenerator::GenerateNearestEids(
+std::vector<cryptauth::EidDataWithTimestamp>
+FakeEidGenerator::GenerateNearestEids(
const std::vector<cryptauth::BeaconSeed>& beacon_seed) const {
- return connection_finder_->nearest_eids();
+ std::vector<std::string> nearest_eids = connection_finder_->nearest_eids();
+
+ std::vector<cryptauth::EidDataWithTimestamp> eid_data_with_timestamps;
+ int64_t start_of_period_ms = 0;
+ for (const std::string& eid : nearest_eids) {
+ eid_data_with_timestamps.push_back(cryptauth::EidDataWithTimestamp(
+ eid, start_of_period_ms, start_of_period_ms + kEidPeriodMs));
+ start_of_period_ms += kEidPeriodMs;
+ }
+
+ return eid_data_with_timestamps;
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698