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

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

Issue 2046283003: Add unit test for ArcBluetoothBridge and TypeConverter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt
Patch Set: Range check in type_converters Created 4 years, 4 months 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
(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 <vector>
9
10 #include "base/macros.h"
11 #include "base/memory/scoped_vector.h"
12 #include "components/arc/common/bluetooth.mojom.h"
13 #include "mojo/public/cpp/bindings/binding.h"
14
15 namespace arc {
16
17 class FakeBluetoothInstance : public mojom::BluetoothInstance {
18 public:
19 class GattDBResult {
20 public:
21 GattDBResult(mojom::BluetoothAddressPtr&& remote_addr,
22 mojo::Array<mojom::BluetoothGattDBElementPtr>&& db);
23 ~GattDBResult();
24
25 const mojom::BluetoothAddressPtr& remote_addr() const {
26 return remote_addr_;
27 }
28
29 const mojo::Array<mojom::BluetoothGattDBElementPtr>& db() const {
30 return db_;
31 }
32
33 private:
34 mojom::BluetoothAddressPtr remote_addr_;
35 mojo::Array<mojom::BluetoothGattDBElementPtr> db_;
36
37 DISALLOW_COPY_AND_ASSIGN(GattDBResult);
38 };
39
40 class LEDeviceFoundData {
41 public:
42 LEDeviceFoundData(
43 mojom::BluetoothAddressPtr&& addr,
44 int32_t rssi,
45 mojo::Array<mojom::BluetoothAdvertisingDataPtr>&& adv_data);
46 ~LEDeviceFoundData();
47
48 const mojom::BluetoothAddressPtr& addr() const { return addr_; }
49
50 int32_t rssi() const { return rssi_; }
51
52 const mojo::Array<mojom::BluetoothAdvertisingDataPtr>& adv_data() const {
53 return adv_data_;
54 }
55
56 private:
57 mojom::BluetoothAddressPtr addr_;
58 int32_t rssi_;
59 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data_;
60
61 DISALLOW_COPY_AND_ASSIGN(LEDeviceFoundData);
62 };
63
64 FakeBluetoothInstance();
65 ~FakeBluetoothInstance() override;
66
67 // interface BluetoothInstance
68 void Init(mojom::BluetoothHostPtr host_ptr) override;
69 void OnAdapterProperties(
70 mojom::BluetoothStatus status,
71 mojo::Array<mojom::BluetoothPropertyPtr> properties) override;
72 void OnRemoteDeviceProperties(
73 mojom::BluetoothStatus status,
74 mojom::BluetoothAddressPtr address,
75 mojo::Array<mojom::BluetoothPropertyPtr> properties) override;
76 void OnDeviceFound(
77 mojo::Array<mojom::BluetoothPropertyPtr> properties) override;
78 void OnDiscoveryStateChanged(mojom::BluetoothDiscoveryState state) override;
79 void OnBondStateChanged(mojom::BluetoothStatus status,
80 mojom::BluetoothAddressPtr remote_addr,
81 mojom::BluetoothBondState state) override;
82 void OnAclStateChanged(mojom::BluetoothStatus status,
83 mojom::BluetoothAddressPtr remote_addr,
84 mojom::BluetoothAclState state) override;
85 void OnLEDeviceFound(
86 mojom::BluetoothAddressPtr addr,
87 int32_t rssi,
88 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data) override;
89 void OnLEConnectionStateChange(mojom::BluetoothAddressPtr remote_addr,
90 bool connected) override;
91 void OnSearchComplete(mojom::BluetoothAddressPtr remote_addr,
92 mojom::BluetoothGattStatus status) override;
93 void OnGetGattDB(mojom::BluetoothAddressPtr remote_addr,
94 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override;
95 void OnServicesRemoved(mojom::BluetoothAddressPtr remote_addr,
96 uint16_t start_handle,
97 uint16_t end_handle) override;
98 void OnServicesAdded(
99 mojom::BluetoothAddressPtr remote_addr,
100 mojo::Array<mojom::BluetoothGattDBElementPtr> db) override;
101
102 void OnGattNotify(mojom::BluetoothAddressPtr remote_addr,
103 mojom::BluetoothGattServiceIDPtr service_id,
104 mojom::BluetoothGattIDPtr char_id,
105 bool is_notify,
106 mojo::Array<uint8_t> value) override;
107
108 void RequestGattRead(mojom::BluetoothAddressPtr address,
109 int32_t attribute_handle,
110 int32_t offset,
111 bool is_long,
112 const RequestGattReadCallback& callback) override;
113
114 void RequestGattWrite(mojom::BluetoothAddressPtr address,
115 int32_t attribute_handle,
116 int32_t offset,
117 mojo::Array<uint8_t> value,
118 const RequestGattWriteCallback& callback) override;
119
120 const std::vector<mojo::Array<mojom::BluetoothPropertyPtr>>&
121 device_found_data() const {
122 return device_found_data_;
123 }
124
125 const std::vector<LEDeviceFoundData*>& le_device_found_data() const {
126 return le_device_found_data_;
127 }
128
129 const std::vector<GattDBResult*>& gatt_db_result() const {
130 return gatt_db_result_;
131 }
132
133 private:
134 std::vector<mojo::Array<mojom::BluetoothPropertyPtr>> device_found_data_;
135 std::vector<LEDeviceFoundData*> le_device_found_data_;
136 std::vector<GattDBResult*> gatt_db_result_;
137
138 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInstance);
139 };
140
141 } // namespace arc
142
143 #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