OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ |
6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
8 #include "device/bluetooth/bluetooth_adapter.h" | 11 #include "device/bluetooth/bluetooth_adapter.h" |
9 | 12 |
10 namespace device { | 13 namespace device { |
11 | 14 |
12 // Test implementation of BluetoothAdapter::Observer counting method calls and | 15 // Test implementation of BluetoothAdapter::Observer counting method calls and |
13 // caching last reported values. | 16 // caching last reported values. |
14 class TestBluetoothAdapterObserver : public BluetoothAdapter::Observer { | 17 class TestBluetoothAdapterObserver : public BluetoothAdapter::Observer { |
15 public: | 18 public: |
16 TestBluetoothAdapterObserver(scoped_refptr<BluetoothAdapter> adapter); | 19 TestBluetoothAdapterObserver(scoped_refptr<BluetoothAdapter> adapter); |
17 ~TestBluetoothAdapterObserver() override; | 20 ~TestBluetoothAdapterObserver() override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void GattCharacteristicRemoved( | 55 void GattCharacteristicRemoved( |
53 BluetoothAdapter* adapter, | 56 BluetoothAdapter* adapter, |
54 BluetoothGattCharacteristic* characteristic) override; | 57 BluetoothGattCharacteristic* characteristic) override; |
55 void GattDescriptorAdded(BluetoothAdapter* adapter, | 58 void GattDescriptorAdded(BluetoothAdapter* adapter, |
56 BluetoothGattDescriptor* descriptor) override; | 59 BluetoothGattDescriptor* descriptor) override; |
57 void GattDescriptorRemoved(BluetoothAdapter* adapter, | 60 void GattDescriptorRemoved(BluetoothAdapter* adapter, |
58 BluetoothGattDescriptor* descriptor) override; | 61 BluetoothGattDescriptor* descriptor) override; |
59 void GattCharacteristicValueChanged( | 62 void GattCharacteristicValueChanged( |
60 BluetoothAdapter* adapter, | 63 BluetoothAdapter* adapter, |
61 BluetoothGattCharacteristic* characteristic, | 64 BluetoothGattCharacteristic* characteristic, |
62 const std::vector<uint8>& value) override; | 65 const std::vector<uint8_t>& value) override; |
63 void GattDescriptorValueChanged(BluetoothAdapter* adapter, | 66 void GattDescriptorValueChanged(BluetoothAdapter* adapter, |
64 BluetoothGattDescriptor* descriptor, | 67 BluetoothGattDescriptor* descriptor, |
65 const std::vector<uint8>& value) override; | 68 const std::vector<uint8_t>& value) override; |
66 | 69 |
67 // Adapter related: | 70 // Adapter related: |
68 int present_changed_count() { return present_changed_count_; } | 71 int present_changed_count() { return present_changed_count_; } |
69 int powered_changed_count() { return powered_changed_count_; } | 72 int powered_changed_count() { return powered_changed_count_; } |
70 int discoverable_changed_count() { return discoverable_changed_count_; } | 73 int discoverable_changed_count() { return discoverable_changed_count_; } |
71 int discovering_changed_count() { return discovering_changed_count_; } | 74 int discovering_changed_count() { return discovering_changed_count_; } |
72 bool last_present() { return last_present_; } | 75 bool last_present() { return last_present_; } |
73 bool last_powered() { return last_powered_; } | 76 bool last_powered() { return last_powered_; } |
74 bool last_discovering() { return last_discovering_; } | 77 bool last_discovering() { return last_discovering_; } |
75 | 78 |
(...skipping 28 matching lines...) Expand all Loading... |
104 return gatt_descriptor_value_changed_count_; | 107 return gatt_descriptor_value_changed_count_; |
105 } | 108 } |
106 std::string last_gatt_service_id() { return last_gatt_service_id_; } | 109 std::string last_gatt_service_id() { return last_gatt_service_id_; } |
107 BluetoothUUID last_gatt_service_uuid() { return last_gatt_service_uuid_; } | 110 BluetoothUUID last_gatt_service_uuid() { return last_gatt_service_uuid_; } |
108 std::string last_gatt_characteristic_id() { | 111 std::string last_gatt_characteristic_id() { |
109 return last_gatt_characteristic_id_; | 112 return last_gatt_characteristic_id_; |
110 } | 113 } |
111 BluetoothUUID last_gatt_characteristic_uuid() { | 114 BluetoothUUID last_gatt_characteristic_uuid() { |
112 return last_gatt_characteristic_uuid_; | 115 return last_gatt_characteristic_uuid_; |
113 } | 116 } |
114 std::vector<uint8> last_changed_characteristic_value() { | 117 std::vector<uint8_t> last_changed_characteristic_value() { |
115 return last_changed_characteristic_value_; | 118 return last_changed_characteristic_value_; |
116 } | 119 } |
117 std::string last_gatt_descriptor_id() { return last_gatt_descriptor_id_; } | 120 std::string last_gatt_descriptor_id() { return last_gatt_descriptor_id_; } |
118 BluetoothUUID last_gatt_descriptor_uuid() { | 121 BluetoothUUID last_gatt_descriptor_uuid() { |
119 return last_gatt_descriptor_uuid_; | 122 return last_gatt_descriptor_uuid_; |
120 } | 123 } |
121 std::vector<uint8> last_changed_descriptor_value() { | 124 std::vector<uint8_t> last_changed_descriptor_value() { |
122 return last_changed_descriptor_value_; | 125 return last_changed_descriptor_value_; |
123 } | 126 } |
124 | 127 |
125 private: | 128 private: |
126 // Some tests use a message loop since background processing is simulated; | 129 // Some tests use a message loop since background processing is simulated; |
127 // break out of those loops. | 130 // break out of those loops. |
128 void QuitMessageLoop(); | 131 void QuitMessageLoop(); |
129 | 132 |
130 scoped_refptr<BluetoothAdapter> adapter_; | 133 scoped_refptr<BluetoothAdapter> adapter_; |
131 | 134 |
(...skipping 23 matching lines...) Expand all Loading... |
155 int gatt_characteristic_added_count_; | 158 int gatt_characteristic_added_count_; |
156 int gatt_characteristic_removed_count_; | 159 int gatt_characteristic_removed_count_; |
157 int gatt_characteristic_value_changed_count_; | 160 int gatt_characteristic_value_changed_count_; |
158 int gatt_descriptor_added_count_; | 161 int gatt_descriptor_added_count_; |
159 int gatt_descriptor_removed_count_; | 162 int gatt_descriptor_removed_count_; |
160 int gatt_descriptor_value_changed_count_; | 163 int gatt_descriptor_value_changed_count_; |
161 std::string last_gatt_service_id_; | 164 std::string last_gatt_service_id_; |
162 BluetoothUUID last_gatt_service_uuid_; | 165 BluetoothUUID last_gatt_service_uuid_; |
163 std::string last_gatt_characteristic_id_; | 166 std::string last_gatt_characteristic_id_; |
164 BluetoothUUID last_gatt_characteristic_uuid_; | 167 BluetoothUUID last_gatt_characteristic_uuid_; |
165 std::vector<uint8> last_changed_characteristic_value_; | 168 std::vector<uint8_t> last_changed_characteristic_value_; |
166 std::string last_gatt_descriptor_id_; | 169 std::string last_gatt_descriptor_id_; |
167 BluetoothUUID last_gatt_descriptor_uuid_; | 170 BluetoothUUID last_gatt_descriptor_uuid_; |
168 std::vector<uint8> last_changed_descriptor_value_; | 171 std::vector<uint8_t> last_changed_descriptor_value_; |
169 | 172 |
170 DISALLOW_COPY_AND_ASSIGN(TestBluetoothAdapterObserver); | 173 DISALLOW_COPY_AND_ASSIGN(TestBluetoothAdapterObserver); |
171 }; | 174 }; |
172 | 175 |
173 } // namespace device | 176 } // namespace device |
174 | 177 |
175 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ | 178 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_ADAPTER_OBSERVER_H_ |
OLD | NEW |