chromium/content/web_test/browser/web_test_bluetooth_adapter_provider.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/web_test/browser/web_test_bluetooth_adapter_provider.h"

#include <set>
#include <utility>
#include <vector>

#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/threading/thread.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
#include "device/bluetooth/public/cpp/bluetooth_address.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "device/bluetooth/test/mock_bluetooth_gatt_connection.h"
#include "device/bluetooth/test/mock_bluetooth_gatt_descriptor.h"
#include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace  // namespace

namespace content {

// static
scoped_refptr<BluetoothAdapter>
WebTestBluetoothAdapterProvider::GetBluetoothAdapter(
    const std::string& fake_adapter_name) {}

// Adapters

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetBaseAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetPresentAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetPoweredAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetScanFilterCheckingAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetFailStartDiscoveryAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetEmptyAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetGlucoseHeartRateAdapter() {}

// Adds a device to |adapter| and notifies all observers about that new device.
// Mocks can call this asynchronously to cause changes in the middle of a test.
static void AddDevice(scoped_refptr<NiceMockBluetoothAdapter> adapter,
                      std::unique_ptr<NiceMockBluetoothDevice> new_device) {}

static void RemoveDevice(scoped_refptr<NiceMockBluetoothAdapter> adapter,
                         const std::string& device_address) {}
// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetSecondDiscoveryFindsHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetDeviceEventAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetDevicesRemovedAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetMissingServiceHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetMissingCharacteristicHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetDelayedServicesDiscoveryAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetDisconnectingHealthThermometer(
    bool add_descriptors) {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetNoNameDeviceAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetEmptyNameHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetNoNameHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetTwoHeartRateServicesAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetDisconnectingHeartRateAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetServicesDiscoveredAfterReconnectionAdapter(
    bool disconnect) {}

// static
scoped_refptr<NiceMockBluetoothAdapter> WebTestBluetoothAdapterProvider::
    GetGATTOperationFinishesAfterReconnectionAdapter(bool disconnect,
                                                     bool succeeds) {}

// static
scoped_refptr<NiceMockBluetoothAdapter> WebTestBluetoothAdapterProvider::
    GetStopNotifySessionFinishesAfterReconnectionAdapter(bool disconnect) {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetBlocklistTestAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() {}

// static
scoped_refptr<NiceMockBluetoothAdapter>
WebTestBluetoothAdapterProvider::GetFailingGATTOperationsAdapter() {}

// Devices

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetBaseDevice(
    MockBluetoothAdapter* adapter,
    const char* device_name,
    device::BluetoothDevice::UUIDList uuids,
    const std::string& address) {}

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetBatteryDevice(
    MockBluetoothAdapter* adapter) {}

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetGlucoseDevice(
    MockBluetoothAdapter* adapter) {}

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetConnectableDevice(
    device::MockBluetoothAdapter* adapter,
    const char* device_name,
    BluetoothDevice::UUIDList uuids,
    const std::string& address) {}

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetUnconnectableDevice(
    MockBluetoothAdapter* adapter,
    BluetoothDevice::ConnectErrorCode error_code,
    const char* device_name) {}

// static
std::unique_ptr<NiceMockBluetoothDevice>
WebTestBluetoothAdapterProvider::GetHeartRateDevice(
    MockBluetoothAdapter* adapter,
    const char* device_name) {}

// Services

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetBaseGATTService(
    const std::string& identifier,
    MockBluetoothDevice* device,
    const std::string& uuid) {}

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetBlocklistTestService(
    device::MockBluetoothDevice* device) {}

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetDeviceInformationService(
    device::MockBluetoothDevice* device) {}

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetGenericAccessService(
    device::MockBluetoothDevice* device) {}

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetHeartRateService(
    MockBluetoothAdapter* adapter,
    MockBluetoothDevice* device) {}

// static
std::unique_ptr<NiceMockBluetoothGattService>
WebTestBluetoothAdapterProvider::GetDisconnectingService(
    MockBluetoothAdapter* adapter,
    MockBluetoothDevice* device) {}

// Characteristics

// static
std::unique_ptr<NiceMockBluetoothGattCharacteristic>
WebTestBluetoothAdapterProvider::GetBaseGATTCharacteristic(
    const std::string& identifier,
    MockBluetoothGattService* service,
    const std::string& uuid,
    BluetoothRemoteGattCharacteristic::Properties properties) {}

// static
std::unique_ptr<NiceMockBluetoothGattCharacteristic>
WebTestBluetoothAdapterProvider::GetErrorCharacteristic(
    MockBluetoothGattService* service,
    BluetoothGattService::GattErrorCode error_code) {}

// Notify sessions

// static
std::unique_ptr<NiceMockBluetoothGattNotifySession>
WebTestBluetoothAdapterProvider::GetBaseGATTNotifySession(
    base::WeakPtr<device::BluetoothRemoteGattCharacteristic> characteristic) {}

// Helper functions

// static
std::string WebTestBluetoothAdapterProvider::errorUUID(uint32_t alias) {}

// static
std::string WebTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {}

}  // namespace content