Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1814)

Unified Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc

Issue 1908523002: bluetooth: Make IsGattServicesDiscoveryComplete virtual (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1aa2532f31cb2a533044b47782d3084c3051b81e..9977249f368f71ac5d9926e6a24200531e1e5b0f 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
@@ -126,7 +126,6 @@ std::set<BluetoothUUID> GetUUIDs(
// Notifies the adapter's observers that the services have been discovered.
void NotifyServicesDiscovered(MockBluetoothAdapter* adapter,
MockBluetoothDevice* device) {
- device->SetGattServicesDiscoveryComplete(true);
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter->GetObservers(),
GattServicesDiscovered(adapter, device));
}
@@ -447,23 +446,18 @@ LayoutTestBluetoothAdapterProvider::GetDelayedServicesDiscoveryAdapter() {
MockBluetoothAdapter* adapter_ptr = adapter.get();
MockBluetoothDevice* device_ptr = device.get();
- // Override the previous mock implementation of CreateGattConnection that
- // this a NotifyServicesDiscovered task. Instead thsi adapter will not post
- // that task until GetGattServices is called.
- ON_CALL(*device, CreateGattConnection(_, _))
- .WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
- [adapter_ptr, device_ptr]() {
- return base::WrapUnique(new NiceMockBluetoothGattConnection(
- adapter_ptr, device_ptr->GetAddress()));
- }));
-
- ON_CALL(*device, GetGattServices())
+ // Override the previous mock implementation of
+ // IsGattServicesDiscoveryComplete so that the first time the function is
+ // called it returns false, adds a service and posts a task to notify
+ // the services have been discovered. Subsequent calls to the function
+ // will return true.
+ ON_CALL(*device, IsGattServicesDiscoveryComplete())
.WillByDefault(Invoke([adapter_ptr, device_ptr] {
std::vector<BluetoothGattService*> services =
device_ptr->GetMockServices();
if (services.size() > 0) {
scheib 2016/04/20 17:50:35 This request of mine will make the code diff large
ortuno 2016/04/20 18:03:19 Done.
- return services;
+ return true;
}
std::unique_ptr<NiceMockBluetoothGattService> heart_rate(
@@ -475,7 +469,7 @@ LayoutTestBluetoothAdapterProvider::GetDelayedServicesDiscoveryAdapter() {
base::RetainedRef(adapter_ptr), device_ptr));
DCHECK(services.size() == 0);
- return services;
+ return false;
}));
adapter->AddMockDevice(std::move(device));
@@ -658,13 +652,13 @@ LayoutTestBluetoothAdapterProvider::GetConnectableDevice(
ON_CALL(*device, CreateGattConnection(_, _))
.WillByDefault(RunCallbackWithResult<0 /* success_callback */>(
[adapter, device_ptr]() {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&NotifyServicesDiscovered,
- base::RetainedRef(adapter), device_ptr));
return base::WrapUnique(new NiceMockBluetoothGattConnection(
adapter, device_ptr->GetAddress()));
}));
+ ON_CALL(*device, IsGattServicesDiscoveryComplete())
+ .WillByDefault(Return(true));
+
return device;
}
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698