Index: device/bluetooth/public/interfaces/fake_bluetooth.mojom |
diff --git a/device/bluetooth/public/interfaces/fake_bluetooth.mojom b/device/bluetooth/public/interfaces/fake_bluetooth.mojom |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51a39f29087f1b30ad3d095fb7499635d41b60e7 |
--- /dev/null |
+++ b/device/bluetooth/public/interfaces/fake_bluetooth.mojom |
@@ -0,0 +1,131 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+module bluetooth.mojom; |
+ |
+enum FakeLECentralManagerState { |
+ ABSENT, |
+ POWERED_ON, |
+ POWERED_OFF, |
+}; |
+ |
+struct FakeLECentralManagerOptions { |
+ FakeLECentralManagerState state; |
+}; |
+ |
+interface FakeBluetooth { |
+ SetLEAvailability(bool available) => (); |
+ SimulateLECentralManager(FakeLECentralManagerOptions options) => (FakeLECentralManager central_manager); |
+}; |
+ |
+struct Appearance { |
+ bool has_value; |
+ uint8 value; |
+}; |
+ |
+struct Power { |
+ bool has_value; |
+ int8 value; |
+}; |
+ |
+struct ScanResult { |
+ string device_address; |
+ uint8 rssi; |
+ ScanRecord scanRecord; |
+}; |
+ |
+struct ScanRecord { |
+ string? name; |
+ array<string>? uuids; |
+ Appearance appearance; |
+ Power txPower; |
+ |
+ map<uint8, array<uint8>> manufacturer_data; |
+ map<string, array<uint8>> service_data; |
+}; |
+ |
+struct FakeLEPeripheralOptions { |
+ string address; |
+ string name; |
+}; |
+ |
+interface FakeLECentralManager { |
+ SimulateAdvertisementReceived(ScanResult result) => (FakeLEPeripheral? peripheral); |
+ |
+ AddConnectedLEPeripheral(FakeLEPeripheralOptions options) => (FakeLEPeripheral? peripheral); |
+ |
+ |
+ SetState(FakeLECentralManagerState state) => (); |
+ GetStartScanCalls() => (uint64 calls); |
+ GetStopScanCalls() => (uint64 calls); |
+}; |
+ |
+// TODO: Add more connection errors. |
+enum GATTConnectionResult { |
+ TIMEOUT, |
+}; |
+ |
+struct FakeRemoteGATTServiceOptions { |
+ string uuid; |
+}; |
+ |
+interface FakeLEPeripheral { |
+ SimulateGATTConnection(GATTConnectionResult result) => (); |
+ SimulateGATTDiscoveryComplete() => (); |
+ SimulateGATTServicesChanged() => (); |
+ |
+ AddFakeService(FakeRemoteGATTServiceOptions options) => (FakeRemoteGATTService? fake_service); |
+ |
+ GetConnectCalls() => (uint64 calls); |
+ GetDisconnectCalls() => (uint64 calls); |
+}; |
+ |
+struct FakeRemoteGATTCharacteristicOptions { |
+ string uuid; |
+ int32 permissions; |
+}; |
+ |
+interface FakeRemoteGATTService { |
+ AddFakeCharacteristic(FakeRemoteGATTCharacteristicOptions options) => (FakeRemoteGATTCharacteristic? characteristic); |
+ AddFakeIncludedService(FakeRemoteGATTServiceOptions options) => (FakeRemoteGATTService? service); |
+}; |
+ |
+struct FakeRemoteGATTDescriptorOptions { |
+ string uuid; |
+}; |
+ |
+enum GATTOperationResult { |
+ SUCCESS, |
+ FAILED, |
+}; |
+ |
+enum NotificationType { |
+ INDICATION, |
+ NOTIFICATION, |
+}; |
+ |
+struct FakeNotificationOptions { |
+ NotificationType type; |
+ array<uint8> value; |
+}; |
+ |
+interface FakeRemoteGATTCharacteristic { |
+ SimulateRead(GATTOperationResult result, array<uint8>? value) => (); |
+ SimulateWrite(GATTOperationResult result) => (array<uint8> value); |
+ SimulateNotificationsStarted(GATTOperationResult result) => (); |
+ SimulateNotificationsStopped(GATTOperationResult result) => (); |
+ SimulateNotification(FakeNotificationOptions options) => (); |
+ |
+ AddFakeDescriptor(FakeRemoteGATTDescriptorOptions options) => (FakeRemoteGATTDescriptor? descriptor); |
+ |
+ GetReadCalls() => (uint64 calls); |
+ GetWriteCalls() => (uint64 calls); |
+ GetStartNotificationsCalls() => (uint64 calls); |
+ GetStopNotificationsCalls() => (uint64 calls); |
+}; |
+ |
+interface FakeRemoteGATTDescriptor { |
+ SimulateRead(GATTOperationResult result, array<uint8>? value) => (); |
+ SimulateWrite(GATTOperationResult result) => (array<uint8> value); |
+}; |