diff options
author | stevenjb <stevenjb@chromium.org> | 2015-11-20 14:05:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-20 22:06:46 +0000 |
commit | 502025c2c3802f36e163e320a819e879a3ddf88f (patch) | |
tree | cfe77581a30ab630ae14edb355728ad1b9c1f1de /device | |
parent | de3c7279759c9bf318961371c5454eeecac508a3 (diff) | |
download | chromium_src-502025c2c3802f36e163e320a819e879a3ddf88f.zip chromium_src-502025c2c3802f36e163e320a819e879a3ddf88f.tar.gz chromium_src-502025c2c3802f36e163e320a819e879a3ddf88f.tar.bz2 |
Use bluetooth and bluetoothPrivate APIs in Options UI
BUG=543294
For device/bluetooth/dbus/
TBR=armansito@chromium.org
Review URL: https://codereview.chromium.org/1434383003
Cr-Commit-Position: refs/heads/master@{#360925}
Diffstat (limited to 'device')
-rw-r--r-- | device/bluetooth/bluetooth_bluez_unittest.cc | 3 | ||||
-rw-r--r-- | device/bluetooth/dbus/fake_bluetooth_device_client.cc | 22 | ||||
-rw-r--r-- | device/bluetooth/dbus/fake_bluetooth_device_client.h | 6 |
3 files changed, 24 insertions, 7 deletions
diff --git a/device/bluetooth/bluetooth_bluez_unittest.cc b/device/bluetooth/bluetooth_bluez_unittest.cc index e82d04d..a01e73d 100644 --- a/device/bluetooth/bluetooth_bluez_unittest.cc +++ b/device/bluetooth/bluetooth_bluez_unittest.cc @@ -175,7 +175,10 @@ class BluetoothBlueZTest : public testing::Test { dbus_setter->SetBluetoothAdapterClient( scoped_ptr<bluez::BluetoothAdapterClient>( fake_bluetooth_adapter_client_)); + fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient; + // Use the original fake behavior for these tests. + fake_bluetooth_device_client_->set_delay_start_discovery(true); dbus_setter->SetBluetoothDeviceClient( scoped_ptr<bluez::BluetoothDeviceClient>( fake_bluetooth_device_client_)); diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc index e6c137b..a2ea92d 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc @@ -267,7 +267,8 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() pairing_cancelled_(false), connection_rssi_(kUnkownPower), transmit_power_(kUnkownPower), - max_transmit_power_(kUnkownPower) { + max_transmit_power_(kUnkownPower), + delay_start_discovery_(false) { scoped_ptr<Properties> properties(new Properties( base::Bind(&FakeBluetoothDeviceClient::OnPropertyChanged, base::Unretained(this), dbus::ObjectPath(kPairedDevicePath)))); @@ -548,12 +549,13 @@ void FakeBluetoothDeviceClient::BeginDiscoverySimulation( VLOG(1) << "starting discovery simulation"; discovery_simulation_step_ = 1; + int delay = delay_start_discovery_ ? simulation_interval_ms_ : 0; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, base::Unretained(this)), - base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); + base::TimeDelta::FromMilliseconds(delay)); } void FakeBluetoothDeviceClient::EndDiscoverySimulation( @@ -1041,12 +1043,17 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() { // Timer fires every .75s, the numbers below are arbitrary to give a feel // for a discovery process. VLOG(1) << "discovery simulation, step " << discovery_simulation_step_; - if (discovery_simulation_step_ == 2) { + uint32_t initial_step = delay_start_discovery_ ? 2 : 1; + if (discovery_simulation_step_ == initial_step) { CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(kLegacyAutopairPath)); CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(kLowEnergyPath)); - + if (!delay_start_discovery_) { + // Include a device that requires a pairing overlay in the UI. + CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(kRequestPinCodePath)); + } } else if (discovery_simulation_step_ == 4) { UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath), base::RandInt(kMinRSSI, kMaxRSSI)); @@ -1064,11 +1071,12 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() { } else if (discovery_simulation_step_ == 8) { CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(kDisplayPasskeyPath)); - CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(kRequestPinCodePath)); + if (delay_start_discovery_) { + CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(kRequestPinCodePath)); + } UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath), base::RandInt(kMinRSSI, kMaxRSSI)); - } else if (discovery_simulation_step_ == 10) { CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(kConfirmPasskeyPath)); diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.h b/device/bluetooth/dbus/fake_bluetooth_device_client.h index f8051b4..67d760b 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.h @@ -145,6 +145,8 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothDeviceClient uint16 transmit_power, uint16 max_transmit_power); + void set_delay_start_discovery(bool value) { delay_start_discovery_ = value; } + static const char kTestPinCode[]; static const int kTestPassKey; @@ -314,6 +316,10 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothDeviceClient int16 connection_rssi_; int16 transmit_power_; int16 max_transmit_power_; + + // Controls the fake behavior to allow more extensive UI testing without + // having to cycle the discovery simulation. + bool delay_start_discovery_; }; } // namespace bluez |