mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Migrate to AnyInvocable in platform code
PiperOrigin-RevId: 504104740
This commit is contained in:
committed by
Copybara-Service
parent
7f34968b78
commit
f4d85f9b90
@@ -229,8 +229,7 @@ TEST(BleMedium, DISABLED_StartAdvertising_ExtendedAdvertising) {
|
||||
|
||||
ByteArray advertising_data(advertising_data_byte_array);
|
||||
|
||||
EXPECT_TRUE(
|
||||
ble_medium.StartAdvertising("NearbyShare", advertising_data, ""));
|
||||
EXPECT_TRUE(ble_medium.StartAdvertising("NearbyShare", advertising_data, ""));
|
||||
}
|
||||
|
||||
TEST(BleMedium, DISABLED_StopAdvertising) {
|
||||
@@ -254,35 +253,30 @@ TEST(BleMedium, DISABLED_StartScanning) {
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
bool fast_advertisement) {},
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
bool fast_advertisement) {},
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
}
|
||||
|
||||
TEST(BleMedium, DISABLED_ReceiveAdvertisement) {
|
||||
absl::Notification advertisement_received_notification;
|
||||
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb =
|
||||
[this, &advertisement_received_notification](
|
||||
api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) {
|
||||
advertisement_received_notification.Notify();
|
||||
},
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb =
|
||||
[&](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) {
|
||||
advertisement_received_notification.Notify();
|
||||
},
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(
|
||||
advertisement_received_notification.WaitForNotificationWithTimeout(
|
||||
absl::Seconds(5)));
|
||||
@@ -292,15 +286,14 @@ TEST(BleMedium, DISABLED_StopScanning) {
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb =
|
||||
[this](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) { EXPECT_TRUE(fast_advertisement); },
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb =
|
||||
[](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) { EXPECT_TRUE(fast_advertisement); },
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(ble_medium.StopScanning("NearbyShare"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user