Commit eacb27f8 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Instant Tethering: Remove kMultiDeviceApi flagging from ConnectionPreserverImpl.

R=hansberry@chromium.org

Bug: 903991
Test: none
Change-Id: I37428a83f128c03d95d4eb16d6b36fc8c9a272a5
Reviewed-on: https://chromium-review.googlesource.com/c/1333110
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607488}
parent 262e5e79
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
#include "chromeos/components/tether/connection_preserver_impl.h" #include "chromeos/components/tether/connection_preserver_impl.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chromeos/chromeos_features.h"
#include "chromeos/components/proximity_auth/logging/logging.h" #include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/components/tether/ble_connection_manager.h"
#include "chromeos/components/tether/tether_host_response_recorder.h" #include "chromeos/components/tether/tether_host_response_recorder.h"
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
...@@ -27,17 +25,14 @@ const char kTetherFeature[] = "magic_tether"; ...@@ -27,17 +25,14 @@ const char kTetherFeature[] = "magic_tether";
ConnectionPreserverImpl::ConnectionPreserverImpl( ConnectionPreserverImpl::ConnectionPreserverImpl(
device_sync::DeviceSyncClient* device_sync_client, device_sync::DeviceSyncClient* device_sync_client,
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
BleConnectionManager* ble_connection_manager,
NetworkStateHandler* network_state_handler, NetworkStateHandler* network_state_handler,
ActiveHost* active_host, ActiveHost* active_host,
TetherHostResponseRecorder* tether_host_response_recorder) TetherHostResponseRecorder* tether_host_response_recorder)
: device_sync_client_(device_sync_client), : device_sync_client_(device_sync_client),
secure_channel_client_(secure_channel_client), secure_channel_client_(secure_channel_client),
ble_connection_manager_(ble_connection_manager),
network_state_handler_(network_state_handler), network_state_handler_(network_state_handler),
active_host_(active_host), active_host_(active_host),
tether_host_response_recorder_(tether_host_response_recorder), tether_host_response_recorder_(tether_host_response_recorder),
request_id_(base::UnguessableToken::Create()),
preserved_connection_timer_(std::make_unique<base::OneShotTimer>()), preserved_connection_timer_(std::make_unique<base::OneShotTimer>()),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
active_host_->AddObserver(this); active_host_->AddObserver(this);
...@@ -84,7 +79,6 @@ void ConnectionPreserverImpl::HandleSuccessfulTetherAvailabilityResponse( ...@@ -84,7 +79,6 @@ void ConnectionPreserverImpl::HandleSuccessfulTetherAvailabilityResponse(
void ConnectionPreserverImpl::OnConnectionAttemptFailure( void ConnectionPreserverImpl::OnConnectionAttemptFailure(
secure_channel::mojom::ConnectionAttemptFailureReason reason) { secure_channel::mojom::ConnectionAttemptFailureReason reason) {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
PA_LOG(WARNING) << "Failed to connect to device " PA_LOG(WARNING) << "Failed to connect to device "
<< cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs( << cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs(
preserved_connection_device_id_) preserved_connection_device_id_)
...@@ -94,7 +88,6 @@ void ConnectionPreserverImpl::OnConnectionAttemptFailure( ...@@ -94,7 +88,6 @@ void ConnectionPreserverImpl::OnConnectionAttemptFailure(
void ConnectionPreserverImpl::OnConnection( void ConnectionPreserverImpl::OnConnection(
std::unique_ptr<secure_channel::ClientChannel> channel) { std::unique_ptr<secure_channel::ClientChannel> channel) {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
PA_LOG(VERBOSE) << "Successfully preserved connection for device: " PA_LOG(VERBOSE) << "Successfully preserved connection for device: "
<< cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs( << cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs(
preserved_connection_device_id_); preserved_connection_device_id_);
...@@ -105,7 +98,6 @@ void ConnectionPreserverImpl::OnConnection( ...@@ -105,7 +98,6 @@ void ConnectionPreserverImpl::OnConnection(
} }
void ConnectionPreserverImpl::OnDisconnected() { void ConnectionPreserverImpl::OnDisconnected() {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
PA_LOG(VERBOSE) << "Remote device disconnected from this device: " PA_LOG(VERBOSE) << "Remote device disconnected from this device: "
<< cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs( << cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs(
preserved_connection_device_id_); preserved_connection_device_id_);
...@@ -171,7 +163,6 @@ void ConnectionPreserverImpl::SetPreservedConnection( ...@@ -171,7 +163,6 @@ void ConnectionPreserverImpl::SetPreservedConnection(
preserved_connection_device_id_ = device_id; preserved_connection_device_id_ = device_id;
if (base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
base::Optional<cryptauth::RemoteDeviceRef> remote_device = base::Optional<cryptauth::RemoteDeviceRef> remote_device =
GetRemoteDevice(preserved_connection_device_id_); GetRemoteDevice(preserved_connection_device_id_);
if (!remote_device) { if (!remote_device) {
...@@ -186,11 +177,6 @@ void ConnectionPreserverImpl::SetPreservedConnection( ...@@ -186,11 +177,6 @@ void ConnectionPreserverImpl::SetPreservedConnection(
*remote_device, *device_sync_client_->GetLocalDeviceMetadata(), *remote_device, *device_sync_client_->GetLocalDeviceMetadata(),
kTetherFeature, secure_channel::ConnectionPriority::kLow); kTetherFeature, secure_channel::ConnectionPriority::kLow);
connection_attempt_->SetDelegate(this); connection_attempt_->SetDelegate(this);
} else {
ble_connection_manager_->RegisterRemoteDevice(
preserved_connection_device_id_, request_id_,
secure_channel::ConnectionPriority::kLow);
}
preserved_connection_timer_->Start( preserved_connection_timer_->Start(
FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutSeconds), FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutSeconds),
...@@ -207,13 +193,8 @@ void ConnectionPreserverImpl::RemovePreservedConnectionIfPresent() { ...@@ -207,13 +193,8 @@ void ConnectionPreserverImpl::RemovePreservedConnectionIfPresent() {
preserved_connection_device_id_) preserved_connection_device_id_)
<< "."; << ".";
if (base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
connection_attempt_.reset(); connection_attempt_.reset();
client_channel_.reset(); client_channel_.reset();
} else {
ble_connection_manager_->UnregisterRemoteDevice(
preserved_connection_device_id_, request_id_);
}
preserved_connection_device_id_.clear(); preserved_connection_device_id_.clear();
preserved_connection_timer_->Stop(); preserved_connection_timer_->Stop();
...@@ -221,7 +202,6 @@ void ConnectionPreserverImpl::RemovePreservedConnectionIfPresent() { ...@@ -221,7 +202,6 @@ void ConnectionPreserverImpl::RemovePreservedConnectionIfPresent() {
base::Optional<cryptauth::RemoteDeviceRef> base::Optional<cryptauth::RemoteDeviceRef>
ConnectionPreserverImpl::GetRemoteDevice(const std::string device_id) { ConnectionPreserverImpl::GetRemoteDevice(const std::string device_id) {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
for (const auto& remote_device : device_sync_client_->GetSyncedDevices()) { for (const auto& remote_device : device_sync_client_->GetSyncedDevices()) {
if (remote_device.GetDeviceId() == device_id) if (remote_device.GetDeviceId() == device_id)
return remote_device; return remote_device;
......
...@@ -24,7 +24,6 @@ class NetworkStateHandler; ...@@ -24,7 +24,6 @@ class NetworkStateHandler;
namespace tether { namespace tether {
class BleConnectionManager;
class SecureChannelClient; class SecureChannelClient;
class TetherHostResponseRecorder; class TetherHostResponseRecorder;
...@@ -44,7 +43,6 @@ class ConnectionPreserverImpl ...@@ -44,7 +43,6 @@ class ConnectionPreserverImpl
ConnectionPreserverImpl( ConnectionPreserverImpl(
device_sync::DeviceSyncClient* device_sync_client, device_sync::DeviceSyncClient* device_sync_client,
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
BleConnectionManager* ble_connection_manager,
NetworkStateHandler* network_state_handler, NetworkStateHandler* network_state_handler,
ActiveHost* active_host, ActiveHost* active_host,
TetherHostResponseRecorder* tether_host_response_recorder); TetherHostResponseRecorder* tether_host_response_recorder);
...@@ -86,11 +84,9 @@ class ConnectionPreserverImpl ...@@ -86,11 +84,9 @@ class ConnectionPreserverImpl
device_sync::DeviceSyncClient* device_sync_client_; device_sync::DeviceSyncClient* device_sync_client_;
secure_channel::SecureChannelClient* secure_channel_client_; secure_channel::SecureChannelClient* secure_channel_client_;
BleConnectionManager* ble_connection_manager_;
NetworkStateHandler* network_state_handler_; NetworkStateHandler* network_state_handler_;
ActiveHost* active_host_; ActiveHost* active_host_;
TetherHostResponseRecorder* tether_host_response_recorder_; TetherHostResponseRecorder* tether_host_response_recorder_;
const base::UnguessableToken request_id_;
std::unique_ptr<base::OneShotTimer> preserved_connection_timer_; std::unique_ptr<base::OneShotTimer> preserved_connection_timer_;
......
...@@ -8,12 +8,9 @@ ...@@ -8,12 +8,9 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "base/timer/mock_timer.h" #include "base/timer/mock_timer.h"
#include "chromeos/chromeos_features.h"
#include "chromeos/components/tether/fake_active_host.h" #include "chromeos/components/tether/fake_active_host.h"
#include "chromeos/components/tether/fake_ble_connection_manager.h"
#include "chromeos/components/tether/mock_tether_host_response_recorder.h" #include "chromeos/components/tether/mock_tether_host_response_recorder.h"
#include "chromeos/components/tether/timer_factory.h" #include "chromeos/components/tether/timer_factory.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
...@@ -80,8 +77,6 @@ class ConnectionPreserverImplTest : public NetworkStateTest { ...@@ -80,8 +77,6 @@ class ConnectionPreserverImplTest : public NetworkStateTest {
fake_secure_channel_client_ = fake_secure_channel_client_ =
std::make_unique<secure_channel::FakeSecureChannelClient>(); std::make_unique<secure_channel::FakeSecureChannelClient>();
fake_ble_connection_manager_ = std::make_unique<FakeBleConnectionManager>();
fake_active_host_ = std::make_unique<FakeActiveHost>(); fake_active_host_ = std::make_unique<FakeActiveHost>();
previously_connected_host_ids_.clear(); previously_connected_host_ids_.clear();
...@@ -94,8 +89,8 @@ class ConnectionPreserverImplTest : public NetworkStateTest { ...@@ -94,8 +89,8 @@ class ConnectionPreserverImplTest : public NetworkStateTest {
connection_preserver_ = std::make_unique<ConnectionPreserverImpl>( connection_preserver_ = std::make_unique<ConnectionPreserverImpl>(
fake_device_sync_client_.get(), fake_secure_channel_client_.get(), fake_device_sync_client_.get(), fake_secure_channel_client_.get(),
fake_ble_connection_manager_.get(), network_state_handler(), network_state_handler(), fake_active_host_.get(),
fake_active_host_.get(), mock_tether_host_response_recorder_.get()); mock_tether_host_response_recorder_.get());
mock_timer_ = new base::MockOneShotTimer(); mock_timer_ = new base::MockOneShotTimer();
connection_preserver_->SetTimerForTesting(base::WrapUnique(mock_timer_)); connection_preserver_->SetTimerForTesting(base::WrapUnique(mock_timer_));
...@@ -109,42 +104,8 @@ class ConnectionPreserverImplTest : public NetworkStateTest { ...@@ -109,42 +104,8 @@ class ConnectionPreserverImplTest : public NetworkStateTest {
DBusThreadManager::Shutdown(); DBusThreadManager::Shutdown();
} }
void SetMultiDeviceApi(bool enabled) { void SimulateSuccessfulHostScan(cryptauth::RemoteDeviceRef remote_device,
static const std::vector<base::Feature> kFeatures{
chromeos::features::kMultiDeviceApi,
chromeos::features::kEnableUnifiedMultiDeviceSetup};
scoped_feature_list_.InitWithFeatures(
(enabled ? kFeatures
: std::vector<base::Feature>() /* enable_features */),
(enabled ? std::vector<base::Feature>()
: kFeatures /* disable_features */));
}
void SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
const std::string& device_id,
bool should_remain_registered) {
DCHECK(!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
base::UnguessableToken request_id = base::UnguessableToken::Create();
fake_ble_connection_manager_->RegisterRemoteDevice(
device_id, request_id, secure_channel::ConnectionPriority::kLow);
EXPECT_TRUE(fake_ble_connection_manager_->IsRegistered(device_id));
connection_preserver_->HandleSuccessfulTetherAvailabilityResponse(
device_id);
EXPECT_TRUE(fake_ble_connection_manager_->IsRegistered(device_id));
fake_ble_connection_manager_->UnregisterRemoteDevice(device_id, request_id);
EXPECT_EQ(should_remain_registered,
fake_ble_connection_manager_->IsRegistered(device_id));
}
void SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
cryptauth::RemoteDeviceRef remote_device,
bool should_remain_registered) { bool should_remain_registered) {
DCHECK(base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi));
// |connection_preserver_| should only grab |fake_connection_attempt| if // |connection_preserver_| should only grab |fake_connection_attempt| if
// it is intended to keep the connection open. // it is intended to keep the connection open.
auto fake_connection_attempt = auto fake_connection_attempt =
...@@ -229,7 +190,6 @@ class ConnectionPreserverImplTest : public NetworkStateTest { ...@@ -229,7 +190,6 @@ class ConnectionPreserverImplTest : public NetworkStateTest {
std::unique_ptr<device_sync::FakeDeviceSyncClient> fake_device_sync_client_; std::unique_ptr<device_sync::FakeDeviceSyncClient> fake_device_sync_client_;
std::unique_ptr<secure_channel::FakeSecureChannelClient> std::unique_ptr<secure_channel::FakeSecureChannelClient>
fake_secure_channel_client_; fake_secure_channel_client_;
std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_;
std::unique_ptr<FakeActiveHost> fake_active_host_; std::unique_ptr<FakeActiveHost> fake_active_host_;
std::unique_ptr<NiceMock<MockTetherHostResponseRecorder>> std::unique_ptr<NiceMock<MockTetherHostResponseRecorder>>
mock_tether_host_response_recorder_; mock_tether_host_response_recorder_;
...@@ -240,71 +200,33 @@ class ConnectionPreserverImplTest : public NetworkStateTest { ...@@ -240,71 +200,33 @@ class ConnectionPreserverImplTest : public NetworkStateTest {
std::vector<std::string> previously_connected_host_ids_; std::vector<std::string> previously_connected_host_ids_;
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(ConnectionPreserverImplTest); DISALLOW_COPY_AND_ASSIGN(ConnectionPreserverImplTest);
}; };
TEST_F(ConnectionPreserverImplTest, TEST_F(ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_NoPreservedConnection) { TestHandleSuccessfulTetherAvailabilityResponse_NoPreservedConnection) {
SetMultiDeviceApi(false /* enabled */); SimulateSuccessfulHostScan(test_remote_devices_[0],
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( true /* should_remain_registered */);
test_remote_device_ids_[0], true /* should_remain_registered */);
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_NoPreservedConnection_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], true /* should_remain_registered */);
} }
TEST_F(ConnectionPreserverImplTest, TEST_F(ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_HasInternet) { TestHandleSuccessfulTetherAvailabilityResponse_HasInternet) {
SetMultiDeviceApi(false /* enabled */);
ConnectToWifi(); ConnectToWifi();
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( SimulateSuccessfulHostScan(test_remote_devices_[0],
test_remote_device_ids_[0], false /* should_remain_registered */); false /* should_remain_registered */);
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_HasInternet_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
ConnectToWifi();
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], false /* should_remain_registered */);
} }
TEST_F( TEST_F(
ConnectionPreserverImplTest, ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreservedConnectionExists_NoPreviouslyConnectedHosts) { TestHandleSuccessfulTetherAvailabilityResponse_PreservedConnectionExists_NoPreviouslyConnectedHosts) {
SetMultiDeviceApi(false /* enabled */); SimulateSuccessfulHostScan(test_remote_devices_[0],
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( true /* should_remain_registered */);
test_remote_device_ids_[0], true /* should_remain_registered */);
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[1], true /* should_remain_registered */);
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreservedConnectionExists_NoPreviouslyConnectedHosts_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], true /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
false /* expect_destroyed */); false /* expect_destroyed */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[1],
test_remote_devices_[1], true /* should_remain_registered */); true /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
true /* expect_destroyed */); true /* expect_destroyed */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1],
...@@ -313,22 +235,8 @@ TEST_F( ...@@ -313,22 +235,8 @@ TEST_F(
TEST_F(ConnectionPreserverImplTest, TEST_F(ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_TimesOut) { TestHandleSuccessfulTetherAvailabilityResponse_TimesOut) {
SetMultiDeviceApi(false /* enabled */); SimulateSuccessfulHostScan(test_remote_devices_[0],
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( true /* should_remain_registered */);
test_remote_device_ids_[0], true /* should_remain_registered */);
mock_timer_->Fire();
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_TimesOut_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], true /* should_remain_registered */);
mock_timer_->Fire(); mock_timer_->Fire();
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
...@@ -337,22 +245,8 @@ TEST_F( ...@@ -337,22 +245,8 @@ TEST_F(
TEST_F(ConnectionPreserverImplTest, TEST_F(ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreserverDestroyed) { TestHandleSuccessfulTetherAvailabilityResponse_PreserverDestroyed) {
SetMultiDeviceApi(false /* enabled */); SimulateSuccessfulHostScan(test_remote_devices_[0],
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( true /* should_remain_registered */);
test_remote_device_ids_[0], true /* should_remain_registered */);
connection_preserver_.reset();
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreserverDestroyed_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], true /* should_remain_registered */);
connection_preserver_.reset(); connection_preserver_.reset();
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
...@@ -362,25 +256,8 @@ TEST_F( ...@@ -362,25 +256,8 @@ TEST_F(
TEST_F( TEST_F(
ConnectionPreserverImplTest, ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_ActiveHostBecomesConnected) { TestHandleSuccessfulTetherAvailabilityResponse_ActiveHostBecomesConnected) {
SetMultiDeviceApi(false /* enabled */); SimulateSuccessfulHostScan(test_remote_devices_[0],
SimulateSuccessfulHostScan_MultiDeviceApiDisabled( true /* should_remain_registered */);
test_remote_device_ids_[0], true /* should_remain_registered */);
fake_active_host_->SetActiveHostConnecting(test_remote_device_ids_[0],
kTetherNetworkGuid);
fake_active_host_->SetActiveHostConnected(
test_remote_device_ids_[0], kTetherNetworkGuid, kWifiNetworkGuid);
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_ActiveHostBecomesConnected_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled(
test_remote_devices_[0], true /* should_remain_registered */);
fake_active_host_->SetActiveHostConnecting(test_remote_device_ids_[0], fake_active_host_->SetActiveHostConnecting(test_remote_device_ids_[0],
kTetherNetworkGuid); kTetherNetworkGuid);
...@@ -394,73 +271,37 @@ TEST_F( ...@@ -394,73 +271,37 @@ TEST_F(
TEST_F( TEST_F(
ConnectionPreserverImplTest, ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreviouslyConnectedHostsExist) { TestHandleSuccessfulTetherAvailabilityResponse_PreviouslyConnectedHostsExist) {
SetMultiDeviceApi(false /* enabled */);
// |test_remote_device_ids_[0]| is the most recently connected device, and
// should be preferred over any other device.
previously_connected_host_ids_.push_back(test_remote_device_ids_[0]);
previously_connected_host_ids_.push_back(test_remote_device_ids_[1]);
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[2], true /* should_remain_registered */);
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[1], true /* should_remain_registered */);
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[2]));
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[0], true /* should_remain_registered */);
EXPECT_FALSE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[1]));
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[1], false /* should_remain_registered */);
EXPECT_TRUE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
SimulateSuccessfulHostScan_MultiDeviceApiDisabled(
test_remote_device_ids_[2], false /* should_remain_registered */);
EXPECT_TRUE(
fake_ble_connection_manager_->IsRegistered(test_remote_device_ids_[0]));
}
TEST_F(
ConnectionPreserverImplTest,
TestHandleSuccessfulTetherAvailabilityResponse_PreviouslyConnectedHostsExist_MultiDeviceApiEnabled) {
SetMultiDeviceApi(true /* enabled */);
// |test_remote_device_ids_[0]| is the most recently connected device, and // |test_remote_device_ids_[0]| is the most recently connected device, and
// should be preferred over any other device. // should be preferred over any other device.
previously_connected_host_ids_.push_back(test_remote_device_ids_[0]); previously_connected_host_ids_.push_back(test_remote_device_ids_[0]);
previously_connected_host_ids_.push_back(test_remote_device_ids_[1]); previously_connected_host_ids_.push_back(test_remote_device_ids_[1]);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[2],
test_remote_devices_[2], true /* should_remain_registered */); true /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[2], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[2],
false /* expect_destroyed */); false /* expect_destroyed */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[1],
test_remote_devices_[1], true /* should_remain_registered */); true /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[2], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[2],
true /* expect_destroyed */); true /* expect_destroyed */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1],
false /* expect_destroyed */); false /* expect_destroyed */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[0],
test_remote_devices_[0], true /* should_remain_registered */); true /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[1],
true /* expect_destroyed */); true /* expect_destroyed */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
false /* expect_destroyed */); false /* expect_destroyed */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[1],
test_remote_devices_[1], false /* should_remain_registered */); false /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
false /* expect_destroyed */); false /* expect_destroyed */);
SimulateSuccessfulHostScan_MultiDeviceApiEnabled( SimulateSuccessfulHostScan(test_remote_devices_[2],
test_remote_devices_[2], false /* should_remain_registered */); false /* should_remain_registered */);
VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0], VerifyChannelForRemoteDeviceDestroyed(test_remote_devices_[0],
false /* expect_destroyed */); false /* expect_destroyed */);
} }
......
...@@ -154,7 +154,6 @@ SynchronousShutdownObjectContainerImpl::SynchronousShutdownObjectContainerImpl( ...@@ -154,7 +154,6 @@ SynchronousShutdownObjectContainerImpl::SynchronousShutdownObjectContainerImpl(
connection_preserver_(std::make_unique<ConnectionPreserverImpl>( connection_preserver_(std::make_unique<ConnectionPreserverImpl>(
device_sync_client, device_sync_client,
secure_channel_client, secure_channel_client,
asychronous_container->ble_connection_manager(),
network_state_handler_, network_state_handler_,
active_host_.get(), active_host_.get(),
tether_host_response_recorder_.get())), tether_host_response_recorder_.get())),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment