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

Unified Diff: device/bluetooth/test/fake_peripheral.cc

Issue 2874873003: bluetooth: Implement simulateGATTConnectionResponse() (Closed)
Patch Set: Merge branch 'bluetooth-generate-with-headers' into bluetooth-simulate-gatt-discovery-complete Created 3 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/test/fake_peripheral.cc
diff --git a/device/bluetooth/test/fake_peripheral.cc b/device/bluetooth/test/fake_peripheral.cc
index 1515e991b9f194914b363e65f15705cd27e11c72..855f2b3376ae2289e0c39780dc24bc27d77b4a97 100644
--- a/device/bluetooth/test/fake_peripheral.cc
+++ b/device/bluetooth/test/fake_peripheral.cc
@@ -4,6 +4,8 @@
#include "device/bluetooth/test/fake_peripheral.h"
+#include "device/bluetooth/bluetooth_gatt_connection.h"
+
namespace bluetooth {
FakePeripheral::FakePeripheral(FakeCentral* fake_central,
@@ -26,6 +28,22 @@ void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) {
service_uuids_ = std::move(service_uuids);
}
+void FakePeripheral::SimulateGATTConnectionResponse(uint16_t code) {
+ CreateGattConnectionCallbacks callbacks =
scheib 2017/05/12 05:43:55 Call up to BluetoothDevice::DidConnectGatt DidFail
ortuno 2017/05/15 07:01:30 Happy to change it but I would like to understand
+ create_gatt_connection_callbacks_.front();
+ create_gatt_connection_callbacks_.pop();
+ if (code == mojom::kHCISuccess) {
+ gatt_connected_ = true;
+ callbacks.first.Run(
+ base::MakeUnique<device::BluetoothGattConnection>(adapter_, address_));
+ adapter_->NotifyDeviceChanged(this);
+ } else if (code == mojom::kHCIConnectionTimeout) {
+ callbacks.second.Run(ERROR_FAILED);
+ } else {
+ callbacks.second.Run(ERROR_UNKNOWN);
+ }
+}
+
uint32_t FakePeripheral::GetBluetoothClass() const {
NOTREACHED();
return 0;
@@ -178,11 +196,16 @@ void FakePeripheral::ConnectToServiceInsecurely(
NOTREACHED();
}
+void FakePeripheral::CreateGattConnection(
+ const GattConnectionCallback& callback,
+ const ConnectErrorCallback& error_callback) {
+ create_gatt_connection_callbacks_.push({callback, error_callback});
+}
+
void FakePeripheral::CreateGattConnectionImpl() {
NOTREACHED();
}
void FakePeripheral::DisconnectGatt() {
- NOTREACHED();
}
} // namespace bluetooth

Powered by Google App Engine
This is Rietveld 408576698