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

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

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
« no previous file with comments | « device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h> 5 #include <device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h>
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "device/bluetooth/test/bluetooth_gatt_server_test.h" 7 #include "device/bluetooth/test/bluetooth_gatt_server_test.h"
8 8
9 namespace device { 9 namespace device {
10 10
11 TestBluetoothLocalGattServiceDelegate::TestBluetoothLocalGattServiceDelegate() 11 TestBluetoothLocalGattServiceDelegate::TestBluetoothLocalGattServiceDelegate()
12 : should_fail_(false), 12 : should_fail_(false),
13 last_written_value_(0), 13 last_written_value_(0),
14 value_to_write_(0), 14 value_to_write_(0),
15 expected_service_(nullptr), 15 expected_service_(nullptr),
16 expected_characteristic_(nullptr), 16 expected_characteristic_(nullptr),
17 expected_descriptor_(nullptr) {} 17 expected_descriptor_(nullptr) {}
18 18
19 TestBluetoothLocalGattServiceDelegate::
20 ~TestBluetoothLocalGattServiceDelegate() {}
21
19 void TestBluetoothLocalGattServiceDelegate::OnCharacteristicReadRequest( 22 void TestBluetoothLocalGattServiceDelegate::OnCharacteristicReadRequest(
20 const BluetoothLocalGattService* service, 23 const BluetoothLocalGattService* service,
21 const BluetoothLocalGattCharacteristic* characteristic, 24 const BluetoothLocalGattCharacteristic* characteristic,
22 int offset, 25 int offset,
23 const ValueCallback& callback, 26 const ValueCallback& callback,
24 const ErrorCallback& error_callback) { 27 const ErrorCallback& error_callback) {
25 EXPECT_EQ(expected_service_, service); 28 EXPECT_EQ(expected_service_, service);
26 EXPECT_EQ(expected_characteristic_, characteristic); 29 EXPECT_EQ(expected_characteristic_, characteristic);
27 if (should_fail_) { 30 if (should_fail_) {
28 error_callback.Run(); 31 error_callback.Run();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 EXPECT_EQ(expected_service_, service); 76 EXPECT_EQ(expected_service_, service);
74 EXPECT_EQ(expected_descriptor_, descriptor); 77 EXPECT_EQ(expected_descriptor_, descriptor);
75 if (should_fail_) { 78 if (should_fail_) {
76 error_callback.Run(); 79 error_callback.Run();
77 return; 80 return;
78 } 81 }
79 last_written_value_ = BluetoothGattServerTest::GetInteger(value); 82 last_written_value_ = BluetoothGattServerTest::GetInteger(value);
80 callback.Run(); 83 callback.Run();
81 } 84 }
82 85
86 void TestBluetoothLocalGattServiceDelegate::OnNotificationsStart(
87 const BluetoothLocalGattService* service,
88 const BluetoothLocalGattCharacteristic* characteristic) {
89 EXPECT_EQ(expected_service_, service);
90 EXPECT_EQ(expected_characteristic_, characteristic);
91 notifications_started_for_characteristic_[characteristic->GetIdentifier()] =
92 true;
93 }
94
95 void TestBluetoothLocalGattServiceDelegate::OnNotificationsStop(
96 const BluetoothLocalGattService* service,
97 const BluetoothLocalGattCharacteristic* characteristic) {
98 EXPECT_EQ(expected_service_, service);
99 EXPECT_EQ(expected_characteristic_, characteristic);
100 notifications_started_for_characteristic_[characteristic->GetIdentifier()] =
101 false;
102 }
103
104 bool TestBluetoothLocalGattServiceDelegate::NotificationStatusForCharacteristic(
105 BluetoothLocalGattCharacteristic* characteristic) {
106 auto found = notifications_started_for_characteristic_.find(
107 characteristic->GetIdentifier());
108 if (found == notifications_started_for_characteristic_.end())
109 return false;
110 return found->second;
111 }
112
83 } // namespace device 113 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698