Commit f468a538 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth: FakeBluetoothChooser never timeout scan

Allows FakeBluetoothChooser to set the test scan duration to never
timeout.

BUG=719827

Change-Id: I38c74a1bbb0de026edb7d578b98258941d0c3349
Reviewed-on: https://chromium-review.googlesource.com/961544Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545105}
parent b0528087
......@@ -153,8 +153,12 @@ gfx::ColorSpace GetTestingColorSpace(const std::string& name);
void SetDeviceColorSpace(RenderView* render_view,
const gfx::ColorSpace& color_space);
// Sets the scan duration to 0.
void SetTestBluetoothScanDuration();
// Sets the scan duration to reflect the given setting.
enum class BluetoothTestScanDurationSetting {
kImmediateTimeout, // Set the scan duration to 0 seconds.
kNeverTimeout, // Set the scan duration to base::TimeDelta::Max() seconds.
};
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting);
// Enables or disables synchronous resize mode. When enabled, all window-sizing
// machinery is short-circuited inside the renderer. This mode is necessary for
......
......@@ -8,15 +8,20 @@
#include <utility>
#include "content/public/browser/bluetooth_chooser.h"
#include "content/public/test/layouttest_support.h"
#include "content/shell/common/layout_test/fake_bluetooth_chooser.mojom.h"
namespace content {
FakeBluetoothChooser::~FakeBluetoothChooser() = default;
FakeBluetoothChooser::~FakeBluetoothChooser() {
SetTestBluetoothScanDuration(
BluetoothTestScanDurationSetting::kImmediateTimeout);
}
// static
std::unique_ptr<FakeBluetoothChooser> FakeBluetoothChooser::Create(
mojom::FakeBluetoothChooserRequest request) {
SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting::kNeverTimeout);
return std::unique_ptr<FakeBluetoothChooser>(
new FakeBluetoothChooser(std::move(request)));
}
......
......@@ -28,6 +28,7 @@ namespace content {
class FakeBluetoothChooser : public mojom::FakeBluetoothChooser,
public BluetoothChooser {
public:
// Resets the test scan duration to timeout immediately.
~FakeBluetoothChooser() override;
// LayoutTestContentBrowserClient will create an instance of this class when a
......
......@@ -32,7 +32,8 @@ void LayoutTestBluetoothFakeAdapterSetterImpl::Create(
void LayoutTestBluetoothFakeAdapterSetterImpl::Set(
const std::string& adapter_name,
SetCallback callback) {
SetTestBluetoothScanDuration();
SetTestBluetoothScanDuration(
BluetoothTestScanDurationSetting::kImmediateTimeout);
device::BluetoothAdapterFactoryWrapper::Get().SetBluetoothAdapterForTesting(
LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(adapter_name));
......
......@@ -507,8 +507,19 @@ void SetDeviceColorSpace(RenderView* render_view,
->SetDeviceColorSpaceForTesting(color_space);
}
void SetTestBluetoothScanDuration() {
BluetoothDeviceChooserController::SetTestScanDurationForTesting();
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) {
switch (setting) {
case BluetoothTestScanDurationSetting::kImmediateTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
IMMEDIATE_TIMEOUT);
break;
case BluetoothTestScanDurationSetting::kNeverTimeout:
BluetoothDeviceChooserController::SetTestScanDurationForTesting(
BluetoothDeviceChooserController::TestScanDurationSetting::
NEVER_TIMEOUT);
break;
}
}
void UseSynchronousResizeMode(RenderView* render_view, bool enable) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment