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

Side by Side Diff: chromeos/components/tether/ble_connection_manager_unittest.cc

Issue 2803153002: [CrOS Tether] Refactor BleScanner so that it takes a BluetoothAdapter in its constructor instead of… (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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chromeos/components/tether/ble_connection_manager.h" 5 #include "chromeos/components/tether/ble_connection_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/timer/mock_timer.h" 8 #include "base/timer/mock_timer.h"
9 #include "chromeos/components/tether/ble_constants.h" 9 #include "chromeos/components/tether/ble_constants.h"
10 #include "chromeos/components/tether/proto/tether.pb.h" 10 #include "chromeos/components/tether/proto/tether.pb.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return received_messages_; 86 return received_messages_;
87 } 87 }
88 88
89 private: 89 private:
90 std::vector<SecureChannelStatusChange> connection_status_changes_; 90 std::vector<SecureChannelStatusChange> connection_status_changes_;
91 std::vector<ReceivedMessage> received_messages_; 91 std::vector<ReceivedMessage> received_messages_;
92 }; 92 };
93 93
94 class MockBleScanner : public BleScanner { 94 class MockBleScanner : public BleScanner {
95 public: 95 public:
96 MockBleScanner() : BleScanner(nullptr) {} 96 MockBleScanner(scoped_refptr<device::BluetoothAdapter> adapter)
97 : BleScanner(adapter, nullptr) {}
97 ~MockBleScanner() override {} 98 ~MockBleScanner() override {}
98 99
99 MOCK_METHOD1(RegisterScanFilterForDevice, 100 MOCK_METHOD1(RegisterScanFilterForDevice,
100 bool(const cryptauth::RemoteDevice&)); 101 bool(const cryptauth::RemoteDevice&));
101 MOCK_METHOD1(UnregisterScanFilterForDevice, 102 MOCK_METHOD1(UnregisterScanFilterForDevice,
102 bool(const cryptauth::RemoteDevice&)); 103 bool(const cryptauth::RemoteDevice&));
103 104
104 void SimulateScanResults(const std::string& device_address, 105 void SimulateScanResults(const std::string& device_address,
105 const cryptauth::RemoteDevice& remote_device) { 106 const cryptauth::RemoteDevice& remote_device) {
106 for (auto& observer : observer_list_) { 107 for (auto& observer : observer_list_) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 245
245 void SetUp() override { 246 void SetUp() override {
246 verified_status_changes_.clear(); 247 verified_status_changes_.clear();
247 verified_received_messages_.clear(); 248 verified_received_messages_.clear();
248 249
249 fake_cryptauth_service_ = 250 fake_cryptauth_service_ =
250 base::MakeUnique<cryptauth::FakeCryptAuthService>(); 251 base::MakeUnique<cryptauth::FakeCryptAuthService>();
251 mock_adapter_ = 252 mock_adapter_ =
252 make_scoped_refptr(new NiceMock<device::MockBluetoothAdapter>()); 253 make_scoped_refptr(new NiceMock<device::MockBluetoothAdapter>());
253 254
254 mock_ble_scanner_ = new MockBleScanner(); 255 mock_ble_scanner_ = new MockBleScanner(mock_adapter_);
255 ON_CALL(*mock_ble_scanner_, RegisterScanFilterForDevice(_)) 256 ON_CALL(*mock_ble_scanner_, RegisterScanFilterForDevice(_))
256 .WillByDefault(Return(true)); 257 .WillByDefault(Return(true));
257 ON_CALL(*mock_ble_scanner_, UnregisterScanFilterForDevice(_)) 258 ON_CALL(*mock_ble_scanner_, UnregisterScanFilterForDevice(_))
258 .WillByDefault(Return(true)); 259 .WillByDefault(Return(true));
259 260
260 mock_ble_advertiser_ = new MockBleAdvertiser(); 261 mock_ble_advertiser_ = new MockBleAdvertiser();
261 ON_CALL(*mock_ble_advertiser_, StartAdvertisingToDevice(_)) 262 ON_CALL(*mock_ble_advertiser_, StartAdvertisingToDevice(_))
262 .WillByDefault(Return(true)); 263 .WillByDefault(Return(true));
263 ON_CALL(*mock_ble_advertiser_, StopAdvertisingToDevice(_)) 264 ON_CALL(*mock_ble_advertiser_, StopAdvertisingToDevice(_))
264 .WillByDefault(Return(true)); 265 .WillByDefault(Return(true));
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 cryptauth::SecureChannel::Status::DISCONNECTED}, 1211 cryptauth::SecureChannel::Status::DISCONNECTED},
1211 {test_devices_[1], cryptauth::SecureChannel::Status::CONNECTING, 1212 {test_devices_[1], cryptauth::SecureChannel::Status::CONNECTING,
1212 cryptauth::SecureChannel::Status::DISCONNECTED}, 1213 cryptauth::SecureChannel::Status::DISCONNECTED},
1213 {test_devices_[2], cryptauth::SecureChannel::Status::CONNECTING, 1214 {test_devices_[2], cryptauth::SecureChannel::Status::CONNECTING,
1214 cryptauth::SecureChannel::Status::DISCONNECTED}}); 1215 cryptauth::SecureChannel::Status::DISCONNECTED}});
1215 } 1216 }
1216 1217
1217 } // namespace tether 1218 } // namespace tether
1218 1219
1219 } // namespace cryptauth 1220 } // namespace cryptauth
OLDNEW
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | chromeos/components/tether/ble_scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698