Internal change

PiperOrigin-RevId: 364353126
This commit is contained in:
hai007
2021-03-22 10:38:20 -07:00
committed by Copybara-Service
parent c648983d52
commit ae283c7cb6
14 changed files with 277 additions and 43 deletions
+4 -4
View File
@@ -65,6 +65,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
std::string fast_advertisement_service_uuid(kFastAdvertisementServiceUuid);
CountDownLatch found_latch(1);
CountDownLatch accepted_latch(1);
CancellationFlag flag;
BlePeripheral* discovered_peripheral = nullptr;
ble_a.StartScanning(
@@ -102,8 +103,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
{
SingleThreadExecutor client_executor;
client_executor.Execute(
[&ble_a, &socket_a, discovered_peripheral, &service_id]() {
CancellationFlag flag;
[&ble_a, &socket_a, discovered_peripheral, &service_id, &flag]() {
socket_a = ble_a.Connect(*discovered_peripheral, service_id, &flag);
});
}
@@ -127,6 +127,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
std::string fast_advertisement_service_uuid(kFastAdvertisementServiceUuid);
CountDownLatch found_latch(1);
CountDownLatch accepted_latch(1);
CancellationFlag flag(true);
BlePeripheral* discovered_peripheral = nullptr;
ble_a.StartScanning(
@@ -164,8 +165,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
{
SingleThreadExecutor client_executor;
client_executor.Execute(
[&ble_a, &socket_a, discovered_peripheral, &service_id]() {
CancellationFlag flag(true);
[&ble_a, &socket_a, discovered_peripheral, &service_id, &flag]() {
socket_a = ble_a.Connect(*discovered_peripheral, service_id, &flag);
});
}
+14 -14
View File
@@ -108,15 +108,15 @@ TEST_P(BluetoothClassicMediumTest, CanConnectToService) {
EXPECT_FALSE(socket_a.IsValid());
EXPECT_FALSE(socket_b.IsValid());
{
CancellationFlag flag;
SingleThreadExecutor server_executor;
SingleThreadExecutor client_executor;
client_executor.Execute(
[this, &socket_a, discovered_device, &service_uuid, &server_socket]() {
CancellationFlag flag;
socket_a =
bt_a_->ConnectToService(*discovered_device, service_uuid, &flag);
if (!socket_a.IsValid()) server_socket.Close();
});
client_executor.Execute([this, &socket_a, discovered_device, &service_uuid,
&server_socket, &flag]() {
socket_a =
bt_a_->ConnectToService(*discovered_device, service_uuid, &flag);
if (!socket_a.IsValid()) server_socket.Close();
});
server_executor.Execute([&socket_b, &server_socket]() {
socket_b = server_socket.Accept();
if (!socket_b.IsValid()) server_socket.Close();
@@ -157,15 +157,15 @@ TEST_P(BluetoothClassicMediumTest, CanCancelConnect) {
EXPECT_FALSE(socket_a.IsValid());
EXPECT_FALSE(socket_b.IsValid());
{
CancellationFlag flag(true);
SingleThreadExecutor server_executor;
SingleThreadExecutor client_executor;
client_executor.Execute(
[this, &socket_a, discovered_device, &service_uuid, &server_socket]() {
CancellationFlag flag(true);
socket_a =
bt_a_->ConnectToService(*discovered_device, service_uuid, &flag);
if (!socket_a.IsValid()) server_socket.Close();
});
client_executor.Execute([this, &socket_a, discovered_device, &service_uuid,
&server_socket, &flag]() {
socket_a =
bt_a_->ConnectToService(*discovered_device, service_uuid, &flag);
if (!socket_a.IsValid()) server_socket.Close();
});
server_executor.Execute([&socket_b, &server_socket]() {
socket_b = server_socket.Accept();
if (!socket_b.IsValid()) server_socket.Close();
+4 -5
View File
@@ -64,6 +64,7 @@ TEST_P(WifiLanMediumTest, CanStartAcceptingConnectionsAndConnect) {
std::string endpoint_info_name{kEndpointName};
CountDownLatch found_latch(1);
CountDownLatch accepted_latch(1);
CancellationFlag flag;
WifiLanService* discovered_service = nullptr;
wifi_a.StartDiscovery(
@@ -102,8 +103,7 @@ TEST_P(WifiLanMediumTest, CanStartAcceptingConnectionsAndConnect) {
{
SingleThreadExecutor client_executor;
client_executor.Execute(
[&wifi_a, &socket_a, discovered_service, &service_id]() {
CancellationFlag flag;
[&wifi_a, &socket_a, discovered_service, &service_id, &flag]() {
socket_a = wifi_a.Connect(*discovered_service, service_id, &flag);
});
}
@@ -126,6 +126,7 @@ TEST_P(WifiLanMediumTest, CanCancelConnect) {
std::string endpoint_info_name{kEndpointName};
CountDownLatch found_latch(1);
CountDownLatch accepted_latch(1);
CancellationFlag flag(true);
WifiLanService* discovered_service = nullptr;
wifi_a.StartDiscovery(
@@ -164,9 +165,7 @@ TEST_P(WifiLanMediumTest, CanCancelConnect) {
{
SingleThreadExecutor client_executor;
client_executor.Execute(
[&wifi_a, &socket_a, discovered_service, &service_id]() {
// Make it as Cancelled.
CancellationFlag flag(true);
[&wifi_a, &socket_a, discovered_service, &service_id, &flag]() {
socket_a = wifi_a.Connect(*discovered_service, service_id, &flag);
});
}