diff options
Diffstat (limited to 'content/shell/browser')
3 files changed, 51 insertions, 0 deletions
diff --git a/content/shell/browser/blink_test_controller.cc b/content/shell/browser/blink_test_controller.cc index eb15b2d..b9e84e5 100644 --- a/content/shell/browser/blink_test_controller.cc +++ b/content/shell/browser/blink_test_controller.cc @@ -753,6 +753,8 @@ void BlinkTestController::OnSendBluetoothManualChooserEvent( event = BluetoothChooser::Event::CANCELLED; } else if (event_name == "selected") { event = BluetoothChooser::Event::SELECTED; + } else if (event_name == "rescan") { + event = BluetoothChooser::Event::RESCAN; } else { printer_->AddErrorMessage(base::StringPrintf( "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", 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 cbc26af..ed27741 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,40 @@ LayoutTestBluetoothAdapterProvider::GetGlucoseHeartRateAdapter() { return adapter.Pass(); } +// Adds a device to |adapter| and notifies all observers about that new device. +// Mocks can call this asynchronously to cause changes in the middle of a test. +static void AddDevice(scoped_refptr<NiceMockBluetoothAdapter> adapter, + 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]() { + // In the second discovery session, have the adapter discover a new + // device, shortly after the session starts. + 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() { diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h index 9d52de9..ac87afe 100644 --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h @@ -121,6 +121,15 @@ class LayoutTestBluetoothAdapterProvider { static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> GetGlucoseHeartRateAdapter(); + // |SecondDiscoveryFindsHeartRateAdapter| + // Inherits from |PoweredAdapter| + // Mock Functions: + // - StartDiscoverySessionWithFilter: + // Run success callback with |DiscoverySession|. + // After the first call, adds a |HeartRateDevice|. + static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> + GetSecondDiscoveryFindsHeartRateAdapter(); + // |MissingServiceGenericAccessAdapter| // Inherits from |EmptyAdapter| // Internal Structure: |