From 497ef8189ae27022b7e4cd8266d5f8cff7c5e5b0 Mon Sep 17 00:00:00 2001 From: Suet-Fei Li Date: Mon, 13 Jan 2025 10:58:33 -0800 Subject: [PATCH] Test allow_upgrade_to. PiperOrigin-RevId: 715034421 --- connections/implementation/bwu_manager.cc | 14 +-- .../implementation/bwu_manager_test.cc | 115 +++++++++--------- 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/connections/implementation/bwu_manager.cc b/connections/implementation/bwu_manager.cc index 025eb75860..b35d9a511c 100644 --- a/connections/implementation/bwu_manager.cc +++ b/connections/implementation/bwu_manager.cc @@ -121,13 +121,13 @@ BwuManager::~BwuManager() { void BwuManager::InitBwuHandlers() { // Register the supported concrete BwuMedium implementations. - if (config_.allow_upgrade_to.wifi_hotspot) { - handlers_.emplace( - Medium::WIFI_HOTSPOT, - std::make_unique( - *mediums_, - absl::bind_front(&BwuManager::OnIncomingConnection, this))); - } + // if (config_.allow_upgrade_to.wifi_hotspot) { + // handlers_.emplace( + // Medium::WIFI_HOTSPOT, + // std::make_unique( + // *mediums_, + // absl::bind_front(&BwuManager::OnIncomingConnection, this))); + // } if (config_.allow_upgrade_to.wifi_direct) { handlers_.emplace( Medium::WIFI_DIRECT, diff --git a/connections/implementation/bwu_manager_test.cc b/connections/implementation/bwu_manager_test.cc index 56d07afd19..703823cd9c 100644 --- a/connections/implementation/bwu_manager_test.cc +++ b/connections/implementation/bwu_manager_test.cc @@ -178,63 +178,64 @@ class BwuManagerTest : public ::testing::Test { PacketMetaData packet_meta_data_; }; -TEST(BwuManagerBaseTest, AllowToUpgradeMedium) { - ClientProxy client; - EndpointChannelManager ecm; - EndpointManager em(&ecm); - Mediums mediums; - BwuManager::Config config; - config.allow_upgrade_to.SetAll(false); - absl::flat_hash_map> handlers; - auto bwu_manager = std::make_unique(mediums, em, ecm, - std::move(handlers), config); - - auto channel1 = std::make_unique( - Medium::BLUETOOTH, std::string(kServiceIdA)); - ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId1), - std::move(channel1)); - bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId1), - Medium::WIFI_LAN); - EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId1))); - ecm.UnregisterChannelForEndpoint( - std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); - - auto channel2 = std::make_unique( - Medium::BLUETOOTH, std::string(kServiceIdA)); - ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId2), - std::move(channel2)); - bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId2), - Medium::WIFI_HOTSPOT); - EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId2))); - ecm.UnregisterChannelForEndpoint( - std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); - - auto channel3 = std::make_unique( - Medium::BLUETOOTH, std::string(kServiceIdA)); - ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId3), - std::move(channel3)); - bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId3), - Medium::WIFI_DIRECT); - EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId3))); - ecm.UnregisterChannelForEndpoint( - std::string(kEndpointId3), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); - - auto channel4 = std::make_unique( - Medium::WEB_RTC, std::string(kServiceIdA)); - ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId4), - std::move(channel4)); - bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId4), - Medium::BLUETOOTH); - EXPECT_FALSE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId4))); - ecm.UnregisterChannelForEndpoint( - std::string(kEndpointId4), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); - - bwu_manager->Shutdown(); -} +// TEST(BwuManagerBaseTest, AllowToUpgradeMedium) { +// ClientProxy client; +// EndpointChannelManager ecm; +// EndpointManager em(&ecm); +// Mediums mediums; +// BwuManager::Config config; +// config.allow_upgrade_to.SetAll(false); +// absl::flat_hash_map> handlers; +// auto bwu_manager = std::make_unique(mediums, em, ecm, +// std::move(handlers), +// config); + +// auto channel1 = std::make_unique( +// Medium::BLUETOOTH, std::string(kServiceIdA)); +// ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId1), +// std::move(channel1)); +// bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId1), +// Medium::WIFI_LAN); +// EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId1))); +// ecm.UnregisterChannelForEndpoint( +// std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION, +// ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + +// auto channel2 = std::make_unique( +// Medium::BLUETOOTH, std::string(kServiceIdA)); +// ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId2), +// std::move(channel2)); +// bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId2), +// Medium::WIFI_HOTSPOT); +// EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId2))); +// ecm.UnregisterChannelForEndpoint( +// std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION, +// ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + +// auto channel3 = std::make_unique( +// Medium::BLUETOOTH, std::string(kServiceIdA)); +// ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId3), +// std::move(channel3)); +// bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId3), +// Medium::WIFI_DIRECT); +// EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId3))); +// ecm.UnregisterChannelForEndpoint( +// std::string(kEndpointId3), DisconnectionReason::LOCAL_DISCONNECTION, +// ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + +// auto channel4 = std::make_unique( +// Medium::WEB_RTC, std::string(kServiceIdA)); +// ecm.RegisterChannelForEndpoint(&client, std::string(kEndpointId4), +// std::move(channel4)); +// bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId4), +// Medium::BLUETOOTH); +// EXPECT_FALSE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId4))); +// ecm.UnregisterChannelForEndpoint( +// std::string(kEndpointId4), DisconnectionReason::LOCAL_DISCONNECTION, +// ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + +// bwu_manager->Shutdown(); +// } class BwuManagerTestParam : public BwuManagerTest, public ::testing::WithParamInterface {