#include "device/bluetooth/test/bluetooth_test_bluez.h"
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "dbus/object_path.h"
#include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
#include "device/bluetooth/bluez/bluetooth_device_bluez.h"
#include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h"
#include "device/bluetooth/bluez/bluetooth_gatt_descriptor_bluez.h"
#include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h"
#include "device/bluetooth/bluez/bluetooth_local_gatt_descriptor_bluez.h"
#include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h"
#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h"
#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h"
#include "device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h"
namespace device {
namespace {
void GetValueCallback(
base::OnceClosure quit_closure,
BluetoothLocalGattService::Delegate::ValueCallback value_callback,
std::optional<BluetoothGattService::GattErrorCode> error_code,
const std::vector<uint8_t>& value) { … }
void ClosureCallback(base::OnceClosure quit_closure,
base::OnceClosure callback) { … }
dbus::ObjectPath GetDevicePath(BluetoothDevice* device) { … }
}
BluetoothTestBlueZ::BluetoothTestBlueZ()
: … { … }
BluetoothTestBlueZ::~BluetoothTestBlueZ() = default;
void BluetoothTestBlueZ::SetUp() { … }
void BluetoothTestBlueZ::TearDown() { … }
bool BluetoothTestBlueZ::PlatformSupportsLowEnergy() { … }
void BluetoothTestBlueZ::InitWithFakeAdapter() { … }
BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice(
int device_ordinal) { … }
BluetoothDevice* BluetoothTestBlueZ::SimulateClassicDevice() { … }
void BluetoothTestBlueZ::SimulateLocalGattCharacteristicValueReadRequest(
BluetoothDevice* from_device,
BluetoothLocalGattCharacteristic* characteristic,
BluetoothLocalGattService::Delegate::ValueCallback value_callback) { … }
void BluetoothTestBlueZ::SimulateLocalGattCharacteristicValueWriteRequest(
BluetoothDevice* from_device,
BluetoothLocalGattCharacteristic* characteristic,
const std::vector<uint8_t>& value_to_write,
base::OnceClosure success_callback,
base::OnceClosure error_callback) { … }
void BluetoothTestBlueZ::
SimulateLocalGattCharacteristicValuePrepareWriteRequest(
BluetoothDevice* from_device,
BluetoothLocalGattCharacteristic* characteristic,
const std::vector<uint8_t>& value_to_write,
int offset,
bool has_subsequent_write,
base::OnceClosure success_callback,
base::OnceClosure error_callback) { … }
void BluetoothTestBlueZ::SimulateLocalGattDescriptorValueReadRequest(
BluetoothDevice* from_device,
BluetoothLocalGattDescriptor* descriptor,
BluetoothLocalGattService::Delegate::ValueCallback value_callback) { … }
void BluetoothTestBlueZ::SimulateLocalGattDescriptorValueWriteRequest(
BluetoothDevice* from_device,
BluetoothLocalGattDescriptor* descriptor,
const std::vector<uint8_t>& value_to_write,
base::OnceClosure success_callback,
base::OnceClosure error_callback) { … }
bool BluetoothTestBlueZ::SimulateLocalGattCharacteristicNotificationsRequest(
BluetoothDevice* from_device,
BluetoothLocalGattCharacteristic* characteristic,
bool start) { … }
std::vector<uint8_t> BluetoothTestBlueZ::LastNotifactionValueForCharacteristic(
BluetoothLocalGattCharacteristic* characteristic) { … }
std::vector<BluetoothLocalGattService*>
BluetoothTestBlueZ::RegisteredGattServices() { … }
}