| Index: components/proximity_auth/proximity_monitor_impl_unittest.cc
|
| diff --git a/components/proximity_auth/proximity_monitor_impl_unittest.cc b/components/proximity_auth/proximity_monitor_impl_unittest.cc
|
| index 85def4bf236968ef2ed12731b2cdbd87939f7f5d..3bb2c8225dea573c1027ce91267fa96e7a96726b 100644
|
| --- a/components/proximity_auth/proximity_monitor_impl_unittest.cc
|
| +++ b/components/proximity_auth/proximity_monitor_impl_unittest.cc
|
| @@ -236,7 +236,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({BluetoothDevice::kUnknownPower, 0, 4});
|
| + ProvideConnectionInfo({BluetoothDevice::kUnknownRSSI, 0, 4});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -248,7 +248,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({0, BluetoothDevice::kUnknownPower, 4});
|
| + ProvideConnectionInfo({0, BluetoothDevice::kUnknownTxPower, 4});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -260,7 +260,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({0, 0, BluetoothDevice::kUnknownPower});
|
| + ProvideConnectionInfo({0, 0, BluetoothDevice::kUnknownTxPower});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -316,7 +316,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({BluetoothDevice::kUnknownPower, 0, 4});
|
| + ProvideConnectionInfo({BluetoothDevice::kUnknownRSSI, 0, 4});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -328,7 +328,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({0, BluetoothDevice::kUnknownPower, 4});
|
| + ProvideConnectionInfo({0, BluetoothDevice::kUnknownTxPower, 4});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -340,7 +340,7 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| monitor_.Start();
|
|
|
| ProvideConnectionInfo({0, 0, 4});
|
| - ProvideConnectionInfo({0, 0, BluetoothDevice::kUnknownPower});
|
| + ProvideConnectionInfo({0, 0, BluetoothDevice::kUnknownTxPower});
|
|
|
| EXPECT_FALSE(monitor_.IsUnlockAllowed());
|
| EXPECT_FALSE(monitor_.IsInRssiRange());
|
| @@ -524,15 +524,52 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| }
|
|
|
| TEST_F(ProximityAuthProximityMonitorImplTest,
|
| - RecordProximityMetricsOnAuthSuccess_ClampedValues) {
|
| + RecordProximityMetricsOnAuthSuccess_ClampedValues_LowerThreshold) {
|
| + // Tests that we clamp values lower than -100 before histograming.
|
| + int8_t rssi = -128;
|
| + int8_t tx_power = -127;
|
| + int8_t max_tx_power = 0;
|
| + int8_t tx_power_delta = tx_power - max_tx_power;
|
| +
|
| monitor_.Start();
|
| - ProvideConnectionInfo({-99999, 99999, 12345});
|
| +
|
| + ASSERT_FALSE(rssi == BluetoothDevice::kUnknownRSSI);
|
| + ASSERT_FALSE(tx_power == BluetoothDevice::kUnknownTxPower);
|
| + ASSERT_FALSE(max_tx_power == BluetoothDevice::kUnknownTxPower);
|
| + ASSERT_FALSE(tx_power_delta == BluetoothDevice::kUnknownTxPower);
|
| +
|
| + ProvideConnectionInfo({rssi, tx_power, max_tx_power});
|
|
|
| base::HistogramTester histogram_tester;
|
| monitor_.RecordProximityMetricsOnAuthSuccess();
|
| histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi",
|
| -100, 1);
|
| histogram_tester.ExpectUniqueSample(
|
| + "EasyUnlock.AuthProximity.TransmitPowerDelta", -100, 1);
|
| +}
|
| +
|
| +TEST_F(ProximityAuthProximityMonitorImplTest,
|
| + RecordProximityMetricsOnAuthSuccess_ClampedValues_UpperThreshold) {
|
| + // Tests that we clamp values larger than 50 before histograming.
|
| + int8_t rssi = 126;
|
| + int8_t tx_power = 127;
|
| + int8_t max_tx_power = 0;
|
| + int8_t tx_power_delta = tx_power - max_tx_power;
|
| +
|
| + monitor_.Start();
|
| +
|
| + ASSERT_FALSE(rssi == BluetoothDevice::kUnknownRSSI);
|
| + ASSERT_FALSE(tx_power == BluetoothDevice::kUnknownTxPower);
|
| + ASSERT_FALSE(max_tx_power == BluetoothDevice::kUnknownTxPower);
|
| + ASSERT_FALSE(tx_power_delta == BluetoothDevice::kUnknownTxPower);
|
| +
|
| + ProvideConnectionInfo({rssi, tx_power, max_tx_power});
|
| +
|
| + base::HistogramTester histogram_tester;
|
| + monitor_.RecordProximityMetricsOnAuthSuccess();
|
| + histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi",
|
| + 50, 1);
|
| + histogram_tester.ExpectUniqueSample(
|
| "EasyUnlock.AuthProximity.TransmitPowerDelta", 50, 1);
|
| }
|
|
|
| @@ -549,14 +586,17 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
|
| ProximityMonitorImpl monitor(unnamed_remote_device, std::move(clock));
|
| monitor.AddObserver(&observer_);
|
| monitor.Start();
|
| - ProvideConnectionInfo({127, 127, 127});
|
| + ProvideConnectionInfo({BluetoothDevice::kUnknownRSSI,
|
| + BluetoothDevice::kUnknownTxPower,
|
| + BluetoothDevice::kUnknownTxPower});
|
|
|
| base::HistogramTester histogram_tester;
|
| monitor.RecordProximityMetricsOnAuthSuccess();
|
| histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi",
|
| - 127, 1);
|
| + BluetoothDevice::kUnknownRSSI, 1);
|
| histogram_tester.ExpectUniqueSample(
|
| - "EasyUnlock.AuthProximity.TransmitPowerDelta", 127, 1);
|
| + "EasyUnlock.AuthProximity.TransmitPowerDelta",
|
| + BluetoothDevice::kUnknownTxPower, 1);
|
| histogram_tester.ExpectUniqueSample(
|
| "EasyUnlock.AuthProximity.TimeSinceLastZeroRssi",
|
| base::TimeDelta::FromSeconds(10).InMilliseconds(), 1);
|
|
|