Fixed one GATT crash

PiperOrigin-RevId: 657684638
This commit is contained in:
Guogang Li
2024-07-30 12:13:51 -07:00
committed by Copybara-Service
parent 68d432c5a8
commit 4d457d134b
5 changed files with 162 additions and 96 deletions
@@ -14,10 +14,13 @@
#include "internal/platform/implementation/windows/ble_gatt_server.h"
#include <functional>
#include <string>
#include <utility>
#include "gtest/gtest.h"
#include "absl/synchronization/notification.h"
#include "absl/time/time.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/windows/bluetooth_adapter.h"
@@ -44,6 +47,23 @@ TEST(BleV2GattServer, DISABLED_Stop) {
blev2_gatt_server.Stop();
}
TEST(BleV2GattServer, DISABLED_StopNotifierIsCalled) {
BluetoothAdapter bluetoothAdapter;
BleGattServer blev2_gatt_server(&bluetoothAdapter, {});
bool is_close_notifier_called = false;
absl::Notification notification;
std::function<void()> notifier = [&is_close_notifier_called,
&notification]() {
is_close_notifier_called = true;
notification.Notify();
};
blev2_gatt_server.SetCloseNotifier(std::move(notifier));
blev2_gatt_server.Stop();
notification.WaitForNotificationWithTimeout(absl::Seconds(1));
EXPECT_TRUE(is_close_notifier_called);
}
TEST(BleV2GattServer, DISABLED_CreateCharacteristic) {
BluetoothAdapter bluetoothAdapter;
BleGattServer blev2_gatt_server(&bluetoothAdapter, {});