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

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

Issue 2915833003: Tether: Break helper TimerFactory out of BleConnectionManager and HostScanCache. (Closed)
Patch Set: Add missing files. Created 3 years, 6 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"
11 #include "chromeos/components/tether/timer_factory.h"
11 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection. h" 12 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection. h"
12 #include "components/cryptauth/bluetooth_throttler.h" 13 #include "components/cryptauth/bluetooth_throttler.h"
13 #include "components/cryptauth/connection.h" 14 #include "components/cryptauth/connection.h"
14 #include "components/cryptauth/fake_connection.h" 15 #include "components/cryptauth/fake_connection.h"
15 #include "components/cryptauth/fake_cryptauth_service.h" 16 #include "components/cryptauth/fake_cryptauth_service.h"
16 #include "components/cryptauth/fake_secure_channel.h" 17 #include "components/cryptauth/fake_secure_channel.h"
17 #include "components/cryptauth/fake_secure_message_delegate.h" 18 #include "components/cryptauth/fake_secure_message_delegate.h"
18 #include "components/cryptauth/remote_device_test_util.h" 19 #include "components/cryptauth/remote_device_test_util.h"
19 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 20 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 static_cast<FakeConnectionWithAddress*>(connection.get()); 223 static_cast<FakeConnectionWithAddress*>(connection.get());
223 EXPECT_EQ(expected_device_address_, fake_connection->GetDeviceAddress()); 224 EXPECT_EQ(expected_device_address_, fake_connection->GetDeviceAddress());
224 return base::WrapUnique( 225 return base::WrapUnique(
225 new FakeSecureChannel(std::move(connection), cryptauth_service)); 226 new FakeSecureChannel(std::move(connection), cryptauth_service));
226 } 227 }
227 228
228 private: 229 private:
229 std::string expected_device_address_; 230 std::string expected_device_address_;
230 }; 231 };
231 232
232 class MockTimerFactory : public BleConnectionManager::TimerFactory { 233 class MockTimerFactory : public TimerFactory {
khorimoto 2017/05/31 18:13:28 Move to anonymous namespace.
Ryan Hansberry 2017/05/31 18:24:54 Done.
233 public: 234 public:
234 std::unique_ptr<base::Timer> CreateTimer() override { 235 std::unique_ptr<base::Timer> CreateOneShotTimer() override {
235 return base::MakeUnique<base::MockTimer>(false /* retains_user_task */, 236 return base::MakeUnique<base::MockTimer>(false /* retains_user_task */,
236 false /* is_repeating */); 237 false /* is_repeating */);
237 } 238 }
238 }; 239 };
239 240
240 BleConnectionManagerTest() : test_devices_(CreateTestDevices(4)) { 241 BleConnectionManagerTest() : test_devices_(CreateTestDevices(4)) {
241 // These tests assume a maximum of two concurrent advertisers. Some of the 242 // These tests assume a maximum of two concurrent advertisers. Some of the
242 // multi-device tests would need to be re-written if this constant changes. 243 // multi-device tests would need to be re-written if this constant changes.
243 EXPECT_EQ(2, kMaxConcurrentAdvertisements); 244 EXPECT_EQ(2, kMaxConcurrentAdvertisements);
244 } 245 }
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 cryptauth::SecureChannel::Status::DISCONNECTED}, 1212 cryptauth::SecureChannel::Status::DISCONNECTED},
1212 {test_devices_[1], cryptauth::SecureChannel::Status::CONNECTING, 1213 {test_devices_[1], cryptauth::SecureChannel::Status::CONNECTING,
1213 cryptauth::SecureChannel::Status::DISCONNECTED}, 1214 cryptauth::SecureChannel::Status::DISCONNECTED},
1214 {test_devices_[2], cryptauth::SecureChannel::Status::CONNECTING, 1215 {test_devices_[2], cryptauth::SecureChannel::Status::CONNECTING,
1215 cryptauth::SecureChannel::Status::DISCONNECTED}}); 1216 cryptauth::SecureChannel::Status::DISCONNECTED}});
1216 } 1217 }
1217 1218
1218 } // namespace tether 1219 } // namespace tether
1219 1220
1220 } // namespace cryptauth 1221 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698