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

Side by Side Diff: device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h

Issue 1973703002: Implement //device/bt changes for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notifications_dbus
Patch Set: Created 4 years, 7 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
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 DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_
6 #define DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_ 6 #define DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h" 13 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
14 #include "device/bluetooth/bluetooth_local_gatt_descriptor.h" 14 #include "device/bluetooth/bluetooth_local_gatt_descriptor.h"
15 #include "device/bluetooth/bluetooth_local_gatt_service.h" 15 #include "device/bluetooth/bluetooth_local_gatt_service.h"
16 16
17 namespace device { 17 namespace device {
18 18
19 class TestBluetoothLocalGattServiceDelegate 19 class TestBluetoothLocalGattServiceDelegate
20 : public BluetoothLocalGattService::Delegate { 20 : public BluetoothLocalGattService::Delegate {
21 public: 21 public:
22 TestBluetoothLocalGattServiceDelegate(); 22 TestBluetoothLocalGattServiceDelegate();
23 ~TestBluetoothLocalGattServiceDelegate();
xiyuan 2016/05/12 19:49:43 nit: make it virtual? Or add a dtor to Delegate in
rkc 2016/05/12 20:12:49 Done.
23 24
25 // BluetoothLocalGattService::Delegate overrides:
24 void OnCharacteristicReadRequest( 26 void OnCharacteristicReadRequest(
25 const BluetoothLocalGattService* service, 27 const BluetoothLocalGattService* service,
26 const BluetoothLocalGattCharacteristic* characteristic, 28 const BluetoothLocalGattCharacteristic* characteristic,
27 int offset, 29 int offset,
28 const ValueCallback& callback, 30 const ValueCallback& callback,
29 const ErrorCallback& error_callback) override; 31 const ErrorCallback& error_callback) override;
30 void OnCharacteristicWriteRequest( 32 void OnCharacteristicWriteRequest(
31 const BluetoothLocalGattService* service, 33 const BluetoothLocalGattService* service,
32 const BluetoothLocalGattCharacteristic* characteristic, 34 const BluetoothLocalGattCharacteristic* characteristic,
33 const std::vector<uint8_t>& value, 35 const std::vector<uint8_t>& value,
34 int offset, 36 int offset,
35 const base::Closure& callback, 37 const base::Closure& callback,
36 const ErrorCallback& error_callback) override; 38 const ErrorCallback& error_callback) override;
37 void OnDescriptorReadRequest(const BluetoothLocalGattService* service, 39 void OnDescriptorReadRequest(const BluetoothLocalGattService* service,
38 const BluetoothLocalGattDescriptor* descriptor, 40 const BluetoothLocalGattDescriptor* descriptor,
39 int offset, 41 int offset,
40 const ValueCallback& callback, 42 const ValueCallback& callback,
41 const ErrorCallback& error_callback) override; 43 const ErrorCallback& error_callback) override;
42 44
43 void OnDescriptorWriteRequest(const BluetoothLocalGattService* service, 45 void OnDescriptorWriteRequest(const BluetoothLocalGattService* service,
44 const BluetoothLocalGattDescriptor* descriptor, 46 const BluetoothLocalGattDescriptor* descriptor,
45 const std::vector<uint8_t>& value, 47 const std::vector<uint8_t>& value,
46 int offset, 48 int offset,
47 const base::Closure& callback, 49 const base::Closure& callback,
48 const ErrorCallback& error_callback) override; 50 const ErrorCallback& error_callback) override;
51 void OnNotificationsStart(
52 const BluetoothLocalGattService* service,
53 const BluetoothLocalGattCharacteristic* characteristic) override;
54 void OnNotificationsStop(
55 const BluetoothLocalGattService* service,
56 const BluetoothLocalGattCharacteristic* characteristic) override;
57
58 bool NotificationStatusForCharacteristic(
59 BluetoothLocalGattCharacteristic* characteristic);
49 60
50 void set_expected_service(BluetoothLocalGattService* service) { 61 void set_expected_service(BluetoothLocalGattService* service) {
51 expected_service_ = service; 62 expected_service_ = service;
52 } 63 }
53 64
54 void set_expected_characteristic( 65 void set_expected_characteristic(
55 BluetoothLocalGattCharacteristic* characteristic) { 66 BluetoothLocalGattCharacteristic* characteristic) {
56 expected_characteristic_ = characteristic; 67 expected_characteristic_ = characteristic;
57 } 68 }
58 69
59 void set_expected_descriptor(BluetoothLocalGattDescriptor* descriptor) { 70 void set_expected_descriptor(BluetoothLocalGattDescriptor* descriptor) {
60 expected_descriptor_ = descriptor; 71 expected_descriptor_ = descriptor;
61 } 72 }
62 73
63 bool should_fail_; 74 bool should_fail_;
64 uint64_t last_written_value_; 75 uint64_t last_written_value_;
65 uint64_t value_to_write_; 76 uint64_t value_to_write_;
66 77
67 private: 78 private:
68 BluetoothLocalGattService* expected_service_; 79 BluetoothLocalGattService* expected_service_;
69 BluetoothLocalGattCharacteristic* expected_characteristic_; 80 BluetoothLocalGattCharacteristic* expected_characteristic_;
70 BluetoothLocalGattDescriptor* expected_descriptor_; 81 BluetoothLocalGattDescriptor* expected_descriptor_;
71 82
83 std::map<std::string, bool> notifications_started_for_characteristic_;
84
72 DISALLOW_COPY_AND_ASSIGN(TestBluetoothLocalGattServiceDelegate); 85 DISALLOW_COPY_AND_ASSIGN(TestBluetoothLocalGattServiceDelegate);
73 }; 86 };
74 87
75 } // namespace device 88 } // namespace device
76 89
77 #endif // DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_ 90 #endif // DEVICE_BLUETOOTH_TEST_TEST_BLUETOOTH_LOCAL_GATT_SERVICE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698