OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ |
| 6 #define COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" |
| 10 #include "components/arc/common/bluetooth.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 |
| 13 namespace arc { |
| 14 |
| 15 class FakeBluetoothInstance : public mojom::BluetoothInstance { |
| 16 public: |
| 17 class GattDBResult { |
| 18 public: |
| 19 GattDBResult(mojom::BluetoothAddressPtr&& remote_addr, |
| 20 mojo::Array<mojom::BluetoothGattDBElementPtr>&& db); |
| 21 ~GattDBResult(); |
| 22 |
| 23 const mojom::BluetoothAddressPtr& remote_addr() const { |
| 24 return remote_addr_; |
| 25 } |
| 26 |
| 27 const mojo::Array<mojom::BluetoothGattDBElementPtr>& db() const { |
| 28 return db_; |
| 29 } |
| 30 |
| 31 private: |
| 32 mojom::BluetoothAddressPtr remote_addr_; |
| 33 mojo::Array<mojom::BluetoothGattDBElementPtr> db_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(GattDBResult); |
| 36 }; |
| 37 |
| 38 class LEDeviceFoundData { |
| 39 public: |
| 40 LEDeviceFoundData( |
| 41 mojom::BluetoothAddressPtr&& addr, |
| 42 int32_t rssi, |
| 43 mojo::Array<mojom::BluetoothAdvertisingDataPtr>&& adv_data); |
| 44 ~LEDeviceFoundData(); |
| 45 |
| 46 const mojom::BluetoothAddressPtr& addr() const { return addr_; } |
| 47 |
| 48 int32_t rssi() const { return rssi_; } |
| 49 |
| 50 const mojo::Array<mojom::BluetoothAdvertisingDataPtr>& adv_data() const { |
| 51 return adv_data_; |
| 52 } |
| 53 |
| 54 private: |
| 55 mojom::BluetoothAddressPtr addr_; |
| 56 int32_t rssi_; |
| 57 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(LEDeviceFoundData); |
| 60 }; |
| 61 |
| 62 FakeBluetoothInstance(); |
| 63 ~FakeBluetoothInstance() override; |
| 64 |
| 65 // interface BluetoothInstance |
| 66 void Init(mojom::BluetoothHostPtr host_ptr) override; |
| 67 void OnAdapterProperties( |
| 68 mojom::BluetoothStatus status, |
| 69 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; |
| 70 void OnRemoteDeviceProperties( |
| 71 mojom::BluetoothStatus status, |
| 72 mojom::BluetoothAddressPtr address, |
| 73 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; |
| 74 void OnDeviceFound( |
| 75 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; |
| 76 void OnDiscoveryStateChanged(mojom::BluetoothDiscoveryState state) override; |
| 77 void OnBondStateChanged(mojom::BluetoothStatus status, |
| 78 mojom::BluetoothAddressPtr remote_addr, |
| 79 mojom::BluetoothBondState state) override; |
| 80 void OnAclStateChanged(mojom::BluetoothStatus status, |
| 81 mojom::BluetoothAddressPtr remote_addr, |
| 82 mojom::BluetoothAclState state) override; |
| 83 void OnLEDeviceFound( |
| 84 mojom::BluetoothAddressPtr addr, |
| 85 int32_t rssi, |
| 86 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data) override; |
| 87 void OnLEConnectionStateChange(mojom::BluetoothAddressPtr remote_addr, |
| 88 bool connected) override; |
| 89 void OnSearchComplete(mojom::BluetoothAddressPtr remote_addr, |
| 90 mojom::BluetoothGattStatus status) override; |
| 91 void OnGetGattDB(mojom::BluetoothAddressPtr remote_addr, |
| 92 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override; |
| 93 void OnServicesRemoved(mojom::BluetoothAddressPtr remote_addr, |
| 94 uint16_t start_handle, |
| 95 uint16_t end_handle) override; |
| 96 void OnServicesAdded( |
| 97 mojom::BluetoothAddressPtr remote_addr, |
| 98 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override; |
| 99 |
| 100 const std::vector<mojo::Array<mojom::BluetoothPropertyPtr>>& |
| 101 device_found_data() const { |
| 102 return device_found_data_; |
| 103 } |
| 104 |
| 105 const std::vector<LEDeviceFoundData*>& le_device_found_data() const { |
| 106 return le_device_found_data_; |
| 107 } |
| 108 |
| 109 const std::vector<GattDBResult*>& gatt_db_result() const { |
| 110 return gatt_db_result_; |
| 111 } |
| 112 |
| 113 private: |
| 114 std::vector<mojo::Array<mojom::BluetoothPropertyPtr>> device_found_data_; |
| 115 std::vector<LEDeviceFoundData*> le_device_found_data_; |
| 116 std::vector<GattDBResult*> gatt_db_result_; |
| 117 }; |
| 118 |
| 119 } // namespace arc |
| 120 |
| 121 #endif // COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ |
OLD | NEW |