| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/proximity_auth/proximity_monitor_impl.h" | 5 #include "components/proximity_auth/proximity_monitor_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 using testing::SaveArg; | 31 using testing::SaveArg; |
| 32 | 32 |
| 33 namespace proximity_auth { | 33 namespace proximity_auth { |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const char kRemoteDeviceUserId[] = "example@gmail.com"; | 36 const char kRemoteDeviceUserId[] = "example@gmail.com"; |
| 37 const char kRemoteDevicePublicKey[] = "Remote Public Key"; | 37 const char kRemoteDevicePublicKey[] = "Remote Public Key"; |
| 38 const char kRemoteDeviceName[] = "LGE Nexus 5"; | 38 const char kRemoteDeviceName[] = "LGE Nexus 5"; |
| 39 const char kBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; | 39 const char kBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; |
| 40 const char kPersistentSymmetricKey[] = "PSK"; | 40 const char kPersistentSymmetricKey[] = "PSK"; |
| 41 const int kRssiThreshold = -50; | 41 const int kRssiThreshold = -70; |
| 42 | 42 |
| 43 class MockProximityMonitorObserver : public ProximityMonitorObserver { | 43 class MockProximityMonitorObserver : public ProximityMonitorObserver { |
| 44 public: | 44 public: |
| 45 MockProximityMonitorObserver() {} | 45 MockProximityMonitorObserver() {} |
| 46 ~MockProximityMonitorObserver() override {} | 46 ~MockProximityMonitorObserver() override {} |
| 47 | 47 |
| 48 MOCK_METHOD0(OnProximityStateChanged, void()); | 48 MOCK_METHOD0(OnProximityStateChanged, void()); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(MockProximityMonitorObserver); | 51 DISALLOW_COPY_AND_ASSIGN(MockProximityMonitorObserver); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ProvideConnectionInfo({-1, 4, 4}); | 228 ProvideConnectionInfo({-1, 4, 4}); |
| 229 ProvideConnectionInfo({-4, 4, 4}); | 229 ProvideConnectionInfo({-4, 4, 4}); |
| 230 ProvideConnectionInfo({0, 4, 4}); | 230 ProvideConnectionInfo({0, 4, 4}); |
| 231 ProvideConnectionInfo({-10, 4, 4}); | 231 ProvideConnectionInfo({-10, 4, 4}); |
| 232 ProvideConnectionInfo({-15, 4, 4}); | 232 ProvideConnectionInfo({-15, 4, 4}); |
| 233 ProvideConnectionInfo({-20, 4, 4}); | 233 ProvideConnectionInfo({-20, 4, 4}); |
| 234 ProvideConnectionInfo({kRssiThreshold, 4, 4}); | 234 ProvideConnectionInfo({kRssiThreshold, 4, 4}); |
| 235 ProvideConnectionInfo({kRssiThreshold - 10, 4, 4}); | 235 ProvideConnectionInfo({kRssiThreshold - 10, 4, 4}); |
| 236 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); | 236 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); |
| 237 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); | 237 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); |
| 238 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); |
| 239 ProvideConnectionInfo({kRssiThreshold - 20, 4, 4}); |
| 238 | 240 |
| 239 EXPECT_FALSE(monitor_.IsUnlockAllowed()); | 241 EXPECT_FALSE(monitor_.IsUnlockAllowed()); |
| 240 } | 242 } |
| 241 | 243 |
| 242 TEST_F(ProximityAuthProximityMonitorImplTest, | 244 TEST_F(ProximityAuthProximityMonitorImplTest, |
| 243 IsUnlockAllowed_RemoteDeviceEntersProximity) { | 245 IsUnlockAllowed_RemoteDeviceEntersProximity) { |
| 244 monitor_.Start(); | 246 monitor_.Start(); |
| 245 | 247 |
| 246 // Start with a device out of proximity. | 248 // Start with a device out of proximity. |
| 247 ProvideConnectionInfo({2 * kRssiThreshold, 4, 4}); | 249 ProvideConnectionInfo({2 * kRssiThreshold, 4, 4}); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 base::HistogramTester histogram_tester; | 350 base::HistogramTester histogram_tester; |
| 349 monitor.RecordProximityMetricsOnAuthSuccess(); | 351 monitor.RecordProximityMetricsOnAuthSuccess(); |
| 350 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi", | 352 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi", |
| 351 127, 1); | 353 127, 1); |
| 352 histogram_tester.ExpectUniqueSample( | 354 histogram_tester.ExpectUniqueSample( |
| 353 "EasyUnlock.AuthProximity.RemoteDeviceModelHash", | 355 "EasyUnlock.AuthProximity.RemoteDeviceModelHash", |
| 354 -1808066424 /* hash of "Unknown" */, 1); | 356 -1808066424 /* hash of "Unknown" */, 1); |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace proximity_auth | 359 } // namespace proximity_auth |
| OLD | NEW |