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

Unified Diff: chromeos/components/tether/ble_connection_manager_unittest.cc

Issue 2800883003: [CrOS Tether] Update SecureChannel and BleConnectionManager to use CryptAuthService instead of a Del (Closed)
Patch Set: Added BleConnectionManager refactor as well. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | components/cryptauth/fake_secure_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/components/tether/ble_connection_manager_unittest.cc
diff --git a/chromeos/components/tether/ble_connection_manager_unittest.cc b/chromeos/components/tether/ble_connection_manager_unittest.cc
index 6ce9b41a3ec45201bbea31425c6c59c92372823b..ca272cfaf57e759d0babfba6d186e5feebd0ab7a 100644
--- a/chromeos/components/tether/ble_connection_manager_unittest.cc
+++ b/chromeos/components/tether/ble_connection_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "components/cryptauth/bluetooth_throttler.h"
#include "components/cryptauth/connection.h"
#include "components/cryptauth/fake_connection.h"
+#include "components/cryptauth/fake_cryptauth_service.h"
#include "components/cryptauth/fake_secure_channel.h"
#include "components/cryptauth/fake_secure_message_delegate.h"
#include "components/cryptauth/remote_device_test_util.h"
@@ -37,28 +38,6 @@ const char kBluetoothAddress1[] = "11:22:33:44:55:66";
const char kBluetoothAddress2[] = "22:33:44:55:66:77";
const char kBluetoothAddress3[] = "33:44:55:66:77:88";
-class FakeSecureChannelDelegate : public cryptauth::SecureChannel::Delegate {
- public:
- FakeSecureChannelDelegate() {}
- ~FakeSecureChannelDelegate() override {}
-
- std::unique_ptr<cryptauth::SecureMessageDelegate>
- CreateSecureMessageDelegate() override {
- return base::MakeUnique<cryptauth::FakeSecureMessageDelegate>();
- }
-};
-
-class TestDelegate : public BleConnectionManager::Delegate {
- public:
- TestDelegate() {}
- ~TestDelegate() {}
-
- std::unique_ptr<cryptauth::SecureChannel::Delegate>
- CreateSecureChannelDelegate() override {
- return base::WrapUnique(new FakeSecureChannelDelegate());
- }
-};
-
struct SecureChannelStatusChange {
SecureChannelStatusChange(const cryptauth::RemoteDevice& remote_device,
const cryptauth::SecureChannel::Status& old_status,
@@ -209,11 +188,10 @@ class BleConnectionManagerTest : public testing::Test {
protected:
class FakeSecureChannel : public cryptauth::FakeSecureChannel {
public:
- FakeSecureChannel(
- std::unique_ptr<cryptauth::Connection> connection,
- std::unique_ptr<cryptauth::SecureChannel::Delegate> delegate)
+ FakeSecureChannel(std::unique_ptr<cryptauth::Connection> connection,
+ cryptauth::CryptAuthService* cryptauth_service)
: cryptauth::FakeSecureChannel(std::move(connection),
- std::move(delegate)) {}
+ cryptauth_service) {}
~FakeSecureChannel() override {}
void AddObserver(Observer* observer) override {
@@ -238,12 +216,12 @@ class BleConnectionManagerTest : public testing::Test {
std::unique_ptr<cryptauth::SecureChannel> BuildInstance(
std::unique_ptr<cryptauth::Connection> connection,
- std::unique_ptr<cryptauth::SecureChannel::Delegate> delegate) override {
+ cryptauth::CryptAuthService* cryptauth_service) override {
FakeConnectionWithAddress* fake_connection =
static_cast<FakeConnectionWithAddress*>(connection.get());
EXPECT_EQ(expected_device_address_, fake_connection->GetDeviceAddress());
return base::WrapUnique(
- new FakeSecureChannel(std::move(connection), std::move(delegate)));
+ new FakeSecureChannel(std::move(connection), cryptauth_service));
}
private:
@@ -268,7 +246,8 @@ class BleConnectionManagerTest : public testing::Test {
verified_status_changes_.clear();
verified_received_messages_.clear();
- delegate_ = new TestDelegate();
+ fake_cryptauth_service_ =
+ base::MakeUnique<cryptauth::FakeCryptAuthService>();
mock_adapter_ =
make_scoped_refptr(new NiceMock<device::MockBluetoothAdapter>());
@@ -300,7 +279,7 @@ class BleConnectionManagerTest : public testing::Test {
fake_secure_channel_factory_.get());
manager_ = base::WrapUnique(new BleConnectionManager(
- base::WrapUnique(delegate_), mock_adapter_,
+ fake_cryptauth_service_.get(), mock_adapter_,
base::WrapUnique(mock_ble_scanner_),
base::WrapUnique(mock_ble_advertiser_), base::WrapUnique(device_queue_),
base::WrapUnique(mock_timer_factory_),
@@ -483,7 +462,7 @@ class BleConnectionManagerTest : public testing::Test {
const std::vector<cryptauth::RemoteDevice> test_devices_;
- BleConnectionManager::Delegate* delegate_;
+ std::unique_ptr<cryptauth::FakeCryptAuthService> fake_cryptauth_service_;
scoped_refptr<NiceMock<device::MockBluetoothAdapter>> mock_adapter_;
MockBleScanner* mock_ble_scanner_;
MockBleAdvertiser* mock_ble_advertiser_;
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | components/cryptauth/fake_secure_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698