From 1e9f0c90c10d405dacfe7ab9b5ae4c1c05227a98 Mon Sep 17 00:00:00 2001 From: jyasskin Date: Thu, 24 Sep 2015 09:58:31 -0700 Subject: Handle RESCAN events from the Bluetooth chooser by starting or extending a discovery session. I also added interfaces to support tests that this works, documented in https://github.com/WebBluetoothCG/web-bluetooth/pull/165. BUG=533185 TBR=mkwst@chromium.org Review URL: https://codereview.chromium.org/1353053002 Cr-Commit-Position: refs/heads/master@{#350586} --- device/bluetooth/test/mock_bluetooth_adapter.cc | 11 +++++++++++ device/bluetooth/test/mock_bluetooth_adapter.h | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'device') diff --git a/device/bluetooth/test/mock_bluetooth_adapter.cc b/device/bluetooth/test/mock_bluetooth_adapter.cc index 8054d69..26ae68b 100644 --- a/device/bluetooth/test/mock_bluetooth_adapter.cc +++ b/device/bluetooth/test/mock_bluetooth_adapter.cc @@ -8,10 +8,21 @@ namespace device { +using testing::Invoke; +using testing::_; + MockBluetoothAdapter::Observer::Observer() {} MockBluetoothAdapter::Observer::~Observer() {} MockBluetoothAdapter::MockBluetoothAdapter() { + ON_CALL(*this, AddObserver(_)) + .WillByDefault(Invoke([this](BluetoothAdapter::Observer* observer) { + this->BluetoothAdapter::AddObserver(observer); + })); + ON_CALL(*this, RemoveObserver(_)) + .WillByDefault(Invoke([this](BluetoothAdapter::Observer* observer) { + this->BluetoothAdapter::RemoveObserver(observer); + })); } MockBluetoothAdapter::~MockBluetoothAdapter() {} diff --git a/device/bluetooth/test/mock_bluetooth_adapter.h b/device/bluetooth/test/mock_bluetooth_adapter.h index 6d1ee73..775adee 100644 --- a/device/bluetooth/test/mock_bluetooth_adapter.h +++ b/device/bluetooth/test/mock_bluetooth_adapter.h @@ -109,6 +109,13 @@ class MockBluetoothAdapter : public BluetoothAdapter { BluetoothAdapter::ConstDeviceList GetConstMockDevices(); BluetoothAdapter::DeviceList GetMockDevices(); + // The observers are maintained by the default behavior of AddObserver() and + // RemoveObserver(). Test fakes can use this function to notify the observers + // about events. + base::ObserverList& GetObservers() { + return observers_; + } + protected: void AddDiscoverySession( BluetoothDiscoveryFilter* discovery_filter, -- cgit v1.1