OLD | NEW |
(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 #include "device/bluetooth/test/fake_bluetooth.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/memory/ptr_util.h" |
| 10 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 11 #include "device/bluetooth/public/interfaces/fake_bluetooth.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 |
| 14 namespace bluetooth { |
| 15 |
| 16 FakeBluetooth::FakeBluetooth() {} |
| 17 FakeBluetooth::~FakeBluetooth() {} |
| 18 |
| 19 // static |
| 20 void FakeBluetooth::Create(mojom::FakeBluetoothRequest request) { |
| 21 mojo::MakeStrongBinding(base::MakeUnique<FakeBluetooth>(), |
| 22 std::move(request)); |
| 23 } |
| 24 |
| 25 void FakeBluetooth::SetLEAvailability( |
| 26 bool available, |
| 27 const SetLEAvailabilityCallback& callback) { |
| 28 device::BluetoothAdapterFactory::SetAvailability(available); |
| 29 callback.Run(); |
| 30 } |
| 31 |
| 32 void FakeBluetooth::SimulateLECentralManager( |
| 33 mojom::FakeLECentralManagerOptionsPtr options, |
| 34 const SimulateLECentralManagerCallback& callback) { |
| 35 mojom::FakeLECentralManagerPtr central_manager_ptr; |
| 36 |
| 37 // TODO: Use a scoped_refptr |
| 38 new FakeLECentralManager(std::move(options), |
| 39 mojo::MakeRequest(¢ral_manager_ptr)); |
| 40 |
| 41 // device::BluetoothAdapterFactory::Get().SetBluetoothAdapterForTesting( |
| 42 // manager); |
| 43 |
| 44 callback.Run(std::move(central_manager_ptr)); |
| 45 } |
| 46 |
| 47 FakeLECentralManager::FakeLECentralManager( |
| 48 mojom::FakeLECentralManagerOptionsPtr options, |
| 49 mojom::FakeLECentralManagerRequest request) |
| 50 : state_(options->state), |
| 51 binding_(this, std::move(request)), |
| 52 start_scan_calls_(0), |
| 53 stop_scan_calls_(0) {} |
| 54 |
| 55 FakeLECentralManager::~FakeLECentralManager() {} |
| 56 |
| 57 void FakeLECentralManager::SimulateAdvertisementReceived( |
| 58 mojom::ScanResultPtr result, |
| 59 const SimulateAdvertisementReceivedCallback& callback) { |
| 60 // for all observers dispatch device added or changed. |
| 61 mojom::FakeLEPeripheralPtr peripheral_ptr; |
| 62 mojo::MakeStrongBinding( |
| 63 base::MakeUnique<FakeLEPeripheral>(result->device_address), |
| 64 mojo::MakeRequest(&peripheral_ptr)); |
| 65 callback.Run(std::move(peripheral_ptr)); |
| 66 } |
| 67 |
| 68 void FakeLECentralManager::AddConnectedLEPeripheral( |
| 69 mojom::FakeLEPeripheralOptionsPtr options, |
| 70 const AddConnectedLEPeripheralCallback& callback) { |
| 71 mojom::FakeLEPeripheralPtr peripheral_ptr; |
| 72 mojo::MakeStrongBinding(base::MakeUnique<FakeLEPeripheral>(options->address), |
| 73 mojo::MakeRequest(&peripheral_ptr)); |
| 74 callback.Run(std::move(peripheral_ptr)); |
| 75 } |
| 76 |
| 77 void FakeLECentralManager::SetState(mojom::FakeLECentralManagerState state, |
| 78 const SetStateCallback& callback) { |
| 79 state_ = state; |
| 80 callback.Run(); |
| 81 } |
| 82 |
| 83 void FakeLECentralManager::GetStartScanCalls( |
| 84 const GetStartScanCallsCallback& callback) { |
| 85 callback.Run(start_scan_calls_); |
| 86 } |
| 87 |
| 88 void FakeLECentralManager::GetStopScanCalls( |
| 89 const GetStopScanCallsCallback& callback) { |
| 90 callback.Run(stop_scan_calls_); |
| 91 } |
| 92 |
| 93 std::string FakeLECentralManager::GetAddress() const { |
| 94 return "Some address"; |
| 95 } |
| 96 |
| 97 std::string FakeLECentralManager::GetName() const { |
| 98 return "Some name"; |
| 99 } |
| 100 |
| 101 void FakeLECentralManager::SetName( |
| 102 const std::string& name, |
| 103 const base::Closure& callback, |
| 104 const device::BluetoothAdapter::ErrorCallback& error_callback) { |
| 105 error_callback.Run(); |
| 106 } |
| 107 |
| 108 bool FakeLECentralManager::IsInitialized() const { |
| 109 return true; |
| 110 } |
| 111 |
| 112 bool FakeLECentralManager::IsPresent() const { |
| 113 if (state_ == mojom::FakeLECentralManagerState::ABSENT) { |
| 114 return false; |
| 115 } |
| 116 return true; |
| 117 } |
| 118 |
| 119 bool FakeLECentralManager::IsPowered() const { |
| 120 switch(state_) { |
| 121 case mojom::FakeLECentralManagerState::ABSENT: |
| 122 case mojom::FakeLECentralManagerState::POWERED_OFF: |
| 123 return false; |
| 124 case mojom::FakeLECentralManagerState::POWERED_ON: |
| 125 return true; |
| 126 } |
| 127 NOTREACHED(); |
| 128 return false; |
| 129 } |
| 130 |
| 131 void FakeLECentralManager::SetPowered( |
| 132 bool powered, |
| 133 const base::Closure& callback, |
| 134 const device::BluetoothAdapter::ErrorCallback& error_callback) { |
| 135 error_callback.Run(); |
| 136 } |
| 137 |
| 138 bool FakeLECentralManager::IsDiscoverable() const { |
| 139 return false; |
| 140 } |
| 141 |
| 142 void FakeLECentralManager::SetDiscoverable( |
| 143 bool discoverable, |
| 144 const base::Closure& callback, |
| 145 const ErrorCallback& error_callback) { |
| 146 error_callback.Run(); |
| 147 } |
| 148 |
| 149 bool FakeLECentralManager::IsDiscovering() const { |
| 150 return false; |
| 151 } |
| 152 |
| 153 device::BluetoothAdapter::UUIDList FakeLECentralManager::GetUUIDs() const { |
| 154 return device::BluetoothAdapter::UUIDList(); |
| 155 } |
| 156 |
| 157 void FakeLECentralManager::CreateRfcommService( |
| 158 const device::BluetoothUUID& uuid, |
| 159 const device::BluetoothAdapter::ServiceOptions& options, |
| 160 const device::BluetoothAdapter::CreateServiceCallback& callback, |
| 161 const device::BluetoothAdapter::CreateServiceErrorCallback& |
| 162 error_callback) { |
| 163 error_callback.Run("Unsupported"); |
| 164 } |
| 165 |
| 166 void FakeLECentralManager::CreateL2capService( |
| 167 const device::BluetoothUUID& uuid, |
| 168 const device::BluetoothAdapter::ServiceOptions& options, |
| 169 const device::BluetoothAdapter::CreateServiceCallback& callback, |
| 170 const device::BluetoothAdapter::CreateServiceErrorCallback& |
| 171 error_callback) { |
| 172 error_callback.Run("Unsupported"); |
| 173 } |
| 174 |
| 175 void FakeLECentralManager::SetAdvertisingInterval( |
| 176 const base::TimeDelta& min, |
| 177 const base::TimeDelta& max, |
| 178 const base::Closure& callback, |
| 179 const device::BluetoothAdapter::AdvertisementErrorCallback& |
| 180 error_callback) { |
| 181 callback.Run(); |
| 182 } |
| 183 |
| 184 void FakeLECentralManager::RegisterAdvertisement( |
| 185 std::unique_ptr<device::BluetoothAdvertisement::Data> advertisement_data, |
| 186 const device::BluetoothAdapter::CreateAdvertisementCallback& callback, |
| 187 const device::BluetoothAdapter::AdvertisementErrorCallback& error_callback
) { |
| 188 } |
| 189 |
| 190 |
| 191 device::BluetoothLocalGattService* |
| 192 FakeLECentralManager::GetGattService(const std::string& identifier) const { |
| 193 return nullptr; |
| 194 } |
| 195 |
| 196 void FakeLECentralManager::AddDiscoverySession( |
| 197 device::BluetoothDiscoveryFilter* discovery_filter, |
| 198 const base::Closure& callback, |
| 199 const device::BluetoothAdapter::DiscoverySessionErrorCallback& |
| 200 error_callback) { |
| 201 callback.Run(); |
| 202 } |
| 203 |
| 204 void FakeLECentralManager::RemoveDiscoverySession( |
| 205 device::BluetoothDiscoveryFilter* discovery_filter, |
| 206 const base::Closure& callback, |
| 207 const device::BluetoothAdapter::DiscoverySessionErrorCallback& |
| 208 error_callback) { |
| 209 callback.Run(); |
| 210 } |
| 211 |
| 212 void FakeLECentralManager::SetDiscoveryFilter( |
| 213 std::unique_ptr<device::BluetoothDiscoveryFilter> |
| 214 discovery_filter, |
| 215 const base::Closure& callback, |
| 216 const device::BluetoothAdapter::DiscoverySessionErrorCallback& |
| 217 error_callback) { |
| 218 callback.Run(); |
| 219 } |
| 220 |
| 221 void FakeLECentralManager::RemovePairingDelegateInternal( |
| 222 device::BluetoothDevice::PairingDelegate* pairing_delegate) { |
| 223 } |
| 224 |
| 225 FakeLEPeripheral::FakeLEPeripheral(const std::string& address) |
| 226 : BluetoothDevice(nullptr), address_(address) {} |
| 227 |
| 228 FakeLEPeripheral::~FakeLEPeripheral() { |
| 229 } |
| 230 |
| 231 void FakeLEPeripheral::SimulateGATTConnection( |
| 232 mojom::GATTConnectionResult result, |
| 233 const SimulateGATTConnectionCallback& callback) { |
| 234 callback.Run(); |
| 235 } |
| 236 |
| 237 void FakeLEPeripheral::SimulateGATTDiscoveryComplete( |
| 238 const SimulateGATTDiscoveryCompleteCallback& callback) { |
| 239 callback.Run(); |
| 240 } |
| 241 |
| 242 void FakeLEPeripheral::SimulateGATTServicesChanged( |
| 243 const SimulateGATTServicesChangedCallback& callback) { |
| 244 callback.Run(); |
| 245 } |
| 246 |
| 247 void FakeLEPeripheral::AddFakeService( |
| 248 mojom::FakeRemoteGATTServiceOptionsPtr options, |
| 249 const AddFakeServiceCallback& callback) { |
| 250 mojom::FakeRemoteGATTServicePtr service_ptr; |
| 251 mojo::MakeStrongBinding( |
| 252 base::MakeUnique<FakeRemoteGATTService>(std::move(options)), |
| 253 mojo::MakeRequest(&service_ptr)); |
| 254 callback.Run(std::move(service_ptr)); |
| 255 } |
| 256 |
| 257 void FakeLEPeripheral::GetConnectCalls( |
| 258 const GetConnectCallsCallback& callback) { |
| 259 callback.Run(connect_calls_); |
| 260 } |
| 261 |
| 262 void FakeLEPeripheral::GetDisconnectCalls( |
| 263 const GetDisconnectCallsCallback& callback) { |
| 264 callback.Run(disconnect_calls_); |
| 265 } |
| 266 |
| 267 uint32_t FakeLEPeripheral::GetBluetoothClass() const { |
| 268 return 0; |
| 269 } |
| 270 |
| 271 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 272 device::BluetoothTransport FakeLEPeripheral::GetType() const { |
| 273 return device::BLUETOOTH_TRANSPORT_INVALID; |
| 274 } |
| 275 #endif |
| 276 |
| 277 std::string FakeLEPeripheral::GetIdentifier() const { |
| 278 return "some identifier"; |
| 279 } |
| 280 |
| 281 std::string FakeLEPeripheral::GetAddress() const { |
| 282 return "some address"; |
| 283 } |
| 284 |
| 285 device::BluetoothDevice::VendorIDSource FakeLEPeripheral::GetVendorIDSource() co
nst { |
| 286 return device::BluetoothDevice::VENDOR_ID_UNKNOWN; |
| 287 } |
| 288 |
| 289 uint16_t FakeLEPeripheral::GetVendorID() const { |
| 290 return 0; |
| 291 } |
| 292 |
| 293 uint16_t FakeLEPeripheral::GetProductID() const { |
| 294 return 1; |
| 295 } |
| 296 |
| 297 uint16_t FakeLEPeripheral::GetDeviceID() const { |
| 298 return 2; |
| 299 } |
| 300 |
| 301 uint16_t FakeLEPeripheral::GetAppearance() const { |
| 302 return 3; |
| 303 } |
| 304 |
| 305 base::Optional<std::string> FakeLEPeripheral::GetName() const { |
| 306 return std::string(); |
| 307 } |
| 308 |
| 309 bool FakeLEPeripheral::IsPaired() const { |
| 310 return false; |
| 311 } |
| 312 |
| 313 bool FakeLEPeripheral::IsConnected() const { |
| 314 return false; |
| 315 } |
| 316 |
| 317 bool FakeLEPeripheral::IsGattConnected() const { |
| 318 return false; |
| 319 } |
| 320 |
| 321 bool FakeLEPeripheral::IsConnectable() const { |
| 322 return true; |
| 323 } |
| 324 |
| 325 bool FakeLEPeripheral::IsConnecting() const { |
| 326 return false; |
| 327 } |
| 328 |
| 329 bool FakeLEPeripheral::ExpectingPinCode() const { |
| 330 return false; |
| 331 } |
| 332 |
| 333 bool FakeLEPeripheral::ExpectingPasskey() const { |
| 334 return false; |
| 335 } |
| 336 |
| 337 bool FakeLEPeripheral::ExpectingConfirmation() const { |
| 338 return false; |
| 339 } |
| 340 |
| 341 void FakeLEPeripheral::GetConnectionInfo(const device::BluetoothDevice::Connecti
onInfoCallback& callback) { |
| 342 } |
| 343 |
| 344 void FakeLEPeripheral::Connect(device::BluetoothDevice::PairingDelegate* pairing
_delegate, |
| 345 const base::Closure& callback, |
| 346 const device::BluetoothDevice::ConnectErrorCallba
ck& error_callback) { |
| 347 callback.Run(); |
| 348 } |
| 349 |
| 350 void FakeLEPeripheral::SetPinCode(const std::string& pincode) { |
| 351 } |
| 352 |
| 353 void FakeLEPeripheral::SetPasskey(uint32_t passkey) { |
| 354 } |
| 355 |
| 356 void FakeLEPeripheral::ConfirmPairing() { |
| 357 } |
| 358 |
| 359 void FakeLEPeripheral::RejectPairing() { |
| 360 } |
| 361 |
| 362 void FakeLEPeripheral::CancelPairing() { |
| 363 } |
| 364 |
| 365 void FakeLEPeripheral::Disconnect(const base::Closure& callback, |
| 366 const device::BluetoothDevice::ErrorCallback&
error_callback) { |
| 367 callback.Run(); |
| 368 } |
| 369 |
| 370 void FakeLEPeripheral::Forget(const base::Closure& callback, |
| 371 const device::BluetoothDevice::ErrorCallback& erro
r_callback) { |
| 372 callback.Run(); |
| 373 } |
| 374 |
| 375 void FakeLEPeripheral::ConnectToService( |
| 376 const device::BluetoothUUID& uuid, |
| 377 const device::BluetoothDevice::ConnectToServiceCallback& callback, |
| 378 const device::BluetoothDevice::ConnectToServiceErrorCallback& error_callba
ck) { |
| 379 } |
| 380 |
| 381 void FakeLEPeripheral::ConnectToServiceInsecurely( |
| 382 const device::BluetoothUUID& uuid, |
| 383 const device::BluetoothDevice::ConnectToServiceCallback& callback, |
| 384 const device::BluetoothDevice::ConnectToServiceErrorCallback& error_callback
) { |
| 385 } |
| 386 |
| 387 void FakeLEPeripheral::CreateGattConnectionImpl() { |
| 388 } |
| 389 |
| 390 void FakeLEPeripheral::DisconnectGatt() { |
| 391 } |
| 392 |
| 393 FakeRemoteGATTService::FakeRemoteGATTService( |
| 394 mojom::FakeRemoteGATTServiceOptionsPtr options) |
| 395 : uuid_(options->uuid) {} |
| 396 |
| 397 void FakeRemoteGATTService::AddFakeCharacteristic( |
| 398 mojom::FakeRemoteGATTCharacteristicOptionsPtr options, |
| 399 const AddFakeCharacteristicCallback& callback) { |
| 400 mojom::FakeRemoteGATTCharacteristicPtr char_ptr; |
| 401 mojo::MakeStrongBinding( |
| 402 base::MakeUnique<FakeRemoteGATTCharacteristic>(std::move(options)), |
| 403 mojo::MakeRequest(&char_ptr)); |
| 404 callback.Run(std::move(char_ptr)); |
| 405 } |
| 406 |
| 407 void FakeRemoteGATTService::AddFakeIncludedService( |
| 408 mojom::FakeRemoteGATTServiceOptionsPtr options, |
| 409 const AddFakeIncludedServiceCallback& callback) { |
| 410 mojom::FakeRemoteGATTServicePtr service_ptr; |
| 411 mojo::MakeStrongBinding( |
| 412 base::MakeUnique<FakeRemoteGATTService>(std::move(options)), |
| 413 mojo::MakeRequest(&service_ptr)); |
| 414 callback.Run(std::move(service_ptr)); |
| 415 } |
| 416 |
| 417 std::string FakeRemoteGATTService::GetIdentifier() const { |
| 418 return "some identifier"; |
| 419 } |
| 420 |
| 421 device::BluetoothUUID FakeRemoteGATTService::GetUUID() const { |
| 422 return device::BluetoothUUID(); |
| 423 } |
| 424 |
| 425 device::BluetoothDevice* FakeRemoteGATTService::GetDevice() const { |
| 426 return nullptr; |
| 427 } |
| 428 |
| 429 bool FakeRemoteGATTService::IsPrimary() const { |
| 430 return true; |
| 431 } |
| 432 |
| 433 std::vector<device::BluetoothRemoteGattCharacteristic*> FakeRemoteGATTService::G
etCharacteristics() const { |
| 434 return std::vector<device::BluetoothRemoteGattCharacteristic*>(); |
| 435 } |
| 436 |
| 437 std::vector<device::BluetoothRemoteGattService*> FakeRemoteGATTService::GetInclu
dedServices() const { |
| 438 return std::vector<device::BluetoothRemoteGattService*>(); |
| 439 } |
| 440 |
| 441 device::BluetoothRemoteGattCharacteristic* FakeRemoteGATTService::GetCharacteris
tic(const std::string& identifier) const { |
| 442 return nullptr; |
| 443 } |
| 444 |
| 445 FakeRemoteGATTCharacteristic::FakeRemoteGATTCharacteristic( |
| 446 mojom::FakeRemoteGATTCharacteristicOptionsPtr options) |
| 447 : uuid_(options->uuid), permissions_(options->permissions) {} |
| 448 |
| 449 FakeRemoteGATTCharacteristic::~FakeRemoteGATTCharacteristic() {} |
| 450 |
| 451 void FakeRemoteGATTCharacteristic::SimulateRead( |
| 452 mojom::GATTOperationResult result, |
| 453 const base::Optional<std::vector<uint8_t>>& value, |
| 454 const SimulateReadCallback& callback) { |
| 455 callback.Run(); |
| 456 } |
| 457 |
| 458 void FakeRemoteGATTCharacteristic::SimulateWrite( |
| 459 mojom::GATTOperationResult result, |
| 460 const SimulateWriteCallback& callback) { |
| 461 callback.Run(std::vector<uint8_t>()); |
| 462 } |
| 463 |
| 464 void FakeRemoteGATTCharacteristic::SimulateNotificationsStarted( |
| 465 mojom::GATTOperationResult result, |
| 466 const SimulateNotificationsStartedCallback& callback) { |
| 467 callback.Run(); |
| 468 } |
| 469 |
| 470 void FakeRemoteGATTCharacteristic::SimulateNotificationsStopped( |
| 471 mojom::GATTOperationResult result, |
| 472 const SimulateNotificationsStoppedCallback& callback) { |
| 473 callback.Run(); |
| 474 } |
| 475 |
| 476 void FakeRemoteGATTCharacteristic::SimulateNotification( |
| 477 mojom::FakeNotificationOptionsPtr options, |
| 478 const SimulateNotificationCallback& callback) { |
| 479 callback.Run(); |
| 480 } |
| 481 |
| 482 void FakeRemoteGATTCharacteristic::AddFakeDescriptor( |
| 483 mojom::FakeRemoteGATTDescriptorOptionsPtr options, |
| 484 const AddFakeDescriptorCallback& callback) { |
| 485 mojom::FakeRemoteGATTDescriptorPtr desc_ptr; |
| 486 mojo::MakeStrongBinding( |
| 487 base::MakeUnique<FakeRemoteGATTDescriptor>(std::move(options)), |
| 488 mojo::MakeRequest(&desc_ptr)); |
| 489 callback.Run(std::move(desc_ptr)); |
| 490 } |
| 491 |
| 492 void FakeRemoteGATTCharacteristic::GetReadCalls( |
| 493 const GetReadCallsCallback& callback) { |
| 494 callback.Run(read_calls_); |
| 495 } |
| 496 |
| 497 void FakeRemoteGATTCharacteristic::GetWriteCalls( |
| 498 const GetWriteCallsCallback& callback) { |
| 499 callback.Run(write_calls_); |
| 500 } |
| 501 |
| 502 void FakeRemoteGATTCharacteristic::GetStartNotificationsCalls( |
| 503 const GetStartNotificationsCallsCallback& callback) { |
| 504 callback.Run(start_notifications_calls_); |
| 505 } |
| 506 |
| 507 void FakeRemoteGATTCharacteristic::GetStopNotificationsCalls( |
| 508 const GetStopNotificationsCallsCallback& callback) { |
| 509 callback.Run(stop_notifications_calls_); |
| 510 } |
| 511 |
| 512 std::string FakeRemoteGATTCharacteristic::GetIdentifier() const { |
| 513 return "Char identifier"; |
| 514 } |
| 515 |
| 516 device::BluetoothUUID FakeRemoteGATTCharacteristic::GetUUID() const { |
| 517 return device::BluetoothUUID("1208"); |
| 518 } |
| 519 |
| 520 device::BluetoothGattCharacteristic::Properties FakeRemoteGATTCharacteristic::Ge
tProperties() const { |
| 521 return 0; |
| 522 } |
| 523 |
| 524 device::BluetoothRemoteGattCharacteristic::Permissions FakeRemoteGATTCharacteris
tic::GetPermissions() const { |
| 525 return 1; |
| 526 } |
| 527 |
| 528 const std::vector<uint8_t>& FakeRemoteGATTCharacteristic::GetValue() const { |
| 529 return value_; |
| 530 } |
| 531 |
| 532 device::BluetoothRemoteGattService* FakeRemoteGATTCharacteristic::GetService() c
onst { |
| 533 return nullptr; |
| 534 } |
| 535 |
| 536 std::vector<device::BluetoothRemoteGattDescriptor*> FakeRemoteGATTCharacteristic
::GetDescriptors() const { |
| 537 return std::vector<device::BluetoothRemoteGattDescriptor*>(); |
| 538 } |
| 539 |
| 540 device::BluetoothRemoteGattDescriptor* FakeRemoteGATTCharacteristic::GetDescript
or(const std::string& identifier) const { |
| 541 return nullptr; |
| 542 } |
| 543 |
| 544 void FakeRemoteGATTCharacteristic::ReadRemoteCharacteristic(const device::Blueto
othRemoteGattCharacteristic::ValueCallback& callback, |
| 545 const device::Blueto
othRemoteGattCharacteristic::ErrorCallback& error_callback) { |
| 546 } |
| 547 |
| 548 void FakeRemoteGATTCharacteristic::WriteRemoteCharacteristic(const std::vector<u
int8_t>& value, |
| 549 const base::Closure& callback, |
| 550 const device::Bluet
oothRemoteGattCharacteristic::ErrorCallback& error_callback) { |
| 551 callback.Run(); |
| 552 } |
| 553 |
| 554 void FakeRemoteGATTCharacteristic::SubscribeToNotifications(device::BluetoothRem
oteGattDescriptor* ccc_descriptor, |
| 555 const base::Closure& callback, |
| 556 const device::Blueto
othRemoteGattCharacteristic::ErrorCallback& error_callback) { |
| 557 callback.Run(); |
| 558 } |
| 559 |
| 560 void FakeRemoteGATTCharacteristic::UnsubscribeFromNotifications( |
| 561 device::BluetoothRemoteGattDescriptor* ccc_descriptor, |
| 562 const base::Closure& callback, |
| 563 const device::BluetoothRemoteGattCharacteristic::ErrorCallback& error_call
back) { |
| 564 callback.Run(); |
| 565 } |
| 566 |
| 567 FakeRemoteGATTDescriptor::FakeRemoteGATTDescriptor( |
| 568 mojom::FakeRemoteGATTDescriptorOptionsPtr options) |
| 569 : uuid_(options->uuid) {} |
| 570 |
| 571 FakeRemoteGATTDescriptor::~FakeRemoteGATTDescriptor() {} |
| 572 |
| 573 void FakeRemoteGATTDescriptor::SimulateRead( |
| 574 mojom::GATTOperationResult result, |
| 575 const base::Optional<std::vector<uint8_t>>& value, |
| 576 const SimulateReadCallback& callback) { |
| 577 callback.Run(); |
| 578 } |
| 579 |
| 580 void FakeRemoteGATTDescriptor::SimulateWrite( |
| 581 mojom::GATTOperationResult result, |
| 582 const SimulateWriteCallback& callback) { |
| 583 callback.Run(std::vector<uint8_t>()); |
| 584 } |
| 585 |
| 586 std::string FakeRemoteGATTDescriptor::GetIdentifier() const { |
| 587 return "desc identifier"; |
| 588 } |
| 589 |
| 590 device::BluetoothUUID FakeRemoteGATTDescriptor::GetUUID() const { |
| 591 return device::BluetoothUUID(); |
| 592 } |
| 593 |
| 594 device::BluetoothRemoteGattCharacteristic::Permissions FakeRemoteGATTDescriptor:
:GetPermissions() const { |
| 595 return 10; |
| 596 } |
| 597 const std::vector<uint8_t>& FakeRemoteGATTDescriptor::GetValue() const { |
| 598 return value_; |
| 599 } |
| 600 |
| 601 device::BluetoothRemoteGattCharacteristic* FakeRemoteGATTDescriptor::GetCharacte
ristic() const { |
| 602 return nullptr; |
| 603 } |
| 604 |
| 605 void FakeRemoteGATTDescriptor::ReadRemoteDescriptor(const device::BluetoothRemot
eGattCharacteristic::ValueCallback& callback, |
| 606 const device::BluetoothRemot
eGattCharacteristic::ErrorCallback& error_callback) { |
| 607 } |
| 608 |
| 609 void FakeRemoteGATTDescriptor::WriteRemoteDescriptor(const std::vector<uint8_t>&
new_value, |
| 610 const base::Closure& callba
ck, |
| 611 const device::BluetoothRemo
teGattCharacteristic::ErrorCallback& error_callback) { |
| 612 callback.Run(); |
| 613 } |
| 614 |
| 615 } // namespace bluetooth |
OLD | NEW |