Commit d4bef19d authored by Phillis Tang's avatar Phillis Tang Committed by Commit Bot

Update tests to remove |BluetoothDiscoverySession::Stop|

The BluetoothDiscoverySession::Stop method callback params will be
removed and |Stop| will be equivalent to the session destructor, update
BluetoothBlueZTest tests to reflect the ongoing refactoring.

Bug: 991682
Change-Id: If5e743407fb08c42c50f0e5ace4da3c7771d8567
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090768Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Phillis Tang <phillis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748282}
parent f0429d00
......@@ -283,6 +283,11 @@ void BluetoothAdapter::NotifyDeviceChanged(BluetoothDevice* device) {
observer.DeviceChanged(this, device);
}
void BluetoothAdapter::NotifyAdapterDiscoveryChangeCompletedForTesting() {
for (auto& observer : observers_)
observer.DiscoveryChangeCompletedForTesting();
}
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
void BluetoothAdapter::NotifyDevicePairedChanged(BluetoothDevice* device,
bool new_paired_status) {
......@@ -468,7 +473,9 @@ void BluetoothAdapter::OnDiscoveryChangeComplete(
return;
discovery_request_pending_ = false;
NotifyAdapterDiscoveryChangeCompletedForTesting();
ProcessDiscoveryQueue();
return;
}
......@@ -494,6 +501,7 @@ void BluetoothAdapter::OnDiscoveryChangeComplete(
return;
discovery_request_pending_ = false;
NotifyAdapterDiscoveryChangeCompletedForTesting();
ProcessDiscoveryQueue();
}
......
......@@ -87,6 +87,9 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
virtual void DeviceAdded(BluetoothAdapter* adapter,
BluetoothDevice* device) {}
// Called when the adapter |DiscoveryChangeComplete| is finished
virtual void DiscoveryChangeCompletedForTesting() {}
// Called when the result of one of the following methods of the device
// |device| changes:
// * GetAddress()
......@@ -592,6 +595,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
void NotifyAdapterPresentChanged(bool present);
void NotifyAdapterPoweredChanged(bool powered);
void NotifyDeviceChanged(BluetoothDevice* device);
void NotifyAdapterDiscoveryChangeCompletedForTesting();
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
void NotifyDevicePairedChanged(BluetoothDevice* device,
......
......@@ -119,6 +119,11 @@ void TestBluetoothAdapterObserver::RegisterDiscoveringChangedWatcher(
discovering_changed_callback_ = callback;
}
void TestBluetoothAdapterObserver::RegisterDiscoveryChangeCompletedWatcher(
base::RepeatingClosure callback) {
discovery_change_completed_callback_ = callback;
}
void TestBluetoothAdapterObserver::DeviceAdded(BluetoothAdapter* adapter,
BluetoothDevice* device) {
EXPECT_EQ(adapter_.get(), adapter);
......@@ -130,6 +135,11 @@ void TestBluetoothAdapterObserver::DeviceAdded(BluetoothAdapter* adapter,
QuitMessageLoop();
}
void TestBluetoothAdapterObserver::DiscoveryChangeCompletedForTesting() {
if (discovery_change_completed_callback_)
discovery_change_completed_callback_.Run();
}
void TestBluetoothAdapterObserver::DeviceChanged(BluetoothAdapter* adapter,
BluetoothDevice* device) {
EXPECT_EQ(adapter_.get(), adapter);
......
......@@ -33,7 +33,9 @@ class TestBluetoothAdapterObserver : public BluetoothAdapter::Observer {
void AdapterDiscoveringChanged(BluetoothAdapter* adapter,
bool discovering) override;
void RegisterDiscoveringChangedWatcher(base::RepeatingClosure callback);
void RegisterDiscoveryChangeCompletedWatcher(base::RepeatingClosure callback);
void DeviceAdded(BluetoothAdapter* adapter, BluetoothDevice* device) override;
void DiscoveryChangeCompletedForTesting() override;
void DeviceChanged(BluetoothAdapter* adapter,
BluetoothDevice* device) override;
void DeviceAddressChanged(device::BluetoothAdapter* adapter,
......@@ -235,6 +237,7 @@ class TestBluetoothAdapterObserver : public BluetoothAdapter::Observer {
base::Optional<uint16_t> last_appearance_;
base::Closure discovering_changed_callback_;
base::Closure discovery_change_completed_callback_;
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
int device_paired_changed_count_;
......
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