Chromium Code Reviews| Index: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| index cbc26aff1d2262f35f14a477fe66cbbff1214b45..babee704ee7944b3ebbc5950b8016baa17f26ef1 100644 |
| --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| @@ -4,8 +4,12 @@ |
| #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h" |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| #include "base/format_macros.h" |
| +#include "base/location.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/thread_task_runner_handle.h" |
| #include "device/bluetooth/bluetooth_adapter.h" |
| #include "device/bluetooth/bluetooth_device.h" |
| #include "device/bluetooth/bluetooth_discovery_session.h" |
| @@ -122,6 +126,8 @@ LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter( |
| return GetFailingConnectionsAdapter(); |
| else if (fake_adapter_name == "FailingGATTOperationsAdapter") |
| return GetFailingGATTOperationsAdapter(); |
| + else if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") |
| + return GetSecondDiscoveryFindsHeartRateAdapter(); |
| else if (fake_adapter_name == "") |
| return NULL; |
| @@ -248,6 +254,36 @@ LayoutTestBluetoothAdapterProvider::GetGlucoseHeartRateAdapter() { |
| return adapter.Pass(); |
| } |
| +static void AddDevice(scoped_refptr<NiceMockBluetoothAdapter> adapter, |
|
scheib
2015/09/23 03:35:00
This is hard enough to trace code flow to warrant
Jeffrey Yasskin
2015/09/23 19:32:05
Done.
|
| + scoped_ptr<NiceMockBluetoothDevice> new_device) { |
| + NiceMockBluetoothDevice* new_device_ptr = new_device.get(); |
| + adapter->AddMockDevice(new_device.Pass()); |
| + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter->GetObservers(), |
| + DeviceAdded(adapter.get(), new_device_ptr)); |
| +} |
| + |
| +// static |
| +scoped_refptr<NiceMockBluetoothAdapter> |
| +LayoutTestBluetoothAdapterProvider::GetSecondDiscoveryFindsHeartRateAdapter() { |
| + scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPoweredAdapter()); |
| + NiceMockBluetoothAdapter* adapter_ptr = adapter.get(); |
| + |
| + EXPECT_CALL(*adapter, StartDiscoverySessionWithFilterRaw(_, _, _)) |
| + .WillOnce(RunCallbackWithResult<1 /* success_callback */>( |
| + []() { return GetDiscoverySession(); })) |
| + .WillOnce( |
| + RunCallbackWithResult<1 /* success_callback */>([adapter_ptr]() { |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&AddDevice, make_scoped_refptr(adapter_ptr), |
| + |
| + base::Passed(GetHeartRateDevice(adapter_ptr)))); |
| + return GetDiscoverySession(); |
| + })); |
| + |
| + return adapter; |
| +} |
| + |
| // static |
| scoped_refptr<NiceMockBluetoothAdapter> |
| LayoutTestBluetoothAdapterProvider::GetMissingServiceGenericAccessAdapter() { |