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

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

Issue 1377313002: Revert of Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 2 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 "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 20 matching lines...) Expand all
31 31
32 const char kRemoteDeviceUserId[] = "example@gmail.com"; 32 const char kRemoteDeviceUserId[] = "example@gmail.com";
33 const char kBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; 33 const char kBluetoothAddress[] = "AA:BB:CC:DD:EE:FF";
34 const char kRemoteDevicePublicKey[] = "Remote Public Key"; 34 const char kRemoteDevicePublicKey[] = "Remote Public Key";
35 const char kRemoteDeviceName[] = "LGE Nexus 5"; 35 const char kRemoteDeviceName[] = "LGE Nexus 5";
36 const char kPersistentSymmetricKey[] = "PSK"; 36 const char kPersistentSymmetricKey[] = "PSK";
37 37
38 class TestProximityMonitorImpl : public ProximityMonitorImpl { 38 class TestProximityMonitorImpl : public ProximityMonitorImpl {
39 public: 39 public:
40 explicit TestProximityMonitorImpl(const RemoteDevice& remote_device, 40 explicit TestProximityMonitorImpl(const RemoteDevice& remote_device,
41 scoped_ptr<base::TickClock> clock) 41 scoped_ptr<base::TickClock> clock,
42 : ProximityMonitorImpl(remote_device, clock.Pass()) {} 42 ProximityMonitorObserver* observer)
43 : ProximityMonitorImpl(remote_device, clock.Pass(), observer) {}
43 ~TestProximityMonitorImpl() override {} 44 ~TestProximityMonitorImpl() override {}
44 45
45 using ProximityMonitorImpl::SetStrategy; 46 using ProximityMonitorImpl::SetStrategy;
46 47
47 private: 48 private:
48 DISALLOW_COPY_AND_ASSIGN(TestProximityMonitorImpl); 49 DISALLOW_COPY_AND_ASSIGN(TestProximityMonitorImpl);
49 }; 50 };
50 51
51 class MockProximityMonitorObserver : public ProximityMonitorObserver { 52 class MockProximityMonitorObserver : public ProximityMonitorObserver {
52 public: 53 public:
(...skipping 29 matching lines...) Expand all
82 kBluetoothAddress, 83 kBluetoothAddress,
83 false /* paired */, 84 false /* paired */,
84 true /* connected */), 85 true /* connected */),
85 monitor_(RemoteDevice(kRemoteDeviceUserId, 86 monitor_(RemoteDevice(kRemoteDeviceUserId,
86 kRemoteDeviceName, 87 kRemoteDeviceName,
87 kRemoteDevicePublicKey, 88 kRemoteDevicePublicKey,
88 RemoteDevice::BLUETOOTH_CLASSIC, 89 RemoteDevice::BLUETOOTH_CLASSIC,
89 kBluetoothAddress, 90 kBluetoothAddress,
90 kPersistentSymmetricKey, 91 kPersistentSymmetricKey,
91 std::string()), 92 std::string()),
92 make_scoped_ptr(clock_)), 93 make_scoped_ptr(clock_),
94 &observer_),
93 task_runner_(new base::TestSimpleTaskRunner()), 95 task_runner_(new base::TestSimpleTaskRunner()),
94 thread_task_runner_handle_(task_runner_) { 96 thread_task_runner_handle_(task_runner_) {
95 ON_CALL(*bluetooth_adapter_, GetDevice(kBluetoothAddress)) 97 ON_CALL(*bluetooth_adapter_, GetDevice(kBluetoothAddress))
96 .WillByDefault(Return(&remote_bluetooth_device_)); 98 .WillByDefault(Return(&remote_bluetooth_device_));
97 ON_CALL(remote_bluetooth_device_, GetConnectionInfo(_)) 99 ON_CALL(remote_bluetooth_device_, GetConnectionInfo(_))
98 .WillByDefault(SaveArg<0>(&connection_info_callback_)); 100 .WillByDefault(SaveArg<0>(&connection_info_callback_));
99 monitor_.AddObserver(&observer_);
100 } 101 }
101 ~ProximityAuthProximityMonitorImplTest() override {} 102 ~ProximityAuthProximityMonitorImplTest() override {}
102 103
103 void RunPendingTasks() { task_runner_->RunPendingTasks(); } 104 void RunPendingTasks() { task_runner_->RunPendingTasks(); }
104 105
105 void ProvideConnectionInfo( 106 void ProvideConnectionInfo(
106 const BluetoothDevice::ConnectionInfo& connection_info) { 107 const BluetoothDevice::ConnectionInfo& connection_info) {
107 RunPendingTasks(); 108 RunPendingTasks();
108 connection_info_callback_.Run(connection_info); 109 connection_info_callback_.Run(connection_info);
109 110
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 TEST_F(ProximityAuthProximityMonitorImplTest, 537 TEST_F(ProximityAuthProximityMonitorImplTest,
537 RecordProximityMetricsOnAuthSuccess_UnknownValues) { 538 RecordProximityMetricsOnAuthSuccess_UnknownValues) {
538 // Note: A device without a recorded name will have its Bluetooth address as 539 // Note: A device without a recorded name will have its Bluetooth address as
539 // its name. 540 // its name.
540 RemoteDevice unnamed_remote_device( 541 RemoteDevice unnamed_remote_device(
541 kRemoteDeviceUserId, kBluetoothAddress, kRemoteDevicePublicKey, 542 kRemoteDeviceUserId, kBluetoothAddress, kRemoteDevicePublicKey,
542 RemoteDevice::BLUETOOTH_CLASSIC, kBluetoothAddress, 543 RemoteDevice::BLUETOOTH_CLASSIC, kBluetoothAddress,
543 kPersistentSymmetricKey, std::string()); 544 kPersistentSymmetricKey, std::string());
544 545
545 scoped_ptr<base::TickClock> clock(new base::SimpleTestTickClock()); 546 scoped_ptr<base::TickClock> clock(new base::SimpleTestTickClock());
546 ProximityMonitorImpl monitor(unnamed_remote_device, clock.Pass()); 547 ProximityMonitorImpl monitor(unnamed_remote_device, clock.Pass(), &observer_);
547 monitor.AddObserver(&observer_);
548 monitor.Start(); 548 monitor.Start();
549 ProvideConnectionInfo({127, 127, 127}); 549 ProvideConnectionInfo({127, 127, 127});
550 550
551 base::HistogramTester histogram_tester; 551 base::HistogramTester histogram_tester;
552 monitor.RecordProximityMetricsOnAuthSuccess(); 552 monitor.RecordProximityMetricsOnAuthSuccess();
553 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi", 553 histogram_tester.ExpectUniqueSample("EasyUnlock.AuthProximity.RollingRssi",
554 127, 1); 554 127, 1);
555 histogram_tester.ExpectUniqueSample( 555 histogram_tester.ExpectUniqueSample(
556 "EasyUnlock.AuthProximity.TransmitPowerDelta", 127, 1); 556 "EasyUnlock.AuthProximity.TransmitPowerDelta", 127, 1);
557 histogram_tester.ExpectUniqueSample( 557 histogram_tester.ExpectUniqueSample(
558 "EasyUnlock.AuthProximity.TimeSinceLastZeroRssi", 558 "EasyUnlock.AuthProximity.TimeSinceLastZeroRssi",
559 base::TimeDelta::FromSeconds(10).InMilliseconds(), 1); 559 base::TimeDelta::FromSeconds(10).InMilliseconds(), 1);
560 histogram_tester.ExpectUniqueSample( 560 histogram_tester.ExpectUniqueSample(
561 "EasyUnlock.AuthProximity.RemoteDeviceModelHash", 561 "EasyUnlock.AuthProximity.RemoteDeviceModelHash",
562 -1808066424 /* hash of "Unknown" */, 1); 562 -1808066424 /* hash of "Unknown" */, 1);
563 } 563 }
564 564
565 } // namespace proximity_auth 565 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/proximity_monitor_impl.cc ('k') | components/proximity_auth/remote_device_life_cycle_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698