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

Side by Side Diff: components/proximity_auth/proximity_monitor_impl_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 new NiceMock<device::MockBluetoothAdapter>(); 69 new NiceMock<device::MockBluetoothAdapter>();
70 device::BluetoothAdapterFactory::SetAdapterForTesting(adapter); 70 device::BluetoothAdapterFactory::SetAdapterForTesting(adapter);
71 return adapter; 71 return adapter;
72 } 72 }
73 73
74 } // namespace 74 } // namespace
75 75
76 class ProximityAuthProximityMonitorImplTest : public testing::Test { 76 class ProximityAuthProximityMonitorImplTest : public testing::Test {
77 public: 77 public:
78 ProximityAuthProximityMonitorImplTest() 78 ProximityAuthProximityMonitorImplTest()
79 : clock_(new base::SimpleTestTickClock()), 79 : clock_(new base::SimpleTestTickClock(base::TimeTicks())),
80 bluetooth_adapter_(CreateAndRegisterMockBluetoothAdapter()), 80 bluetooth_adapter_(CreateAndRegisterMockBluetoothAdapter()),
81 remote_bluetooth_device_(&*bluetooth_adapter_, 81 remote_bluetooth_device_(&*bluetooth_adapter_,
82 0, 82 0,
83 kRemoteDeviceName, 83 kRemoteDeviceName,
84 kBluetoothAddress, 84 kBluetoothAddress,
85 false /* paired */, 85 false /* paired */,
86 true /* connected */), 86 true /* connected */),
87 monitor_(RemoteDevice(kRemoteDeviceUserId, 87 monitor_(RemoteDevice(kRemoteDeviceUserId,
88 kRemoteDeviceName, 88 kRemoteDeviceName,
89 kRemoteDevicePublicKey, 89 kRemoteDevicePublicKey,
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 537
538 TEST_F(ProximityAuthProximityMonitorImplTest, 538 TEST_F(ProximityAuthProximityMonitorImplTest,
539 RecordProximityMetricsOnAuthSuccess_UnknownValues) { 539 RecordProximityMetricsOnAuthSuccess_UnknownValues) {
540 // Note: A device without a recorded name will have its Bluetooth address as 540 // Note: A device without a recorded name will have its Bluetooth address as
541 // its name. 541 // its name.
542 RemoteDevice unnamed_remote_device( 542 RemoteDevice unnamed_remote_device(
543 kRemoteDeviceUserId, kBluetoothAddress, kRemoteDevicePublicKey, 543 kRemoteDeviceUserId, kBluetoothAddress, kRemoteDevicePublicKey,
544 RemoteDevice::BLUETOOTH_CLASSIC, kBluetoothAddress, 544 RemoteDevice::BLUETOOTH_CLASSIC, kBluetoothAddress,
545 kPersistentSymmetricKey, std::string()); 545 kPersistentSymmetricKey, std::string());
546 546
547 scoped_ptr<base::TickClock> clock(new base::SimpleTestTickClock()); 547 scoped_ptr<base::TickClock> clock(
548 new base::SimpleTestTickClock(base::TimeTicks()));
548 ProximityMonitorImpl monitor(unnamed_remote_device, std::move(clock)); 549 ProximityMonitorImpl monitor(unnamed_remote_device, std::move(clock));
549 monitor.AddObserver(&observer_); 550 monitor.AddObserver(&observer_);
550 monitor.Start(); 551 monitor.Start();
551 ProvideConnectionInfo({127, 127, 127}); 552 ProvideConnectionInfo({127, 127, 127});
552 553
553 base::HistogramTester histogram_tester; 554 base::HistogramTester histogram_tester;
554 monitor.RecordProximityMetricsOnAuthSuccess(); 555 monitor.RecordProximityMetricsOnAuthSuccess();
555 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi", 556 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi",
556 127, 1); 557 127, 1);
557 histogram_tester.ExpectUniqueSample( 558 histogram_tester.ExpectUniqueSample(
558 "EasyUnlock.AuthProximity.TransmitPowerDelta", 127, 1); 559 "EasyUnlock.AuthProximity.TransmitPowerDelta", 127, 1);
559 histogram_tester.ExpectUniqueSample( 560 histogram_tester.ExpectUniqueSample(
560 "EasyUnlock.AuthProximity.TimeSinceLastZeroRssi", 561 "EasyUnlock.AuthProximity.TimeSinceLastZeroRssi",
561 base::TimeDelta::FromSeconds(10).InMilliseconds(), 1); 562 base::TimeDelta::FromSeconds(10).InMilliseconds(), 1);
562 histogram_tester.ExpectUniqueSample( 563 histogram_tester.ExpectUniqueSample(
563 "EasyUnlock.AuthProximity.RemoteDeviceModelHash", 564 "EasyUnlock.AuthProximity.RemoteDeviceModelHash",
564 -1808066424 /* hash of "Unknown" */, 1); 565 -1808066424 /* hash of "Unknown" */, 1);
565 } 566 }
566 567
567 } // namespace proximity_auth 568 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698