Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: components/arc/test/fake_bluetooth_instance.h

Issue 2511253002: arc: bluetooth: enable use_new_wrapper_types for bluetooth.mojom (Closed)
Patch Set: Rebase again Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ 5 #ifndef COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_
6 #define COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ 6 #define COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "components/arc/common/bluetooth.mojom.h" 13 #include "components/arc/common/bluetooth.mojom.h"
14 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
15 15
16 namespace device { 16 namespace device {
17 class BluetoothUUID; 17 class BluetoothUUID;
18 } 18 }
19 19
20 namespace arc { 20 namespace arc {
21 21
22 class FakeBluetoothInstance : public mojom::BluetoothInstance { 22 class FakeBluetoothInstance : public mojom::BluetoothInstance {
23 public: 23 public:
24 class GattDBResult { 24 class GattDBResult {
25 public: 25 public:
26 GattDBResult(mojom::BluetoothAddressPtr&& remote_addr, 26 GattDBResult(mojom::BluetoothAddressPtr&& remote_addr,
27 mojo::Array<mojom::BluetoothGattDBElementPtr>&& db); 27 std::vector<mojom::BluetoothGattDBElementPtr>&& db);
28 ~GattDBResult(); 28 ~GattDBResult();
29 29
30 const mojom::BluetoothAddressPtr& remote_addr() const { 30 const mojom::BluetoothAddressPtr& remote_addr() const {
31 return remote_addr_; 31 return remote_addr_;
32 } 32 }
33 33
34 const mojo::Array<mojom::BluetoothGattDBElementPtr>& db() const { 34 const std::vector<mojom::BluetoothGattDBElementPtr>& db() const {
35 return db_; 35 return db_;
36 } 36 }
37 37
38 private: 38 private:
39 mojom::BluetoothAddressPtr remote_addr_; 39 mojom::BluetoothAddressPtr remote_addr_;
40 mojo::Array<mojom::BluetoothGattDBElementPtr> db_; 40 std::vector<mojom::BluetoothGattDBElementPtr> db_;
41 41
42 DISALLOW_COPY_AND_ASSIGN(GattDBResult); 42 DISALLOW_COPY_AND_ASSIGN(GattDBResult);
43 }; 43 };
44 44
45 class LEDeviceFoundData { 45 class LEDeviceFoundData {
46 public: 46 public:
47 LEDeviceFoundData( 47 LEDeviceFoundData(
48 mojom::BluetoothAddressPtr&& addr, 48 mojom::BluetoothAddressPtr&& addr,
49 int32_t rssi, 49 int32_t rssi,
50 mojo::Array<mojom::BluetoothAdvertisingDataPtr>&& adv_data); 50 std::vector<mojom::BluetoothAdvertisingDataPtr>&& adv_data);
51 ~LEDeviceFoundData(); 51 ~LEDeviceFoundData();
52 52
53 const mojom::BluetoothAddressPtr& addr() const { return addr_; } 53 const mojom::BluetoothAddressPtr& addr() const { return addr_; }
54 54
55 int32_t rssi() const { return rssi_; } 55 int32_t rssi() const { return rssi_; }
56 56
57 const mojo::Array<mojom::BluetoothAdvertisingDataPtr>& adv_data() const { 57 const std::vector<mojom::BluetoothAdvertisingDataPtr>& adv_data() const {
58 return adv_data_; 58 return adv_data_;
59 } 59 }
60 60
61 private: 61 private:
62 mojom::BluetoothAddressPtr addr_; 62 mojom::BluetoothAddressPtr addr_;
63 int32_t rssi_; 63 int32_t rssi_;
64 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data_; 64 std::vector<mojom::BluetoothAdvertisingDataPtr> adv_data_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(LEDeviceFoundData); 66 DISALLOW_COPY_AND_ASSIGN(LEDeviceFoundData);
67 }; 67 };
68 68
69 FakeBluetoothInstance(); 69 FakeBluetoothInstance();
70 ~FakeBluetoothInstance() override; 70 ~FakeBluetoothInstance() override;
71 71
72 // interface BluetoothInstance 72 // interface BluetoothInstance
73 void Init(mojom::BluetoothHostPtr host_ptr) override; 73 void Init(mojom::BluetoothHostPtr host_ptr) override;
74 void OnAdapterProperties( 74 void OnAdapterProperties(
75 mojom::BluetoothStatus status, 75 mojom::BluetoothStatus status,
76 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; 76 std::vector<mojom::BluetoothPropertyPtr> properties) override;
77 void OnRemoteDeviceProperties( 77 void OnRemoteDeviceProperties(
78 mojom::BluetoothStatus status, 78 mojom::BluetoothStatus status,
79 mojom::BluetoothAddressPtr address, 79 mojom::BluetoothAddressPtr address,
80 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; 80 std::vector<mojom::BluetoothPropertyPtr> properties) override;
81 void OnDeviceFound( 81 void OnDeviceFound(
82 mojo::Array<mojom::BluetoothPropertyPtr> properties) override; 82 std::vector<mojom::BluetoothPropertyPtr> properties) override;
83 void OnDiscoveryStateChanged(mojom::BluetoothDiscoveryState state) override; 83 void OnDiscoveryStateChanged(mojom::BluetoothDiscoveryState state) override;
84 void OnBondStateChanged(mojom::BluetoothStatus status, 84 void OnBondStateChanged(mojom::BluetoothStatus status,
85 mojom::BluetoothAddressPtr remote_addr, 85 mojom::BluetoothAddressPtr remote_addr,
86 mojom::BluetoothBondState state) override; 86 mojom::BluetoothBondState state) override;
87 void OnAclStateChanged(mojom::BluetoothStatus status, 87 void OnAclStateChanged(mojom::BluetoothStatus status,
88 mojom::BluetoothAddressPtr remote_addr, 88 mojom::BluetoothAddressPtr remote_addr,
89 mojom::BluetoothAclState state) override; 89 mojom::BluetoothAclState state) override;
90 void OnLEDeviceFound( 90 void OnLEDeviceFound(
91 mojom::BluetoothAddressPtr addr, 91 mojom::BluetoothAddressPtr addr,
92 int32_t rssi, 92 int32_t rssi,
93 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data) override; 93 std::vector<mojom::BluetoothAdvertisingDataPtr> adv_data) override;
94 void OnLEConnectionStateChange(mojom::BluetoothAddressPtr remote_addr, 94 void OnLEConnectionStateChange(mojom::BluetoothAddressPtr remote_addr,
95 bool connected) override; 95 bool connected) override;
96 void OnLEDeviceAddressChange(mojom::BluetoothAddressPtr old_addr, 96 void OnLEDeviceAddressChange(mojom::BluetoothAddressPtr old_addr,
97 mojom::BluetoothAddressPtr new_addr) override; 97 mojom::BluetoothAddressPtr new_addr) override;
98 void OnSearchComplete(mojom::BluetoothAddressPtr remote_addr, 98 void OnSearchComplete(mojom::BluetoothAddressPtr remote_addr,
99 mojom::BluetoothGattStatus status) override; 99 mojom::BluetoothGattStatus status) override;
100 void OnGetGattDB(mojom::BluetoothAddressPtr remote_addr, 100 void OnGetGattDB(mojom::BluetoothAddressPtr remote_addr,
101 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override; 101 std::vector<mojom::BluetoothGattDBElementPtr> db) override;
102 void OnServicesRemoved(mojom::BluetoothAddressPtr remote_addr, 102 void OnServicesRemoved(mojom::BluetoothAddressPtr remote_addr,
103 uint16_t start_handle, 103 uint16_t start_handle,
104 uint16_t end_handle) override; 104 uint16_t end_handle) override;
105 void OnServicesAdded( 105 void OnServicesAdded(
106 mojom::BluetoothAddressPtr remote_addr, 106 mojom::BluetoothAddressPtr remote_addr,
107 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override; 107 std::vector<mojom::BluetoothGattDBElementPtr> db) override;
108 108
109 void OnGattNotify(mojom::BluetoothAddressPtr remote_addr, 109 void OnGattNotify(mojom::BluetoothAddressPtr remote_addr,
110 mojom::BluetoothGattServiceIDPtr service_id, 110 mojom::BluetoothGattServiceIDPtr service_id,
111 mojom::BluetoothGattIDPtr char_id, 111 mojom::BluetoothGattIDPtr char_id,
112 bool is_notify, 112 bool is_notify,
113 mojo::Array<uint8_t> value) override; 113 const std::vector<uint8_t>& value) override;
114 114
115 void RequestGattRead(mojom::BluetoothAddressPtr address, 115 void RequestGattRead(mojom::BluetoothAddressPtr address,
116 int32_t attribute_handle, 116 int32_t attribute_handle,
117 int32_t offset, 117 int32_t offset,
118 bool is_long, 118 bool is_long,
119 const RequestGattReadCallback& callback) override; 119 const RequestGattReadCallback& callback) override;
120 120
121 void RequestGattWrite(mojom::BluetoothAddressPtr address, 121 void RequestGattWrite(mojom::BluetoothAddressPtr address,
122 int32_t attribute_handle, 122 int32_t attribute_handle,
123 int32_t offset, 123 int32_t offset,
124 mojo::Array<uint8_t> value, 124 const std::vector<uint8_t>& value,
125 const RequestGattWriteCallback& callback) override; 125 const RequestGattWriteCallback& callback) override;
126 126
127 void OnGetSdpRecords( 127 void OnGetSdpRecords(
128 mojom::BluetoothStatus status, 128 mojom::BluetoothStatus status,
129 mojom::BluetoothAddressPtr remove_addr, 129 mojom::BluetoothAddressPtr remove_addr,
130 const device::BluetoothUUID& target_uuid, 130 const device::BluetoothUUID& target_uuid,
131 mojo::Array<mojom::BluetoothSdpRecordPtr> records) override; 131 std::vector<mojom::BluetoothSdpRecordPtr> records) override;
132 132
133 const std::vector<mojo::Array<mojom::BluetoothPropertyPtr>>& 133 const std::vector<std::vector<mojom::BluetoothPropertyPtr>>&
134 device_found_data() const { 134 device_found_data() const {
135 return device_found_data_; 135 return device_found_data_;
136 } 136 }
137 137
138 const std::vector<std::unique_ptr<LEDeviceFoundData>>& le_device_found_data() 138 const std::vector<std::unique_ptr<LEDeviceFoundData>>& le_device_found_data()
139 const { 139 const {
140 return le_device_found_data_; 140 return le_device_found_data_;
141 } 141 }
142 142
143 const std::vector<std::unique_ptr<GattDBResult>>& gatt_db_result() const { 143 const std::vector<std::unique_ptr<GattDBResult>>& gatt_db_result() const {
144 return gatt_db_result_; 144 return gatt_db_result_;
145 } 145 }
146 146
147 private: 147 private:
148 std::vector<mojo::Array<mojom::BluetoothPropertyPtr>> device_found_data_; 148 std::vector<std::vector<mojom::BluetoothPropertyPtr>> device_found_data_;
149 std::vector<std::unique_ptr<LEDeviceFoundData>> le_device_found_data_; 149 std::vector<std::unique_ptr<LEDeviceFoundData>> le_device_found_data_;
150 std::vector<std::unique_ptr<GattDBResult>> gatt_db_result_; 150 std::vector<std::unique_ptr<GattDBResult>> gatt_db_result_;
151 151
152 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInstance); 152 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInstance);
153 }; 153 };
154 154
155 } // namespace arc 155 } // namespace arc
156 156
157 #endif // COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_ 157 #endif // COMPONENTS_ARC_TEST_FAKE_BLUETOOTH_INSTANCE_H_
OLDNEW
« no previous file with comments | « components/arc/bluetooth/bluetooth_type_converters_unittest.cc ('k') | components/arc/test/fake_bluetooth_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698